3
是否可以使用Roslyn檢測不可達代碼或其他內置編譯警告?是否有可能使用Roslyn檢測不可達代碼或其他內置編譯警告
private void DoSomething()
{
string a = "TEST";
throw new Exception("Why would I throw an exception here?");
a = "This will never be reached"; //this is a compile time warning for unreachable code...Can I detect it?
}
我試過檢查語義和語法方法中的節點屬性,但沒有看到任何問題或警告集合。
謝謝,我還沒有看到在我使用Roslyn到這一點時AnalyzeRegionControlFlow的用法。很棒。 – Jay 2012-04-20 13:14:16