Skip to content

Hook up IDocumentServiceProvider in VS Code #78266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System.Composition;
using Microsoft.CodeAnalysis.ExternalAccess.Razor;
using Microsoft.CodeAnalysis.ExternalAccess.Razor.Features;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Host.Mef;
Expand Down Expand Up @@ -47,7 +48,7 @@ internal sealed partial class RazorDynamicFileInfoProvider(Lazy<LanguageServerWo
dynamicInfo.SourceCodeKind,
dynamicInfo.TextLoader,
designTimeOnly: true,
documentServiceProvider: null);
documentServiceProvider: new RazorDocumentServiceProviderWrapper(dynamicInfo.DocumentServiceProvider));
}

public Task OnInitializedAsync(ClientCapabilities clientCapabilities, RequestContext context, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor" Key="$(RazorKey)" />
<InternalsVisibleTo Include="Microsoft.VisualStudio.LanguageServices.Razor.Test" Key="$(RazorKey)" />
<InternalsVisibleTo Include="Microsoft.VisualStudioCode.RazorExtension" Key="$(RazorKey)" />
<InternalsVisibleTo Include="Microsoft.VisualStudioCode.RazorExtension.Test" Key="$(RazorKey)" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor.UnitTests" />
<InternalsVisibleTo Include="Microsoft.CodeAnalysis.ExternalAccess.Razor.EditorFeatures" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal sealed class RazorDocumentServiceProviderWrapper : IDocumentServiceProv
// The lazily initialized service fields use StrongBox<T> to explicitly allow null as an initialized value.
private StrongBox<ISpanMappingService?>? _lazySpanMappingService;
private StrongBox<IDocumentExcerptService?>? _lazyExcerptService;
private StrongBox<DocumentPropertiesService?>? _lazyDocumentPropertiesService;
private StrongBox<IDocumentService?>? _lazyDocumentPropertiesService;

public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDocumentServiceProvider)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public RazorDocumentServiceProviderWrapper(IRazorDocumentServiceProvider innerDo
},
_innerDocumentServiceProvider);

return (TService?)(object?)documentPropertiesService;
return (TService?)documentPropertiesService;
}

return this as TService;
Expand Down
Loading