diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj b/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj
index a5245bc423e75..24c9011fc8164 100644
--- a/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj
+++ b/src/EditorFeatures/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.EditorFeatures.DiagnosticsTests.Utilities.csproj
@@ -11,28 +11,10 @@
true
-
-
-
-
-
-
-
-
-
-
- global,WORKSPACES
-
-
-
-
-
-
-
-
+
diff --git a/src/EditorFeatures/Test2/GoToBase/GoToBaseTestsBase.vb b/src/EditorFeatures/Test2/GoToBase/GoToBaseTestsBase.vb
index e9ac8f39f49cb..f56c97eef26e0 100644
--- a/src/EditorFeatures/Test2/GoToBase/GoToBaseTestsBase.vb
+++ b/src/EditorFeatures/Test2/GoToBase/GoToBaseTestsBase.vb
@@ -17,7 +17,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.GoToBase
testHost:=TestHost.InProcess,
Async Function(document As Document, position As Integer, context As SimpleFindUsagesContext)
Dim gotoBaseService = document.GetLanguageService(Of IGoToBaseService)
- Dim options = New TestOptionsProvider(Of ClassificationOptions)(ClassificationOptions.Default)
+ Dim options = TestOptionsProvider.Create(ClassificationOptions.Default)
Await gotoBaseService.FindBasesAsync(context, document, position, options, CancellationToken.None)
End Function,
shouldSucceed, metadataDefinitions)
diff --git a/src/EditorFeatures/Test2/GoToImplementation/GoToImplementationTests.vb b/src/EditorFeatures/Test2/GoToImplementation/GoToImplementationTests.vb
index 3532f2aee9852..f5a4c12e1361d 100644
--- a/src/EditorFeatures/Test2/GoToImplementation/GoToImplementationTests.vb
+++ b/src/EditorFeatures/Test2/GoToImplementation/GoToImplementationTests.vb
@@ -17,7 +17,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.GoToImplementation
host,
Async Function(document As Document, position As Integer, context As SimpleFindUsagesContext) As Task
Dim findUsagesService = document.GetLanguageService(Of IFindUsagesService)
- Dim options = New TestOptionsProvider(Of ClassificationOptions)(ClassificationOptions.Default)
+ Dim options = TestOptionsProvider.Create(ClassificationOptions.Default)
Await findUsagesService.FindImplementationsAsync(context, document, position, options, CancellationToken.None).ConfigureAwait(False)
End Function,
shouldSucceed,
diff --git a/src/Features/TestUtilities/EditAndContinue/MockHotReloadLogger.cs b/src/EditorFeatures/TestUtilities/EditAndContinue/MockHotReloadLogger.cs
similarity index 100%
rename from src/Features/TestUtilities/EditAndContinue/MockHotReloadLogger.cs
rename to src/EditorFeatures/TestUtilities/EditAndContinue/MockHotReloadLogger.cs
diff --git a/src/Features/TestUtilities/EditAndContinue/MockManagedHotReloadService.cs b/src/EditorFeatures/TestUtilities/EditAndContinue/MockManagedHotReloadService.cs
similarity index 100%
rename from src/Features/TestUtilities/EditAndContinue/MockManagedHotReloadService.cs
rename to src/EditorFeatures/TestUtilities/EditAndContinue/MockManagedHotReloadService.cs
diff --git a/src/Workspaces/CoreTestUtilities/Fakes/StubStreamingFindUsagesPresenter.cs b/src/EditorFeatures/TestUtilities/FindUsages/StubStreamingFindUsagesPresenter.cs
similarity index 100%
rename from src/Workspaces/CoreTestUtilities/Fakes/StubStreamingFindUsagesPresenter.cs
rename to src/EditorFeatures/TestUtilities/FindUsages/StubStreamingFindUsagesPresenter.cs
diff --git a/src/Workspaces/CoreTest/Options/OptionSerializerTests.cs b/src/EditorFeatures/TestUtilities/Options/OptionSerializerTests.cs
similarity index 100%
rename from src/Workspaces/CoreTest/Options/OptionSerializerTests.cs
rename to src/EditorFeatures/TestUtilities/Options/OptionSerializerTests.cs
diff --git a/src/EditorFeatures/TestUtilities/Workspaces/EditorTestWorkspace.cs b/src/EditorFeatures/TestUtilities/Workspaces/EditorTestWorkspace.cs
index e45633a941cff..bda79f12eade7 100644
--- a/src/EditorFeatures/TestUtilities/Workspaces/EditorTestWorkspace.cs
+++ b/src/EditorFeatures/TestUtilities/Workspaces/EditorTestWorkspace.cs
@@ -7,7 +7,9 @@
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
+using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host;
@@ -193,6 +195,27 @@ public void OpenSourceGeneratedDocument(DocumentId documentId)
testDocument.GetOpenTextContainer();
}
+ public TServiceInterface GetService(string contentType)
+ {
+ var values = ExportProvider.GetExports();
+ return values.Single(value => value.Metadata.ContentTypes.Contains(contentType)).Value;
+ }
+
+ public TServiceInterface GetService(string contentType, string name)
+ {
+ var values = ExportProvider.GetExports();
+ return values.Single(value => value.Metadata.Name == name && value.Metadata.ContentTypes.Contains(contentType)).Value;
+ }
+
+ internal override bool CanAddProjectReference(ProjectId referencingProject, ProjectId referencedProject)
+ {
+ // VisualStudioWorkspace asserts the main thread for this call, so do the same thing here to catch tests
+ // that fail to account for this possibility.
+ var threadingContext = ExportProvider.GetExportedValue();
+ Contract.ThrowIfFalse(threadingContext.HasMainThread && threadingContext.JoinableTaskContext.IsOnMainThread);
+ return true;
+ }
+
///
/// Creates a TestHostDocument backed by a projection buffer. The surface buffer is
/// described by a markup string with {|name:|} style pointers to annotated spans that can
diff --git a/src/Features/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.Features.DiagnosticsTests.Utilities.csproj b/src/Features/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.Features.DiagnosticsTests.Utilities.csproj
index 7562820dd9d50..3cc2dec805a9e 100644
--- a/src/Features/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.Features.DiagnosticsTests.Utilities.csproj
+++ b/src/Features/DiagnosticsTestUtilities/Microsoft.CodeAnalysis.Features.DiagnosticsTests.Utilities.csproj
@@ -12,6 +12,7 @@
+
diff --git a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs
index 8795dc2a44e8c..02c4a38bb6666 100644
--- a/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs
+++ b/src/Features/Test/FindUsages/DefinitionItemFactoryTests.cs
@@ -132,7 +132,7 @@ public async Task ToClassifiedDefinitionItemAsync_Assembly_Source()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var a = compilation.Assembly;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(a, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -168,7 +168,7 @@ public async Task ToClassifiedDefinitionItemAsync_Assembly_Metadata()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var m = compilation.GetReferencedAssemblySymbols().Single(a => a.Name == "mscorlib");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(m, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -210,7 +210,7 @@ public async Task ToClassifiedDefinitionItemAsync_Module_Source()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var m = compilation.Assembly.Modules.Single();
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(m, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -246,7 +246,7 @@ public async Task ToClassifiedDefinitionItemAsync_Module_Metadata()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var m = compilation.GetReferencedAssemblySymbols().Single(a => a.Name == "mscorlib").Modules.Single();
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(m, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -288,7 +288,7 @@ public async Task ToClassifiedDefinitionItemAsync_Namespace_Source()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var symbol = compilation.GetMember("N");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(symbol, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -330,7 +330,7 @@ public async Task ToClassifiedDefinitionItemAsync_Namespace_Metadata()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var n = compilation.GetMember("System");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(n, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -383,7 +383,7 @@ namespace System { class D {} }
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var n = compilation.GetMember("System");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(n, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -437,7 +437,7 @@ public async Task ToClassifiedDefinitionItemAsync_Namespace_Global_Source()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var symbol = compilation.Assembly.GlobalNamespace;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(symbol, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -477,7 +477,7 @@ public async Task ToClassifiedDefinitionItemAsync_Namespace_Global_SourceAndMeta
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var symbol = compilation.GlobalNamespace;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(symbol, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -517,7 +517,7 @@ public async Task ToClassifiedDefinitionItemAsync_Class()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var c = compilation.GetMember("C");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(c, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -559,7 +559,7 @@ public async Task ToClassifiedDefinitionItemAsync_Class_Metadata()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var c = compilation.GetMember("System.Activator");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(c, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -617,7 +617,7 @@ End Class
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var c = compilation.GetMember("C");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(c, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -663,7 +663,7 @@ public async Task ToClassifiedDefinitionItemAsync_Dynamic()
var compilation = await project.GetCompilationAsync();
Contract.ThrowIfNull(compilation);
var c = compilation.GetMember("C.F").Type;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(c, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -703,7 +703,7 @@ public async Task ToClassifiedDefinitionItemAsync_TupleSyntax()
var t1 = tuple.TypeParameters[0];
var t2 = tuple.TypeParameters[1];
var genericTuple = tuple.OriginalDefinition;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(tuple, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -765,7 +765,7 @@ public async Task ToClassifiedDefinitionItemAsync_ValueTuple()
var t1 = tuple.TypeParameters[0];
var t2 = tuple.TypeParameters[1];
var genericTuple = tuple.OriginalDefinition;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(tuple, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -821,7 +821,7 @@ public async Task ToClassifiedDefinitionItemAsync_GenericInstatiation_Source()
var t1 = type.TypeParameters[0];
var t2 = type.TypeParameters[1];
var genericType = type.OriginalDefinition;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(type, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -875,7 +875,7 @@ class C { Dictionary F; }
var t1 = type.TypeParameters[0];
var t2 = type.TypeParameters[1];
var genericType = type.OriginalDefinition;
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(type, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -936,7 +936,7 @@ public async Task ToClassifiedDefinitionItemAsync_TypeTypeParameter()
var c = compilation.GetMember("C");
var p = c.GetTypeParameters().Single();
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(p, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -979,7 +979,7 @@ public async Task ToClassifiedDefinitionItemAsync_Method()
var m = compilation.GetMember("C.M");
var c = m.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(m, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1034,7 +1034,7 @@ public async Task ToClassifiedDefinitionItemAsync_Field()
var m = compilation.GetMember("C.M");
var c = m.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(m, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1086,7 +1086,7 @@ public async Task ToClassifiedDefinitionItemAsync_Property()
var p = compilation.GetMember("C.P");
var c = p.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(p, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1150,7 +1150,7 @@ public async Task ToClassifiedDefinitionItemAsync_Property_Getter()
Contract.ThrowIfNull(g);
var c = p.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(g, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1207,7 +1207,7 @@ public async Task ToClassifiedDefinitionItemAsync_Property_Setter()
Contract.ThrowIfNull(g);
var c = p.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(g, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1262,7 +1262,7 @@ public async Task ToClassifiedDefinitionItemAsync_Indexer()
var p = compilation.GetMember("C.this[]");
var c = p.ContainingType;
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(p, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1343,7 +1343,7 @@ void M(int p) { }
var p = m.GetParameters().Single();
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(p, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1402,7 +1402,7 @@ void M() { }
var c = m.ContainingType;
var p = m.GetTypeParameters().Single();
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(p, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1454,7 +1454,7 @@ public async Task ToClassifiedDefinitionItemAsync_LocalFunction()
var c = compilation.GetMember("C");
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(f, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1521,7 +1521,7 @@ class C
var c = compilation.GetMember("C");
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(x, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
@@ -1592,7 +1592,7 @@ class C
var c = compilation.GetMember("C");
var i = compilation.GetSpecialType(SpecialType.System_Int32);
- var classificationOptions = workspace.GlobalOptions.GetClassificationOptionsProvider();
+ var classificationOptions = TestOptionsProvider.Create(ClassificationOptions.Default);
var searchOptions = FindReferencesSearchOptions.Default;
var item = await DefinitionItemFactory.ToClassifiedDefinitionItemAsync(r, classificationOptions, solution, searchOptions, isPrimary: true, includeHiddenLocations: true, CancellationToken.None);
diff --git a/src/Features/TestUtilities/Options/TestOptionsProvider.cs b/src/Features/TestUtilities/Options/TestOptionsProvider.cs
index 4f50cc6f65bf8..711c0dfe0e4e3 100644
--- a/src/Features/TestUtilities/Options/TestOptionsProvider.cs
+++ b/src/Features/TestUtilities/Options/TestOptionsProvider.cs
@@ -9,8 +9,14 @@
namespace Microsoft.CodeAnalysis.Test.Utilities;
-internal class TestOptionsProvider(TOptions options) : OptionsProvider
+internal static class TestOptionsProvider
{
- public ValueTask GetOptionsAsync(LanguageServices languageServices, CancellationToken cancellationToken)
- => ValueTaskFactory.FromResult(options);
+ internal class Provider(TOptions options) : OptionsProvider
+ {
+ public ValueTask GetOptionsAsync(LanguageServices languageServices, CancellationToken cancellationToken)
+ => ValueTaskFactory.FromResult(options);
+ }
+
+ public static OptionsProvider Create(TOptions options)
+ => new Provider(options);
}
diff --git a/src/Features/TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs b/src/LanguageServer/Protocol.TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
similarity index 100%
rename from src/Features/TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
rename to src/LanguageServer/Protocol.TestUtilities/Diagnostics/DiagnosticProviderTestUtilities.cs
diff --git a/src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs b/src/LanguageServer/Protocol.TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
similarity index 100%
rename from src/Features/TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
rename to src/LanguageServer/Protocol.TestUtilities/Diagnostics/TestDiagnosticAnalyzerDriver.cs
diff --git a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs
index ca70a51b6606c..24126d40f789c 100644
--- a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs
+++ b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs
@@ -991,12 +991,12 @@ public Assembly LoadFromPath(string fullPath)
}
[PartNotDiscoverable]
- [ExportWorkspaceService(typeof(IWorkspaceConfigurationService), ServiceLayer.Test), System.Composition.Shared]
+ [ExportWorkspaceService(typeof(IWorkspaceConfigurationService), ServiceLayer.Test), Shared]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- private sealed class TestWorkspaceConfigurationService(IGlobalOptionService globalOptionService) : IWorkspaceConfigurationService
+ private sealed class TestWorkspaceConfigurationService() : IWorkspaceConfigurationService
{
- public WorkspaceConfigurationOptions Options => globalOptionService.GetWorkspaceConfigurationOptions();
+ public WorkspaceConfigurationOptions Options { get; set; } = WorkspaceConfigurationOptions.Default;
}
[Theory, CombinatorialData]
@@ -1009,11 +1009,11 @@ internal async Task UpdatingAnalyzerReferenceReloadsGenerators(
const string AnalyzerResourceV2 = @"Microsoft.CodeAnalysis.UnitTests.Resources.Microsoft.CodeAnalysis.TestAnalyzerReference.dll.v2";
using var workspace = CreateWorkspace([typeof(TestWorkspaceConfigurationService)], TestHost.OutOfProcess);
+ var mefServices = (VisualStudioMefHostServices)workspace.Services.HostServices;
// Ensure the local and remote sides agree on how we're executing source generators.
- var mefServices = (VisualStudioMefHostServices)workspace.Services.HostServices;
- var globalOptionService = mefServices.GetExportedValue();
- globalOptionService.SetGlobalOption(WorkspaceConfigurationOptionsStorage.SourceGeneratorExecution, executionPreference);
+ var configService = (TestWorkspaceConfigurationService)workspace.Services.GetRequiredService();
+ configService.Options = configService.Options with { SourceGeneratorExecution = executionPreference };
using var client = await InProcRemoteHostClient.GetTestClientAsync(workspace).ConfigureAwait(false);
diff --git a/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs b/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs
index 25b4339f818e5..06aeba1c25acc 100644
--- a/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs
+++ b/src/Workspaces/CoreTest/UtilityTest/IntervalTreeTests.cs
@@ -6,10 +6,8 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
-using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.VisualStudio.Text;
using Roslyn.Test.Utilities;
using Xunit;
@@ -318,19 +316,19 @@ private void TestOverlapsAndIntersects(IList> spans)
{
for (var length = 1; length <= max; length++)
{
- var span = new Span(start, length);
+ var span = new TextSpan(start, length);
var set1 = new HashSet(GetIntervalsThatOverlapWith(tree, start, length).Select(i => i.Item3));
var set2 = new HashSet(spans.Where(t =>
{
- return span.OverlapsWith(new Span(t.Item1, t.Item2));
+ return span.OverlapsWith(new TextSpan(t.Item1, t.Item2));
}).Select(t => t.Item3));
Assert.True(set1.SetEquals(set2));
var set3 = new HashSet(GetIntervalsThatIntersectWith(tree, start, length).Select(i => i.Item3));
var set4 = new HashSet(spans.Where(t =>
{
- return span.IntersectsWith(new Span(t.Item1, t.Item2));
+ return span.IntersectsWith(new TextSpan(t.Item1, t.Item2));
}).Select(t => t.Item3));
Assert.True(set3.SetEquals(set4));
}
diff --git a/src/Workspaces/CoreTestUtilities/TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs b/src/Workspaces/CoreTestUtilities/TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs
index f80f699610c17..3b6e7ad8ab153 100644
--- a/src/Workspaces/CoreTestUtilities/TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs
+++ b/src/Workspaces/CoreTestUtilities/TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs
@@ -6,7 +6,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Threading;
-using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Test.Utilities
@@ -143,7 +142,7 @@ public override SynchronizationContext CreateCopy()
[MethodImpl(MethodImplOptions.NoInlining)]
private static void ThrowFailedTransferExceptionForCapture()
- => throw new InvalidOperationException($"Code cannot switch to the main thread without configuring the {nameof(IThreadingContext)}.");
+ => throw new InvalidOperationException($"Code cannot switch to the main thread without configuring IThreadingContext.");
}
}
}
diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs
index 82294e820a565..9c2ee72d4da07 100644
--- a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs
+++ b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs
@@ -14,17 +14,13 @@
using System.Xml.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Editor;
-using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Editor.UnitTests.Extensions;
using Microsoft.CodeAnalysis.Host;
-using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.Notification;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Serialization;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.CodeAnalysis.UnitTests;
using Microsoft.VisualStudio.Composition;
using Roslyn.Test.Utilities;
@@ -34,7 +30,7 @@
namespace Microsoft.CodeAnalysis.Test.Utilities
{
- public abstract partial class TestWorkspace : Workspace, ILspWorkspace
+ public abstract partial class TestWorkspace : Workspace
where TDocument : TestHostDocument
where TProject : TestHostProject
where TSolution : TestHostSolution
@@ -334,18 +330,6 @@ public void OnDocumentRemoved(DocumentId documentId, bool closeDocument = false)
public TServiceInterface GetService()
=> ExportProvider.GetExportedValue();
- public TServiceInterface GetService(string contentType)
- {
- var values = ExportProvider.GetExports();
- return values.Single(value => value.Metadata.ContentTypes.Contains(contentType)).Value;
- }
-
- public TServiceInterface GetService(string contentType, string name)
- {
- var values = ExportProvider.GetExports();
- return values.Single(value => value.Metadata.Name == name && value.Metadata.ContentTypes.Contains(contentType)).Value;
- }
-
public override bool CanApplyChange(ApplyChangesKind feature)
{
switch (feature)
@@ -593,13 +577,7 @@ public override bool CanApplyParseOptionChange(ParseOptions oldOptions, ParseOpt
=> true;
internal override bool CanAddProjectReference(ProjectId referencingProject, ProjectId referencedProject)
- {
- // VisualStudioWorkspace asserts the main thread for this call, so do the same thing here to catch tests
- // that fail to account for this possibility.
- var threadingContext = ExportProvider.GetExportedValue();
- Contract.ThrowIfFalse(threadingContext.HasMainThread && threadingContext.JoinableTaskContext.IsOnMainThread);
- return true;
- }
+ => true;
internal void InitializeDocuments(
string language,