Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
This rule is designed to ensure that the correct language is specified for the DiagnosticAnalyzer attribute in C#. The DiagnosticAnalyzer attribute is used to indicate that a class is a diagnostic analyzer, which is a component that analyzes code to find problems. The language parameter specifies the language that the analyzer supports.
It is crucial to accurately specify the language of the DiagnosticAnalyzer because it determines the language syntax and semantics the analyzer will use. If you specify the wrong language, it can lead to incorrect or incomplete code analysis.
How to remediate
To fix this issue, always specify “C#” as the language for DiagnosticAnalyzer in C# projects. For instance, use [DiagnosticAnalyzer("C#")] to indicate that the analyzer supports C# language. Avoid specifying other languages such as [DiagnosticAnalyzer("C")] or [DiagnosticAnalyzer("VB")] in a C# project.
Non-Compliant Code Examples
// language should be C#[DiagnosticAnalyzer("C")]classMyAnalyzer:DiagnosticAnalyzer{}