public override void Initialize(AnalysisContext analysisContext) { analysisContext.EnableConcurrentExecution(); analysisContext.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); analysisContext.RegisterSymbolAction(context => { var field = (IFieldSymbol)context.Symbol; if (field.ContainingType == null || field.ContainingType.TypeKind != TypeKind.Enum || !WordParser.ContainsWord(field.Name, WordParserOptions.SplitCompoundWords, reservedWords)) { return; } // FxCop compat: only analyze externally visible symbols by default. if (!field.MatchesConfiguredVisibility(context.Options, Rule, context.CancellationToken)) { return; } context.ReportDiagnostic(field.CreateDiagnostic(Rule, field.ContainingType.Name, field.Name)); }, SymbolKind.Field); }
private static ValueValidator?GetValueValidator(string name) { foreach (var valueValidator in s_tokensToValueValidator) { if (WordParser.ContainsWord(name, WordParserOptions.SplitCompoundWords, valueValidator.AcceptedTokens)) { return(valueValidator); } } return(null); }