diff --git a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs index 420d916dc24d0..4f80225d950f1 100644 --- a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsClassificationTaggerProvider.cs @@ -32,7 +32,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics [TagType(typeof(ClassificationTag))] internal partial class DiagnosticsClassificationTaggerProvider : AbstractDiagnosticsTaggerProvider { - private static readonly IEnumerable> s_tagSourceOptions = new[] { EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Classification, ServiceComponentOnOffOptions.DiagnosticProvider }; + private static readonly IEnumerable> s_tagSourceOptions = new[] { EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Classification }; private readonly ClassificationTypeMap _typeMap; private readonly ClassificationTag _classificationTag; diff --git a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSquiggleTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSquiggleTaggerProvider.cs index 3ff1ec5c0b98e..17a62b90d5e54 100644 --- a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSquiggleTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSquiggleTaggerProvider.cs @@ -28,7 +28,7 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics internal partial class DiagnosticsSquiggleTaggerProvider : AbstractDiagnosticsAdornmentTaggerProvider { private static readonly IEnumerable> s_tagSourceOptions = - ImmutableArray.Create(EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Squiggles, ServiceComponentOnOffOptions.DiagnosticProvider); + ImmutableArray.Create(EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Squiggles); protected override IEnumerable> Options => s_tagSourceOptions; diff --git a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSuggestionTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSuggestionTaggerProvider.cs index 219bd48ea4278..550b4330b4f06 100644 --- a/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSuggestionTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Diagnostics/DiagnosticsSuggestionTaggerProvider.cs @@ -28,7 +28,7 @@ internal partial class DiagnosticsSuggestionTaggerProvider : AbstractDiagnosticsAdornmentTaggerProvider { private static readonly IEnumerable> s_tagSourceOptions = - ImmutableArray.Create(EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Squiggles, ServiceComponentOnOffOptions.DiagnosticProvider); + ImmutableArray.Create(EditorComponentOnOffOptions.Tagger, InternalFeatureOnOffOptions.Squiggles); protected override IEnumerable> Options => s_tagSourceOptions; diff --git a/src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb b/src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb index 34eae7c6195c6..38561611d1d28 100644 --- a/src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb +++ b/src/EditorFeatures/Test2/Diagnostics/DiagnosticProviderTests.vb @@ -203,35 +203,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests VerifyAllAvailableDiagnostics(test, diagnostics, ordered:=False) End Sub - - Public Sub TestDiagnosticsFromTurnedOff() - Dim test = - - - class Program - { - - - void Test() - { - int a = 5 - "2"; - } - } - - - - - Class GooClass - Sub Blah() End Sub - End Class - - - - - Dim diagnostics = - - VerifyAllAvailableDiagnostics(test, diagnostics, ordered:=False, enabled:=False) - End Sub - Public Sub WarningsAsErrors() Dim test = @@ -283,17 +254,9 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests VerifyAllAvailableDiagnostics(test, diagnostics) End Sub - Private Shared Sub VerifyAllAvailableDiagnostics(test As XElement, diagnostics As XElement, Optional ordered As Boolean = True, Optional enabled As Boolean = True) + Private Shared Sub VerifyAllAvailableDiagnostics(test As XElement, diagnostics As XElement, Optional ordered As Boolean = True) Using workspace = TestWorkspace.CreateWorkspace(test, composition:=s_composition) - ' turn off diagnostic - If Not enabled Then - workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options _ - .WithChangedOption(ServiceComponentOnOffOptions.DiagnosticProvider, False) _ - .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.CSharp, BackgroundAnalysisScope.Default) _ - .WithChangedOption(SolutionCrawlerOptions.BackgroundAnalysisScopeOption, LanguageNames.VisualBasic, BackgroundAnalysisScope.Default))) - End If - Dim registrationService = workspace.Services.GetService(Of ISolutionCrawlerRegistrationService)() registrationService.Register(workspace) diff --git a/src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs b/src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs index 571d91a2d788b..66714ac6169eb 100644 --- a/src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs +++ b/src/Features/Core/Portable/Diagnostics/DefaultDiagnosticAnalyzerService.cs @@ -36,14 +36,7 @@ public DefaultDiagnosticAnalyzerService( } public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) - { - if (!workspace.Options.GetOption(ServiceComponentOnOffOptions.DiagnosticProvider)) - { - return null; - } - - return new DefaultDiagnosticIncrementalAnalyzer(this, workspace); - } + => new DefaultDiagnosticIncrementalAnalyzer(this, workspace); public event EventHandler DiagnosticsUpdated; public event EventHandler DiagnosticsCleared { add { } remove { } } diff --git a/src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs b/src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs index da10c4b1912a2..647c9d0dbc23e 100644 --- a/src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs +++ b/src/Features/Core/Portable/Diagnostics/DiagnosticAnalyzerService_IncrementalAnalyzer.cs @@ -20,14 +20,7 @@ namespace Microsoft.CodeAnalysis.Diagnostics internal partial class DiagnosticAnalyzerService : IIncrementalAnalyzerProvider { public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace) - { - if (!workspace.Options.GetOption(ServiceComponentOnOffOptions.DiagnosticProvider)) - { - return null; - } - - return _map.GetValue(workspace, _createIncrementalAnalyzer); - } + => _map.GetValue(workspace, _createIncrementalAnalyzer); public void ShutdownAnalyzerFrom(Workspace workspace) { diff --git a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs deleted file mode 100644 index 67e5078c2c9a6..0000000000000 --- a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -// 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. - -#nullable disable - -using Microsoft.CodeAnalysis.Options; - -namespace Microsoft.CodeAnalysis.Shared.Options -{ - /// - /// options to indicate whether a certain component in Roslyn is enabled or not - /// - internal static class ServiceComponentOnOffOptions - { - public static readonly Option2 DiagnosticProvider = new(nameof(ServiceComponentOnOffOptions), nameof(DiagnosticProvider), defaultValue: true); - } -} diff --git a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs b/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs deleted file mode 100644 index 958f9b891c536..0000000000000 --- a/src/Features/Core/Portable/Shared/Options/ServiceComponentOnOffOptionsProvider.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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. - -#nullable disable - -using System; -using System.Collections.Immutable; -using System.Composition; -using Microsoft.CodeAnalysis.Host.Mef; -using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Options.Providers; - -namespace Microsoft.CodeAnalysis.Shared.Options -{ - [ExportOptionProvider, Shared] - internal class ServiceComponentOnOffOptionsProvider : IOptionProvider - { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public ServiceComponentOnOffOptionsProvider() - { - } - - public ImmutableArray Options { get; } = ImmutableArray.Create( - ServiceComponentOnOffOptions.DiagnosticProvider); - } -}