private void SymbolAction(
            SymbolAnalysisContext context,
            ConcurrentDictionary <Guid, ConcurrentDictionary <string, string> > idToCachedResult)
        {
            if (string.IsNullOrEmpty(context.Symbol.Name))
            {
                return;
            }

            var namingPreferences = context.GetNamingStylePreferencesAsync().GetAwaiter().GetResult();

            if (namingPreferences == null)
            {
                return;
            }

            var namingStyleRules = namingPreferences.Rules;

            if (!namingStyleRules.TryGetApplicableRule(context.Symbol, out var applicableRule) ||
                applicableRule.EnforcementLevel == DiagnosticSeverity.Hidden)
            {
                return;
            }

            var cache = idToCachedResult.GetOrAdd(applicableRule.NamingStyle.ID, s_createCache);

            if (!cache.TryGetValue(context.Symbol.Name, out var failureReason))
            {
                if (applicableRule.NamingStyle.IsNameCompliant(context.Symbol.Name, out failureReason))
                {
                    failureReason = null;
                }

                cache.TryAdd(context.Symbol.Name, failureReason);
            }

            if (failureReason == null)
            {
                return;
            }

            var descriptor = new DiagnosticDescriptor(IDEDiagnosticIds.NamingRuleId,
                                                      s_localizableTitleNamingStyle,
                                                      string.Format(FeaturesResources.Naming_rule_violation_0, failureReason),
                                                      DiagnosticCategory.Style,
                                                      applicableRule.EnforcementLevel,
                                                      isEnabledByDefault: true);

            var builder = ImmutableDictionary.CreateBuilder <string, string>();

            builder[nameof(NamingStyle)] = applicableRule.NamingStyle.CreateXElement().ToString();
            builder["OptionName"]        = nameof(SimplificationOptions.NamingPreferences);
            builder["OptionLanguage"]    = context.Compilation.Language;
            context.ReportDiagnostic(Diagnostic.Create(descriptor, context.Symbol.Locations.First(), builder.ToImmutable()));
        }