Skip to content

Commit

Permalink
Merge pull request #619 from StefanMaron/PredefinedActionCategoryNames
Browse files Browse the repository at this point in the history
Implement PredefinedActionCategoryNames from SyntaxFacts on rule0016
Arthurvdv authored May 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents c20a1ff + f1fe5b9 commit 578937a
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions Design/Rule0016CheckForMissingCaptions.cs
Original file line number Diff line number Diff line change
@@ -12,29 +12,7 @@ class Rule0016CheckForMissingCaptions : DiagnosticAnalyzer
{
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } = ImmutableArray.Create<DiagnosticDescriptor>(DiagnosticDescriptors.Rule0016CheckForMissingCaptions);

private static readonly List<string> PromotedGroupNames = new List<string>
{
"category_new",
"category_process",
"category_report",
"category_category4",
"category_category5",
"category_category6",
"category_category7",
"category_category8",
"category_category9",
"category_category10",
"category_category11",
"category_category12",
"category_category13",
"category_category14",
"category_category15",
"category_category16",
"category_category17",
"category_category18",
"category_category19",
"category_category20",
};
private static readonly HashSet<string> _predefinedActionCategoryNames = SyntaxFacts.PredefinedActionCategoryNames.Select(x => x.Key.ToLowerInvariant()).ToHashSet();

public override void Initialize(AnalysisContext context)
=> context.RegisterSymbolAction(new Action<SymbolAnalysisContext>(this.CheckForMissingCaptions),
@@ -176,7 +154,7 @@ private bool CaptionIsMissing(ISymbol Symbol, SymbolAnalysisContext context)
return false;
}

if (SemanticFacts.IsSameName(Symbol.MostSpecificKind, "Group") && PromotedGroupNames.Contains(Symbol.Name.ToLowerInvariant()))
if (Symbol.Kind == SymbolKind.Action && ((IActionSymbol)Symbol).ActionKind == ActionKind.Group && _predefinedActionCategoryNames.Contains(Symbol.Name.ToLowerInvariant()))
return false;

if (Symbol.GetBooleanPropertyValue(PropertyKind.ShowCaption) != false)

0 comments on commit 578937a

Please sign in to comment.