Skip to content
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 @@ -25,6 +25,7 @@ internal sealed class LanguageServerTestComposition
ExtensionAssemblyPaths: extensionPaths ?? [],
DevKitDependencyPath: devKitDependencyPath,
RazorDesignTimePath: null,
CSharpDesignTimePath: null,
Copy link
Member

Choose a reason for hiding this comment

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

Should we just be creating a generic mechanism for pushing MSBuild properties rather than adding one each time we need this?

Copy link
Member Author

@davidwengier davidwengier Aug 20, 2025

Choose a reason for hiding this comment

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

That thought definitely crossed my mind. Happy to implement things that way if you and/or @dibarbet prefer, you're the owners. Not sure if thats an abuse/support burden for 3rd party consumers of the language server (or if thats a concern, or if there are any :))

Copy link
Member

Choose a reason for hiding this comment

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

Fine with this particular change. I'd be interested in a better way to pass this information, but I think I'd want it to be structured. I don't really like a general property bag because it isn't as clear what needs to be passed (and in general, you shouldn't need arbitrary msbuild properties).

Copy link
Member

Choose a reason for hiding this comment

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

For example, I could imagine augmenting the initialize request with additional Razor specific information (that you could inject via a middleware). But not convinced that is necessarily better.

Copy link
Member Author

@davidwengier davidwengier Aug 21, 2025

Choose a reason for hiding this comment

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

Going to err on the side of caution and leave this for now. I think initialization is definitely ripe for review, once cohosting graduates and we remove rzls support. At the moment there are still two very different ways of working with Razor in this project which complicates things and makes changes potentially fragile.

ExtensionLogDirectory: string.Empty,
ServerPipeName: null,
UseStdIo: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,8 @@ protected LanguageServerProjectLoader(
_logger = loggerFactory.CreateLogger(nameof(LanguageServerProjectLoader));
_projectLoadTelemetryReporter = projectLoadTelemetry;
_binLogPathProvider = binLogPathProvider;
var razorDesignTimePath = serverConfigurationFactory.ServerConfiguration?.RazorDesignTimePath;

AdditionalProperties = razorDesignTimePath is null
? ImmutableDictionary<string, string>.Empty
: ImmutableDictionary<string, string>.Empty.Add("RazorDesignTimeTargets", razorDesignTimePath);
AdditionalProperties = BuildAdditionalProperties(serverConfigurationFactory.ServerConfiguration);

_projectsToReload = new AsyncBatchingWorkQueue<ProjectToLoad>(
TimeSpan.FromMilliseconds(100),
Expand All @@ -118,6 +115,28 @@ protected LanguageServerProjectLoader(
CancellationToken.None); // TODO: do we need to introduce a shutdown cancellation token for this?
}

private static ImmutableDictionary<string, string> BuildAdditionalProperties(ServerConfiguration? serverConfiguration)
{
var properties = ImmutableDictionary<string, string>.Empty;

if (serverConfiguration is null)
{
return properties;
}

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

if (serverConfiguration.CSharpDesignTimePath is { } csharpDesignTimePath)
{
properties = properties.Add("CSharpDesignTimeTargetsPath", csharpDesignTimePath);
}

return properties;
}

private sealed class ToastErrorReporter
{
private int _displayedToast = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ static RootCommand CreateCommand()
Required = false
};

var csharpDesignTimePathOption = new Option<string?>("--csharpDesignTimePath")
{
Description = "Full path to the C# design time target path (optional).",
Required = false
};

var serverPipeNameOption = new Option<string?>("--pipe")
{
Description = "The name of the pipe the server will connect to.",
Expand All @@ -266,6 +272,7 @@ static RootCommand CreateCommand()
devKitDependencyPathOption,
razorSourceGeneratorOption,
razorDesignTimePathOption,
csharpDesignTimePathOption,
extensionLogDirectoryOption,
serverPipeNameOption,
useStdIoOption
Expand All @@ -281,6 +288,7 @@ static RootCommand CreateCommand()
var extensionAssemblyPaths = parseResult.GetValue(extensionAssemblyPathsOption) ?? [];
var devKitDependencyPath = parseResult.GetValue(devKitDependencyPathOption);
var razorDesignTimePath = parseResult.GetValue(razorDesignTimePathOption);
var csharpDesignTimePath = parseResult.GetValue(csharpDesignTimePathOption);
var extensionLogDirectory = parseResult.GetValue(extensionLogDirectoryOption)!;
var serverPipeName = parseResult.GetValue(serverPipeNameOption);
var useStdIo = parseResult.GetValue(useStdIoOption);
Expand All @@ -294,6 +302,7 @@ static RootCommand CreateCommand()
ExtensionAssemblyPaths: extensionAssemblyPaths,
DevKitDependencyPath: devKitDependencyPath,
RazorDesignTimePath: razorDesignTimePath,
CSharpDesignTimePath: csharpDesignTimePath,
ServerPipeName: serverPipeName,
UseStdIo: useStdIo,
ExtensionLogDirectory: extensionLogDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ internal sealed record class ServerConfiguration(
IEnumerable<string> ExtensionAssemblyPaths,
string? DevKitDependencyPath,
string? RazorDesignTimePath,
string? CSharpDesignTimePath,
string? ServerPipeName,
bool UseStdIo,
string ExtensionLogDirectory);
Expand Down
Loading