diff --git a/src/EditorFeatures/Core.Wpf/Structure/VisualStudio14StructureTaggerProvider.cs b/src/EditorFeatures/Core.Wpf/Structure/VisualStudio14StructureTaggerProvider.cs index b0c609af76c5deb8cbf91ebeba3e15b17ddf91e3..92e70c0428cd709acb5fdb9634a090d7c9fac5ef 100644 --- a/src/EditorFeatures/Core.Wpf/Structure/VisualStudio14StructureTaggerProvider.cs +++ b/src/EditorFeatures/Core.Wpf/Structure/VisualStudio14StructureTaggerProvider.cs @@ -2,9 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.ComponentModel.Composition; -using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; +using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Structure; using Microsoft.VisualStudio.Text; @@ -28,11 +29,11 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.Structure [Export(typeof(VisualStudio14StructureTaggerProvider))] [TagType(typeof(IOutliningRegionTag))] [ContentType(ContentTypeNames.RoslynContentType)] - internal partial class VisualStudio14StructureTaggerProvider : + internal class VisualStudio14StructureTaggerProvider : AbstractStructureTaggerProvider { [ImportingConstructor] - [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] + [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public VisualStudio14StructureTaggerProvider( IThreadingContext threadingContext, IForegroundNotificationService notificationService, diff --git a/src/EditorFeatures/Test/Structure/StructureTaggerTests.cs b/src/EditorFeatures/Test/Structure/StructureTaggerTests.cs index 3419d26d1c7e53b10763703447e4e8352fe260af..502d76a5373a9239af998fdc5ebc7ff17b2bb941 100644 --- a/src/EditorFeatures/Test/Structure/StructureTaggerTests.cs +++ b/src/EditorFeatures/Test/Structure/StructureTaggerTests.cs @@ -9,11 +9,8 @@ using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Editor.Tagging; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; -using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Projection; using Microsoft.VisualStudio.Text.Tagging; using Roslyn.Test.Utilities; using Roslyn.Utilities; @@ -42,7 +39,7 @@ static void Main(string[] args) #endregion }"; - using var workspace = TestWorkspace.CreateCSharp(code); + using var workspace = TestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf); workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(workspace.Options .WithChangedOption(BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp, true))); @@ -84,7 +81,7 @@ static void Main(string[] args) #endregion }"; - using var workspace = TestWorkspace.CreateCSharp(code); + using var workspace = TestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeaturesWpf); var tags = await GetTagsFromWorkspaceAsync(workspace); // ensure all 4 outlining region tags were found @@ -119,7 +116,7 @@ End Module #End Region End Namespace"; - using var workspace = TestWorkspace.CreateVisualBasic(code); + using var workspace = TestWorkspace.CreateVisualBasic(code, composition: EditorTestCompositions.EditorFeaturesWpf); var tags = await GetTagsFromWorkspaceAsync(workspace); // ensure all 4 outlining region tags were found @@ -148,7 +145,7 @@ Sub Main(args As String()) End Sub End Module"; - using var workspace = TestWorkspace.CreateVisualBasic(code); + using var workspace = TestWorkspace.CreateVisualBasic(code, composition: EditorTestCompositions.EditorFeaturesWpf); var tags = await GetTagsFromWorkspaceAsync(workspace); var hints = tags.Select(x => x.CollapsedHintForm).Cast().ToArray(); @@ -160,15 +157,8 @@ private static async Task> GetTagsFromWorkspaceAsync(T { var hostdoc = workspace.Documents.First(); var view = hostdoc.GetTextView(); - var textService = workspace.GetService(); - var editorService = workspace.GetService(); - var projectionService = workspace.GetService(); - - var provider = new VisualStudio14StructureTaggerProvider( - workspace.ExportProvider.GetExportedValue(), - workspace.ExportProvider.GetExportedValue(), - textService, editorService, projectionService, - AsynchronousOperationListenerProvider.NullProvider); + + var provider = workspace.ExportProvider.GetExportedValue(); var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); var context = new TaggerContext(document, view.TextSnapshot); diff --git a/src/EditorFeatures/Test/Tagging/AsynchronousTaggerTests.cs b/src/EditorFeatures/Test/Tagging/AsynchronousTaggerTests.cs index 3e0c73b001b4a12abb1aeeb340cc15a97e8c23c0..25587652ee5f513cd255337953e29586e3cf88e1 100644 --- a/src/EditorFeatures/Test/Tagging/AsynchronousTaggerTests.cs +++ b/src/EditorFeatures/Test/Tagging/AsynchronousTaggerTests.cs @@ -11,13 +11,13 @@ using Microsoft.CodeAnalysis.Editor.Shared.Tagging; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.CodeAnalysis.Editor.Tagging; +using Microsoft.CodeAnalysis.Editor.UnitTests; using Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text.Shared.Extensions; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; -using Microsoft.VisualStudio.Text.Projection; using Microsoft.VisualStudio.Text.Tagging; using Roslyn.Test.Utilities; using Roslyn.Utilities; @@ -93,16 +93,10 @@ static List> tagProducer(SnapshotSpan span, CancellationToken [WpfFact] public void TestSynchronousOutlining() { - using var workspace = TestWorkspace.CreateCSharp("class Program {\r\n\r\n}"); + using var workspace = TestWorkspace.CreateCSharp("class Program {\r\n\r\n}", composition: EditorTestCompositions.EditorFeaturesWpf); WpfTestRunner.RequireWpfFact($"{nameof(AsynchronousTaggerTests)}.{nameof(TestSynchronousOutlining)} creates asynchronous taggers"); - var tagProvider = new VisualStudio14StructureTaggerProvider( - workspace.ExportProvider.GetExportedValue(), - workspace.GetService(), - workspace.GetService(), - workspace.GetService(), - workspace.GetService(), - workspace.ExportProvider.GetExportedValue()); + var tagProvider = workspace.ExportProvider.GetExportedValue(); var document = workspace.Documents.First(); var textBuffer = document.GetTextBuffer();