public bool IsFixableDiagnostic(Diagnostic diagnostic) { // We only offer fix for configurable code style diagnostics which have one of more editorconfig based storage locations. // Also skip suppressed diagnostics defensively, though the code fix engine should ideally never call us for suppressed diagnostics. if ( diagnostic.IsSuppressed || SuppressionHelpers.IsNotConfigurableDiagnostic(diagnostic) || diagnostic.Location.SourceTree == null ) { return(false); } var language = diagnostic.Location.SourceTree.Options.Language; return(IDEDiagnosticIdToOptionMappingHelper.TryGetMappedOptions( diagnostic.Id, language, out var options ) && !options.IsEmpty && options.All( o => o.StorageLocations.Any(l => l is IEditorConfigStorageLocation2) )); }
/// <summary> /// Returns true if an entry's suppression state can be modified. /// </summary> /// <returns></returns> private static bool IsEntryWithConfigurableSuppressionState(DiagnosticData entry) { // Compiler diagnostics with severity 'Error' are not configurable. // Additionally, diagnostics coming from build are from a snapshot (as opposed to live diagnostics) and cannot be configured. return(entry != null && !SuppressionHelpers.IsNotConfigurableDiagnostic(entry) && !entry.IsBuildDiagnostic()); }
private void OnErrorListSetSeveritySubMenuStatus(object sender, EventArgs e) { // For now, we only enable the Set severity menu when a single configurable diagnostic is selected in the error list // and we can update/create an editorconfig file for the configuration entry. // In future, we can enable support for configuring in presence of multi-selection. var command = (MenuCommand)sender; var selectedEntry = TryGetSingleSelectedEntry(); command.Visible = selectedEntry != null && !SuppressionHelpers.IsNotConfigurableDiagnostic(selectedEntry) && TryGetPathToAnalyzerConfigDoc(selectedEntry, out _, out _); command.Enabled = command.Visible && !KnownUIContexts.SolutionBuildingContext.IsActive; }
/// <summary> /// Returns true if an entry's suppression state can be modified. /// </summary> /// <returns></returns> private static bool IsEntryWithConfigurableSuppressionState(DiagnosticData entry) { return(entry != null && !SuppressionHelpers.IsNotConfigurableDiagnostic(entry)); }