Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
114 changes: 0 additions & 114 deletions .github/skills/run-vscode-local-testing/SKILL.md

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ internal sealed class LanguageServerTestComposition
SessionId: null,
ExtensionAssemblyPaths: extensionPaths ?? [],
DevKitDependencyPath: devKitDependencyPath,
RazorDesignTimePath: null,
CSharpDesignTimePath: null,
ExtensionLogDirectory: string.Empty,
ServerPipeName: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace;

internal abstract class LanguageServerProjectLoader
{
private static readonly string s_razorDesignTimePath = Path.Combine(AppContext.BaseDirectory, "Targets", "Microsoft.NET.Sdk.Razor.DesignTime.targets");

private readonly AsyncBatchingWorkQueue<ProjectToLoad> _projectsToReload;

protected readonly LanguageServerWorkspaceFactory _workspaceFactory;
Expand Down Expand Up @@ -126,10 +128,7 @@ private static ImmutableDictionary<string, string> BuildAdditionalProperties(Ser
return properties;
}

if (serverConfiguration.RazorDesignTimePath is { } razorDesignTimePath)
{
properties = properties.Add("RazorDesignTimeTargets", razorDesignTimePath);
}
properties = properties.Add("RazorDesignTimeTargets", s_razorDesignTimePath);

if (serverConfiguration.CSharpDesignTimePath is { } csharpDesignTimePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.Collections.Frozen;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.LanguageServer.Logging;
using Microsoft.CodeAnalysis.LanguageServer.Services;
Expand All @@ -19,6 +20,17 @@ internal sealed class LanguageServerExportProviderBuilder : ExportProviderBuilde
// For testing purposes, track the last cache write task.
private static Task? s_cacheWriteTask_forTestingPurposesOnly;

private static readonly FrozenSet<string> s_dllsToExcludeFromMef =
[
// These DLLs are part of Razor, but should only be in their MEF composition not ours
"Microsoft.CodeAnalysis.Razor.Workspaces.dll",
"Microsoft.CodeAnalysis.Remote.Razor.dll",

// This is a runtime dependency of Remote.Razor, but its host-layer exports belong to the remote host
// composition and conflict with the language server's workspace services if included here.
"Microsoft.CodeAnalysis.Remote.ServiceHub.dll",
];

private LanguageServerExportProviderBuilder(
ImmutableArray<string> assemblyPaths,
Resolver resolver,
Expand All @@ -39,13 +51,16 @@ public static async Task<ExportProvider> CreateExportProviderAsync(
ILoggerFactory loggerFactory,
CancellationToken cancellationToken)
{
// Load any Roslyn assemblies from the extension directory
// Load Roslyn assemblies from the language server directory.
using var _ = ArrayBuilder<string>.GetInstance(out var assemblyPathsBuilder);

// Don't catch IO exceptions as it's better to fail to build the catalog than give back
// a partial catalog that will surely blow up later.
assemblyPathsBuilder.AddRange(Directory.EnumerateFiles(baseDirectory, "Microsoft.CodeAnalysis*.dll"));
assemblyPathsBuilder.AddRange(Directory.EnumerateFiles(baseDirectory, "Microsoft.ServiceHub*.dll"));
assemblyPathsBuilder.AddRange(FilterFiles(baseDirectory, "Microsoft.CodeAnalysis*.dll"));
assemblyPathsBuilder.AddRange(FilterFiles(baseDirectory, "Microsoft.ServiceHub*.dll"));
Comment on lines +59 to +60
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder at what point it's just easier to list the files than keep adding fancier logic here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the wildcards because it makes it easier to handle adding new project references - don't have to remember to also go and add them to this list.


// The Razor extension ships with Roslyn and so needs to be in our MEF composition
assemblyPathsBuilder.Add(Path.Combine(baseDirectory, "Microsoft.VisualStudioCode.RazorExtension.dll"));

// DevKit assemblies are not shipped in the main language server folder
// and not included in ExtensionAssemblyPaths (they get loaded into the default ALC).
Expand Down Expand Up @@ -74,6 +89,15 @@ public static async Task<ExportProvider> CreateExportProviderAsync(
return exportProvider;
}

private static IEnumerable<string> FilterFiles(string baseDirectory, string filter)
{
foreach (var file in Directory.EnumerateFiles(baseDirectory, filter))
{
if (!s_dllsToExcludeFromMef.Contains(Path.GetFileName(file)))
Comment thread
davidwengier marked this conversation as resolved.
yield return file;
}
}

protected override void LogError(string message, Exception exception)
=> _logger.LogError(exception, message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
<ProjectReference Include="..\ExternalAccess\CompilerDeveloperSDK\Microsoft.CodeAnalysis.ExternalAccess.CompilerDeveloperSDK.csproj" />
<ProjectReference Include="..\ExternalAccess\Copilot\Microsoft.CodeAnalysis.LanguageServer.ExternalAccess.Copilot.csproj" />
<ProjectReference Include="..\..\Tools\ExternalAccess\Razor\Features\Microsoft.CodeAnalysis.ExternalAccess.Razor.Features.csproj" />
<!-- Ship the VS Code Razor entrypoint as a real runtime dependency so it participates in the server deps.json. -->
<ProjectReference Include="..\..\Razor\src\Razor\src\Microsoft.VisualStudioCode.RazorExtension\Microsoft.VisualStudioCode.RazorExtension.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading