private static void AddDiagnosticIdToOptionMapping(string diagnosticId, IPerLanguageOption option) { if (option != null) { AddDiagnosticIdToOptionMapping(diagnosticId, ImmutableHashSet.Create(option)); } }
/// <summary> /// Constructor for a code style analyzer with a single diagnostic descriptor and /// unique <see cref="IPerLanguageOption"/> code style option. /// </summary> /// <param name="diagnosticId">Diagnostic ID reported by this analyzer</param> /// <param name="option"> /// Per-language option that can be used to configure the given diagnosticId. /// Null, if there is no such unique 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, IPerLanguageOption option, LocalizableString title, LocalizableString messageFormat = null, bool configurable = true) : base(diagnosticId, title, messageFormat, configurable) { AddDiagnosticIdToOptionMapping(diagnosticId, option); }
public static T GetOption <T>(this AnalyzerOptions analyzerOptions, IPerLanguageOption <T> option, string?language, SyntaxTree syntaxTree, CancellationToken cancellationToken) { var optionAsync = GetOptionAsync <T>(analyzerOptions, option, language, syntaxTree, cancellationToken); if (optionAsync.IsCompleted) { return(optionAsync.Result); } return(optionAsync.AsTask().GetAwaiter().GetResult()); }