提交 8c876a0c 编写于 作者: M Manish Vasani

Add a debug check to ensure all CodeStyle diagnostic descriptors have...

Add a debug check to ensure all CodeStyle diagnostic descriptors have EnforceOnBuild custom tag + Fix the missing tag for IDE0043 identified from this assert
上级 597d719e
......@@ -5,6 +5,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.LanguageServices;
using Roslyn.Utilities;
......@@ -39,7 +40,8 @@ internal abstract class AbstractValidateFormatStringDiagnosticAnalyzer<TSyntaxKi
DiagnosticCategory.Compiler,
DiagnosticSeverity.Info,
isEnabledByDefault: true,
description: Description);
description: Description,
customTags: EnforceOnBuildValues.ValidateFormatString.ToCustomTag());
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
=> ImmutableArray.Create(Rule);
......
......@@ -22,6 +22,7 @@ public static class Program
private const int ExpectedArguments = 4;
private static readonly string s_neverTag = EnforceOnBuild.Never.ToCustomTag();
private static readonly string s_whenExplicitlyEnabledTag = EnforceOnBuild.WhenExplicitlyEnabled.ToCustomTag();
private static readonly string s_recommendedTag = EnforceOnBuild.Recommended.ToCustomTag();
private static readonly string s_highlyRecommendedTag = EnforceOnBuild.HighlyRecommended.ToCustomTag();
......@@ -152,6 +153,9 @@ bool AddRule(DiagnosticDescriptor rule)
(bool isEnabledByDefault, DiagnosticSeverity effectiveSeverity) GetEnabledByDefaultAndSeverity(DiagnosticDescriptor rule, AnalysisMode analysisMode)
{
Debug.Assert(rule.CustomTags.Any(c => c == s_neverTag || c == s_whenExplicitlyEnabledTag || c == s_recommendedTag || c == s_highlyRecommendedTag),
$"DiagnosticDescriptor for '{rule.Id}' must have a {nameof(EnforceOnBuild)} custom tag");
bool isEnabledInNonDefaultMode;
switch (analysisMode)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册