이 페이지는 아직 영어로 제공되지 않습니다. 번역 작업 중입니다.
현재 번역 프로젝트에 대한 질문이나 피드백이 있으신 경우 언제든지 연락주시기 바랍니다.

Metadata

ID: csharp-best-practices/diagnostic-analyzer-language

Language: C#

Severity: Warning

Category: Error Prone

Description

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")]
class MyAnalyzer : DiagnosticAnalyzer
{
}

Compliant Code Examples

[DiagnosticAnalyzer("C#")]
class MyAnalyzer : DiagnosticAnalyzer
{
}
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Security

PREVIEWING: guillaume.barrier/ERRORT-5095-general-doc-update