// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; namespace Microsoft.CodeAnalysis.Diagnostics { public abstract class AnalyzerConfigOptions { /// /// Comparer that should be used for all analyzer config keys. This is a case-insensitive comparison based /// on Unicode case sensitivity rules for identifiers. /// public static StringComparer KeyComparer { get; } = AnalyzerConfig.Section.PropertiesKeyComparer; internal static ImmutableDictionary EmptyDictionary = ImmutableDictionary.Create(KeyComparer); /// /// Get an analyzer config value for the given key, using the . /// public abstract bool TryGetValue(string key, out string value); } internal sealed class CompilerAnalyzerConfigOptions : AnalyzerConfigOptions { public static CompilerAnalyzerConfigOptions Empty { get; } = new CompilerAnalyzerConfigOptions(EmptyDictionary); private readonly ImmutableDictionary _backing; public CompilerAnalyzerConfigOptions(ImmutableDictionary properties) { _backing = properties; } public override bool TryGetValue(string key, out string value) => _backing.TryGetValue(key, out value); } }