private static void AddDiagnosticIdToOptionMapping(string diagnosticId, ILanguageSpecificOption option, string language) { if (option != null) { AddDiagnosticIdToOptionMapping(diagnosticId, ImmutableHashSet.Create(option), language); } }
/// <summary> /// Constructor for a code style analyzer with a single diagnostic descriptor and /// unique <see cref="ILanguageSpecificOption"/> code style option for the given language. /// </summary> /// <param name="diagnosticId">Diagnostic ID reported by this analyzer</param> /// <param name="option"> /// Language specific option that can be used to configure the given diagnosticId. /// Null, if there is no such unique option. /// </param> /// <param name="language">Language for the given language-specific <paramref name="option"/>.</param> /// <param name="title">Title for the diagnostic descriptor</param> /// <param name="messageFormat"> /// Message for the diagnostic descriptor. /// Null if the message is identical to the title. /// </param> /// <param name="configurable">Flag indicating if the reported diagnostics are configurable by the end users</param> protected AbstractBuiltInCodeStyleDiagnosticAnalyzer( string diagnosticId, ILanguageSpecificOption option, string language, LocalizableString title, LocalizableString messageFormat = null, bool configurable = true) : base(diagnosticId, title, messageFormat, configurable) { AddDiagnosticIdToOptionMapping(diagnosticId, option, language); }
public static T GetOption <T>(this AnalyzerOptions analyzerOptions, ILanguageSpecificOption <T> option, SyntaxTree syntaxTree, CancellationToken cancellationToken) { var optionAsync = GetOptionAsync <T>(analyzerOptions, option, language: null, syntaxTree, cancellationToken); if (optionAsync.IsCompleted) { return(optionAsync.Result); } return(optionAsync.AsTask().GetAwaiter().GetResult()); }