Non-abstract sub-types of DiagnosticAnalyzer should be marked with DiagnosticAnalyzerAttribute(s). The argument to this attribute(s), if any, determine the supported languages for the analyzer. Analyzer types without this attribute will be ignored by the analysis engine.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | True |
You must specify at least one syntax, symbol or operation kind when registering a syntax, symbol, or operation analyzer action respectively. Otherwise, the registered action will never be invoked during analysis.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
SymbolKind '{0}' is not supported for symbol analyzer actions
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
Diagnostic analyzer is marked as supporting only one language, but the analyzer assembly doesn't seem to refer to any language specific CodeAnalysis assemblies, and so is likely to work for more than one language. Consider adding an additional language argument to DiagnosticAnalyzerAttribute.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
ReportDiagnostic should only be invoked with supported DiagnosticDescriptors that are returned from DiagnosticAnalyzer.SupportedDiagnostics property. Otherwise, the reported diagnostic will be filtered out by the analysis engine.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
DiagnosticAnalyzer's language-specific Register methods, such as RegisterSyntaxNodeAction, RegisterCodeBlockStartAction and RegisterCodeBlockEndAction, expect a language-specific 'SyntaxKind' type argument for it's 'TLanguageKindEnumName' type parameter. Otherwise, the registered analyzer action can never be invoked during analysis.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
If your diagnostic analyzer and it's reported diagnostics need to be localizable, then the supported DiagnosticDescriptors used for constructing the diagnostics must also be localizable. If so, then localizable argument(s) must be provided for parameter 'title' (and optionally 'description') to the diagnostic descriptor constructor to ensure that the descriptor is localizable.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisLocalization |
Enabled | False |
Severity | Warning |
CodeFix | False |
Instance of a diagnostic analyzer might outlive the lifetime of compilation. Hence, storing per-compilation data, such as symbols, into the fields of a diagnostic analyzer might cause stale compilations to stay alive and cause memory leaks. Instead, you should store this data on a separate type instantiated in a compilation start action, registered using 'AnalysisContext.RegisterCompilationStartAction' API. An instance of this type will be created per-compilation and it won't outlive compilation's lifetime, hence avoiding memory leaks.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisPerformance |
Enabled | True |
Severity | Warning |
CodeFix | False |
The author of this interface did not intend to have third party implementations of this interface and reserves the right to change it. Implementing this interface could therefore result in a source or binary compatibility issue with a future version of this interface.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCompatibility |
Enabled | True |
Severity | Error |
CodeFix | False |
A CodeFixProvider that intends to support fix all occurrences must classify the registered code actions into equivalence classes by assigning it an explicit, non-null equivalence key which is unique for each kind of code action created by this fixer. This enables the FixAllProvider to fix all diagnostics in the required scope by applying code actions from this fixer that are in the equivalence class of the trigger code action.
Item | Value |
---|---|
Category | Correctness |
Enabled | True |
Severity | Warning |
CodeFix | False |
A CodeFixProvider that intends to support fix all occurrences must classify the registered code actions into equivalence classes by assigning it an explicit, non-null equivalence key which is unique for each kind of code action created by this fixer. This enables the FixAllProvider to fix all diagnostics in the required scope by applying code actions from this fixer that are in the equivalence class of the trigger code action.
Item | Value |
---|---|
Category | Correctness |
Enabled | True |
Severity | Warning |
CodeFix | False |
An analyzer start action enables performing stateful analysis over a given code unit, such as a code block, compilation, etc. Careful design is necessary to achieve efficient analyzer execution without memory leaks. Use the following guidelines for writing such analyzers:
-
Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.
-
If required, define and initialize state in the start action.
-
Register at least one non-end action that refers to this state in the start action. If no such action is necessary, consider replacing the start action with a non-start action. For example, a CodeBlockStartAction with no registered actions or only a registered CodeBlockEndAction should be replaced with a CodeBlockAction.
-
If required, register an end action to report diagnostics based on the final state.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisPerformance |
Enabled | True |
Severity | Warning |
CodeFix | False |
An analyzer start action enables performing stateful analysis over a given code unit, such as a code block, compilation, etc. Careful design is necessary to achieve efficient analyzer execution without memory leaks. Use the following guidelines for writing such analyzers:
-
Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.
-
If required, define and initialize state in the start action.
-
Register at least one non-end action that refers to this state in the start action. If no such action is necessary, consider replacing the start action with a non-start action. For example, a CodeBlockStartAction with no registered actions or only a registered CodeBlockEndAction should be replaced with a CodeBlockAction.
-
If required, register an end action to report diagnostics based on the final state.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisPerformance |
Enabled | True |
Severity | Warning |
CodeFix | False |
Many objects exposed by Roslyn are immutable. The return value from a method invocation on these objects should not be ignored.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
The 'helpLinkUri' value is used to show information when this diagnostic in the error list. Every analyzer should have a helpLinkUri specified which points to a help page that does not change over time.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDocumentation |
Enabled | False |
Severity | Warning |
CodeFix | False |
A CodeFixProvider should provide FixAll support to enable users to fix multiple instances of the underlying diagnostic with a single code fix. See documentation at https://github.com/dotnet/roslyn/blob/main/docs/analyzers/FixAllProvider.md for further details.
Item | Value |
---|---|
Category | Correctness |
Enabled | True |
Severity | Warning |
CodeFix | True |
DiagnosticId for analyzers must be a non-null constant.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
DiagnosticId for analyzers must be in specified format.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
DiagnosticId must be unique across analyzers.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
Category for analyzers must be from the specified values.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | False |
Severity | Warning |
CodeFix | False |
Invalid entry in analyzer category and diagnostic ID range specification file.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS1022: Do not use types from Workspaces assembly in an analyzer
Diagnostic analyzer types should not use types from Workspaces assemblies. Workspaces assemblies are only available when the analyzer executes in Visual Studio IDE live analysis, but are not available during command line build. Referencing types from Workspaces assemblies will lead to runtime exception during analyzer execution in command line build.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS1023: Upgrade MSBuildWorkspace
MSBuildWorkspace has moved to the Microsoft.CodeAnalysis.Workspaces.MSBuild NuGet package and there are breaking API changes.
Item | Value |
---|---|
Category | Library |
Enabled | True |
Severity | Warning |
CodeFix | False |
Symbols should be compared for equality, not identity. Use an overload accepting an 'IEqualityComparer' and pass 'SymbolEqualityComparer'.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | True |
Configure generated code analysis
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | True |
Enable concurrent execution
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | True |
Inherit type '{0}' from DiagnosticAnalyzer or remove the DiagnosticAnalyzerAttribute(s)
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
The 'customTags' value is used as a way to enable specific actions and filters on diagnostic descriptors based on the specific values of the tags. Every Roslyn analyzer should have at least one tag from the 'WellKnownDiagnosticTags' class.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDocumentation |
Enabled | False |
Severity | Warning |
CodeFix | False |
DiagnosticId for analyzers should not use reserved IDs.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
'GetSemanticModel' is an expensive method to invoke within a diagnostic analyzer because it creates a completely new semantic model, which does not share compilation data with the compiler or other analyzers. This incurs an additional performance cost during semantic analysis. Instead, consider registering a different analyzer action which allows used of a shared 'SemanticModel', such as 'RegisterOperationAction', 'RegisterSyntaxNodeAction', or 'RegisterSemanticModelAction'.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
The diagnostic title should not contain a period, nor any line return character, nor any leading or trailing whitespaces
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | True |
The diagnostic message should not contain any line return character nor any leading or trailing whitespaces and should either be a single sentence without a trailing period or a multi-sentences with a trailing period
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | True |
The diagnostic description should be one or multiple sentences ending with a punctuation sign and should not have any leading or trailing whitespaces
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | True |
Prefer 'syntax.IsKind(kind)' to 'syntax.Kind() == kind' when checking syntax kinds. Code using 'IsKind' is slightly more efficient at runtime, so consistent use of this form where applicable helps improve performance in complex analysis scenarios.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisPerformance |
Enabled | True |
Severity | Warning |
CodeFix | True |
The symbol has been marked as banned for use in analyzers, and an alternate should be used instead.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Error |
CodeFix | False |
A project containing analyzers or source generators should specify the property '<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>'.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
'DiagnosticDescriptor' assigned to field is used to report a compilation end diagnostic, but the 'DiagnosticDescriptor' constructor used to initialize it does not pass in the required custom tag "CompilationEnd". See documentation for 'WellKnownDiagnosticTags.CompilationEnd' for details.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisDesign |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS1038: Compiler extensions should be implemented in assemblies with compiler-provided references
Types which implement compiler extension points should not be declared in assemblies that contain references to assemblies which are not provided by all compilation scenarios. Doing so may cause the feature to behave unpredictably.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
Calling 'SemanticModel.GetDeclaredSymbol' with on certain types inheriting from 'SyntaxNode', for example 'GlobalStatementSyntax' and 'IncompleteMemberSyntax' will always return 'null'.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
Calling 'SemanticModel.GetDeclaredSymbol' with an argument of type 'FieldDeclarationSyntax' or 'EventFieldDeclarationSyntax' will always return 'null'. Call 'GetDeclaredSymbol' with the variable declarators from the field instead.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisCorrectness |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2000: Add analyzer diagnostic IDs to analyzer release
All supported analyzer diagnostic IDs should be part of an analyzer release.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | True |
RS2001: Ensure up-to-date entry for analyzer diagnostic IDs are added to analyzer release
Ensure up-to-date entry for analyzer diagnostic IDs are added to analyzer release.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | True |
RS2002: Do not add removed analyzer diagnostic IDs to unshipped analyzer release
Entries for analyzer diagnostic IDs that are no longer reported and never shipped can be removed from unshipped analyzer release.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2003: Shipped diagnostic IDs that are no longer reported should have an entry in the 'Removed Rules' table in unshipped file
Shipped diagnostic IDs that are no longer reported should have an entry in the 'Removed Rules' table in unshipped file.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2004: Diagnostic IDs marked as removed in analyzer release file should not be reported by analyzers
Diagnostic IDs marked as removed in analyzer release file should not be reported by analyzers.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2005: Remove duplicate entries for diagnostic ID in the same analyzer release
Remove duplicate entries for diagnostic ID in the same analyzer release.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2006: Remove duplicate entries for diagnostic ID between analyzer releases
Remove duplicate entries for diagnostic ID between analyzer releases.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2007: Invalid entry in analyzer release file
Invalid entry in analyzer release file.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | False |
RS2008: Enable analyzer release tracking
Enabling release tracking for analyzer packages helps in tracking and documenting the analyzer diagnostics that ship and/or change with each analyzer release. See details at https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md.
Item | Value |
---|---|
Category | MicrosoftCodeAnalysisReleaseTracking |
Enabled | True |
Severity | Warning |
CodeFix | True |