Skip to content

Commit d9be266

Browse files
committed
Fix MEF composition in test
1 parent 3aed1aa commit d9be266

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostEndpointTest.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.AspNetCore.Razor.Test.Common.Mef;
1313
using Microsoft.CodeAnalysis;
1414
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
15+
using Microsoft.CodeAnalysis.Razor.Cohost;
1516
using Microsoft.CodeAnalysis.Razor.Workspaces;
1617
using Microsoft.VisualStudio.LanguageServer.Client;
1718
using Microsoft.VisualStudio.LanguageServer.ContainedLanguage;
@@ -58,7 +59,9 @@ public void RegistrationsProvideFilter()
5859
.AddExcludedPartTypes(typeof(IWorkspaceProvider))
5960
.AddParts(typeof(TestWorkspaceProvider))
6061
.AddExcludedPartTypes(typeof(ILspEditorFeatureDetector))
61-
.AddParts(typeof(TestLspEditorFeatureDetector));
62+
.AddParts(typeof(TestLspEditorFeatureDetector))
63+
.AddExcludedPartTypes(typeof(IIncompatibleProjectService))
64+
.AddParts(typeof(TestIncompatibleProjectService));
6265

6366
using var exportProvider = testComposition.ExportProviderFactory.CreateExportProvider();
6467

@@ -120,7 +123,7 @@ public void RegistrationsProvideFilter()
120123
}
121124
}
122125

123-
[Export(typeof(ILanguageServiceBroker2))]
126+
[Export(typeof(ILanguageServiceBroker2)), PartNotDiscoverable]
124127
private class TestILanguageServiceBroker2 : ILanguageServiceBroker2
125128
{
126129
public IEnumerable<ILanguageClientInstance> ActiveLanguageClients => throw new NotImplementedException();
@@ -154,13 +157,13 @@ public event AsyncEventHandler<LanguageClientNotifyEventArgs> ClientNotifyAsync
154157
public Task<IEnumerable<(ILanguageClient, TOut)>> RequestMultipleAsync<TIn, TOut>(string[] contentTypes, Func<VSLSP.ServerCapabilities, bool> capabilitiesFilter, VSLSP.LspRequest<TIn, TOut> method, TIn parameters, CancellationToken cancellationToken) => throw new NotImplementedException();
155158
}
156159

157-
[Export(typeof(IWorkspaceProvider))]
160+
[Export(typeof(IWorkspaceProvider)), PartNotDiscoverable]
158161
private class TestWorkspaceProvider : IWorkspaceProvider
159162
{
160163
public CodeAnalysis.Workspace GetWorkspace() => throw new NotImplementedException();
161164
}
162165

163-
[Export(typeof(ILspEditorFeatureDetector))]
166+
[Export(typeof(ILspEditorFeatureDetector)), PartNotDiscoverable]
164167
private class TestLspEditorFeatureDetector : ILspEditorFeatureDetector
165168
{
166169
public bool IsLiveShareHost() => throw new NotImplementedException();
@@ -170,7 +173,7 @@ private class TestLspEditorFeatureDetector : ILspEditorFeatureDetector
170173
public bool IsRemoteClient() => throw new NotImplementedException();
171174
}
172175

173-
[Export(typeof(IRazorSemanticTokensRefreshQueue))]
176+
[Export(typeof(IRazorSemanticTokensRefreshQueue)), PartNotDiscoverable]
174177
private class TestRazorSemanticTokensRefreshQueue : IRazorSemanticTokensRefreshQueue
175178
{
176179
public void Initialize(string clientCapabilitiesString) => throw new NotImplementedException();

src/Razor/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/TestIncompatibleProjectService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.ComponentModel.Composition;
45
using Microsoft.CodeAnalysis;
56
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Cohost;
67
using Microsoft.CodeAnalysis.Razor.Cohost;
78
using Xunit;
89

910
namespace Microsoft.VisualStudio.Razor.LanguageClient.Cohost;
1011

12+
[Export(typeof(IIncompatibleProjectService)), PartNotDiscoverable]
1113
internal class TestIncompatibleProjectService() : IIncompatibleProjectService
1214
{
1315
public void HandleMiscFilesDocument(TextDocument textDocument)

0 commit comments

Comments
 (0)