Currently, the diagnostics generated for analyzer load or instantiation issues are too generic and not to helpful to diagnose the root cause of failure. We have 3 of them (and corresponding VB counterparts), all of which can be enhanced:
- CS8032, i.e.
WRN_AnalyzerCannotBeCreated = 8032 (http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1269) invariably has the below message:
Severity Code Description Project File Line
Warning CS8032 An instance of analyzer Analyzer5.Analyzer5Analyzer cannot be created from C:\Users\mavasani\Documents\Visual Studio 2015\Projects\Analyzer5\Analyzer5\Analyzer5\bin\Debug\Analyzer5.dll: Exception has been thrown by the target of an invocation.. ClassLibrary1 1
We should consider embedding the exception stack trace in the diagnostic's description (on same lines as analyzer exception diagnostics here: http://source.roslyn.io/Microsoft.CodeAnalysis/R/f9e46cc7c756e697.html).
- CS8033, i.e.
WRN_NoAnalyzerInAssembly = 8033 (http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1270) has the below message:
The assembly {0} does not contain any analyzers.
We generate this diagnostic only when an analyzer assembly has types marked with "DiagnosticAnalyzerAttribute" but has no analyzers for a specific language OR there is mismatch between assembly version of Microsoft.CodeAnalysis.dll referenced by the analyzer vs used by the analyszer host (command line build/IDE). We can make this error message more helpful by pointing out the exact reason, as we already have this information at the point we generate this diagnostic: http://source.roslyn.io/#Microsoft.CodeAnalysis/DiagnosticAnalyzer/AnalyzerFileReference.cs,186
- CS834, i.e.
WRN_UnableToLoadAnalyzer = 8034 (http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1271). Even this diagnostic has just the exception message that caused Assembly load to fail for the analyzer reference assembly. We should embed the exception stack trace in the description here: http://source.roslyn.io/#Microsoft.CodeAnalysis/CommandLine/CommonCommandLineArguments.cs,347
Currently, the diagnostics generated for analyzer load or instantiation issues are too generic and not to helpful to diagnose the root cause of failure. We have 3 of them (and corresponding VB counterparts), all of which can be enhanced:
WRN_AnalyzerCannotBeCreated = 8032(http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1269) invariably has the below message:We should consider embedding the exception stack trace in the diagnostic's description (on same lines as analyzer exception diagnostics here: http://source.roslyn.io/Microsoft.CodeAnalysis/R/f9e46cc7c756e697.html).
WRN_NoAnalyzerInAssembly = 8033(http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1270) has the below message:The assembly {0} does not contain any analyzers.We generate this diagnostic only when an analyzer assembly has types marked with "DiagnosticAnalyzerAttribute" but has no analyzers for a specific language OR there is mismatch between assembly version of Microsoft.CodeAnalysis.dll referenced by the analyzer vs used by the analyszer host (command line build/IDE). We can make this error message more helpful by pointing out the exact reason, as we already have this information at the point we generate this diagnostic: http://source.roslyn.io/#Microsoft.CodeAnalysis/DiagnosticAnalyzer/AnalyzerFileReference.cs,186
WRN_UnableToLoadAnalyzer = 8034(http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Errors/ErrorCode.cs,1271). Even this diagnostic has just the exception message that caused Assembly load to fail for the analyzer reference assembly. We should embed the exception stack trace in the description here: http://source.roslyn.io/#Microsoft.CodeAnalysis/CommandLine/CommonCommandLineArguments.cs,347