/// <summary> /// Updates or adds an .editorconfig <see cref="AnalyzerConfigDocument"/> to the given <paramref name="project"/> /// so that the severity of the given <paramref name="diagnostic"/> is configured to be the given /// <paramref name="editorConfigSeverity"/>. /// </summary> public static Task <Solution> ConfigureSeverityAsync( string editorConfigSeverity, Diagnostic diagnostic, Project project, CancellationToken cancellationToken) { // For option based code style diagnostic, try to find the .editorconfig key-value pair for the // option setting. var codeStyleOptionValues = GetCodeStyleOptionValuesForDiagnostic(diagnostic, project); ConfigurationUpdater updater; if (!codeStyleOptionValues.IsEmpty) { return(ConfigureCodeStyleOptionsAsync( codeStyleOptionValues.Select(t => (t.optionName, t.currentOptionValue, editorConfigSeverity, t.isPerLanguage)), diagnostic, project, configurationKind: ConfigurationKind.Severity, cancellationToken)); } else { updater = new ConfigurationUpdater(optionNameOpt: null, newOptionValueOpt: null, editorConfigSeverity, configurationKind: ConfigurationKind.Severity, diagnostic, isPerLanguage: false, project, cancellationToken); return(updater.ConfigureAsync()); } }
private static Task <Solution> BulkConfigureSeverityCoreAsync( string editorConfigSeverity, string category, Project project, CancellationToken cancellationToken) { Contract.ThrowIfNull(category); var updater = new ConfigurationUpdater(optionNameOpt: null, newOptionValueOpt: null, editorConfigSeverity, configurationKind: ConfigurationKind.BulkConfigure, diagnosticToConfigure: null, category, isPerLanguage: false, project, cancellationToken); return(updater.ConfigureAsync()); }