Skip to content

Latest commit

 

History

History
29 lines (28 loc) · 9.91 KB

File metadata and controls

29 lines (28 loc) · 9.91 KB
Sr. No. Rule ID Title Category Enabled CodeFix Description
1 RS1001 Missing diagnostic analyzer attribute. MicrosoftCodeAnalysisCorrectness True True 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.
2 RS1002 Missing kind argument when registering an analyzer action. MicrosoftCodeAnalysisCorrectness True False 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.
3 RS1003 Unsupported SymbolKind argument when registering a symbol analyzer action. MicrosoftCodeAnalysisCorrectness True False SymbolKind '{0}' is not supported for symbol analyzer actions.
4 RS1004 Recommend adding language support to diagnostic analyzer. MicrosoftCodeAnalysisCorrectness True 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.
5 RS1005 ReportDiagnostic invoked with an unsupported DiagnosticDescriptor. MicrosoftCodeAnalysisCorrectness True 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.
6 RS1006 Invalid type argument for DiagnosticAnalyzer's Register method. MicrosoftCodeAnalysisCorrectness True 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.
7 RS1007 Provide localizable arguments to diagnostic descriptor constructor. MicrosoftCodeAnalysisLocalization False 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.
8 RS1008 Avoid storing per-compilation data into the fields of a diagnostic analyzer. MicrosoftCodeAnalysisPerformance True 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.
9 RS1009 Only internal implementations of this interface are allowed. MicrosoftCodeAnalysisCompatibility True 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.
10 RS1010 Create code actions should have a unique EquivalenceKey for FixAll occurrences support. Correctness True 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.
11 RS1011 Use code actions that have a unique EquivalenceKey for FixAll occurrences support. Correctness True 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.
12 RS1012 Start action has no registered actions. MicrosoftCodeAnalysisPerformance True 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:
1. Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.
2. If required, define and initialize state in the start action.
3. 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.
4. If required, register an end action to report diagnostics based on the final state.
13 RS1013 Start action has no registered non-end actions. MicrosoftCodeAnalysisPerformance True 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:
1. Define a new scope for the registered start action, possibly with a private nested type for analyzing each code unit.
2. If required, define and initialize state in the start action.
3. 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.
4. If required, register an end action to report diagnostics based on the final state.
14 RS1014 Do not ignore values returned by methods on immutable objects. MicrosoftCodeAnalysisCorrectness True False Many objects exposed by Roslyn are immutable. The return value from a method invocation on these objects should not be ignored.
15 RS1015 Provide non-null 'helpLinkUri' value to diagnostic descriptor constructor. MicrosoftCodeAnalysisDocumentation False 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.
16 RS1016 Code fix providers should provide FixAll support. Correctness True True A CodeFixProvider should provide FixAll support to enable users to fix multiple instances of the underlying diagnostic with a single code fix. See documenation at https://github.com/dotnet/roslyn/blob/master/docs/analyzers/FixAllProvider.md for further details.
17 RS1017 DiagnosticId for analyzers must be a non-null constant. MicrosoftCodeAnalysisDesign True False DiagnosticId for analyzers must be a non-null constant.
18 RS1018 DiagnosticId for analyzers must be in specified format. MicrosoftCodeAnalysisDesign True False DiagnosticId for analyzers must be in specified format.
19 RS1019 DiagnosticId must be unique across analyzers. MicrosoftCodeAnalysisDesign True False DiagnosticId must be unique across analyzers.
20 RS1020 Category for analyzers must be from the specified values. MicrosoftCodeAnalysisDesign False False Category for analyzers must be from the specified values.
21 RS1021 Invalid entry in analyzer category and diagnostic ID range specification file. MicrosoftCodeAnalysisDesign True False Invalid entry in analyzer category and diagnostic ID range specification file.
22 RS1022 Do not use types from Workspaces assembly in an analyzer MicrosoftCodeAnalysisCorrectness True False 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.
23 RS1023 Upgrade MSBuildWorkspace Library True False MSBuildWorkspace has moved to the Microsoft.CodeAnalysis.Workspaces.MSBuild NuGet package and there are breaking API changes.
24 RS1024 Compare symbols correctly MicrosoftCodeAnalysisCorrectness True True Symbols should be compared for equality, not identity.
25 RS1025 Configure generated code analysis MicrosoftCodeAnalysisCorrectness True True Configure generated code analysis
26 RS1026 Enable concurrent execution MicrosoftCodeAnalysisCorrectness True True Enable concurrent execution