From 4bf5adcfc92c62a7cf657cbf17cd0bde7c91eafa Mon Sep 17 00:00:00 2001 From: David Wengier Date: Fri, 8 Nov 2024 12:43:13 +1100 Subject: [PATCH 1/2] Pass UseRoslynTokenizer setting to the LSP server --- package.json | 9 ++++++++- package.nls.json | 6 ++++++ src/razor/src/razorLanguageServerClient.ts | 5 +++++ src/razor/src/razorLanguageServerOptions.ts | 1 + src/razor/src/razorLanguageServerOptionsResolver.ts | 2 ++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a91567631..1d778b9ec 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "defaults": { "roslyn": "4.13.0-2.24531.3", "omniSharp": "1.39.11", - "razor": "9.0.0-preview.24531.4", + "razor": "9.0.0-preview.24555.12", "razorOmnisharp": "7.0.0-preview.23363.1", "xamlTools": "17.13.35506.24" }, @@ -1528,6 +1528,13 @@ "description": "%configuration.razor.languageServer.forceRuntimeCodeGeneration%", "order": 90 }, + "razor.languageServer.useRoslynTokenizer": { + "type": "boolean", + "scope": "machine-overridable", + "default": false, + "markdownDescription": "%configuration.razor.languageServer.useRoslynTokenizer%", + "order": 90 + }, "razor.languageServer.suppressLspErrorToasts": { "type": "boolean", "default": true, diff --git a/package.nls.json b/package.nls.json index d751ee61c..3c5e66c55 100644 --- a/package.nls.json +++ b/package.nls.json @@ -127,6 +127,12 @@ "configuration.razor.languageServer.debug": "Specifies whether to wait for debug attach when launching the language server.", "configuration.razor.server.trace": "Specifies the logging level to use for the Razor server.", "configuration.razor.languageServer.forceRuntimeCodeGeneration": "(EXPERIMENTAL) Enable combined design time/runtime code generation for Razor files", + "configuration.razor.languageServer.useRoslynTokenizer": { + "message": "(EXPERIMENTAL) Use the C# tokenizer for Razor files in the IDE. Enables some new C# features, like interpolated and raw strings, in Razor files opened in Visual Studio. This matches using `use-roslyn-tokenizer` in a `.csproj` file for command line builds, and may result in inconsistencies if this option and your project files do not match.", + "comment": [ + "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." + ] + }, "configuration.razor.languageServer.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.", "debuggers.coreclr.configurationSnippets.label.console-local": ".NET: Launch Executable file (Console)", "debuggers.coreclr.configurationSnippets.label.web-local": ".NET: Launch Executable file (Web)", diff --git a/src/razor/src/razorLanguageServerClient.ts b/src/razor/src/razorLanguageServerClient.ts index 2408500df..af4295b4c 100644 --- a/src/razor/src/razorLanguageServerClient.ts +++ b/src/razor/src/razorLanguageServerClient.ts @@ -271,6 +271,11 @@ export class RazorLanguageServerClient implements vscode.Disposable { args.push('true'); } + if (options.useRoslynTokenizer) { + args.push('--UseRoslynTokenizer'); + args.push('true'); + } + if (this.telemetryExtensionDllPath.length > 0) { args.push('--telemetryLevel', this.vscodeTelemetryReporter.telemetryLevel); args.push('--sessionId', getSessionId()); diff --git a/src/razor/src/razorLanguageServerOptions.ts b/src/razor/src/razorLanguageServerOptions.ts index 126798f16..0f4df5562 100644 --- a/src/razor/src/razorLanguageServerOptions.ts +++ b/src/razor/src/razorLanguageServerOptions.ts @@ -13,5 +13,6 @@ export interface RazorLanguageServerOptions { logLevel: LogLevel; usingOmniSharp: boolean; forceRuntimeCodeGeneration: boolean; + useRoslynTokenizer: boolean; suppressErrorToasts: boolean; } diff --git a/src/razor/src/razorLanguageServerOptionsResolver.ts b/src/razor/src/razorLanguageServerOptionsResolver.ts index 842f8f71b..4bb395ca5 100644 --- a/src/razor/src/razorLanguageServerOptionsResolver.ts +++ b/src/razor/src/razorLanguageServerOptionsResolver.ts @@ -25,6 +25,7 @@ export function resolveRazorLanguageServerOptions( const usingOmniSharp = !getCSharpDevKit() && vscodeApi.workspace.getConfiguration().get('dotnet.server.useOmnisharp'); const forceRuntimeCodeGeneration = serverConfig.get('forceRuntimeCodeGeneration'); + const useRoslynTokenizer = serverConfig.get('useRoslynTokenizer'); const suppressErrorToasts = serverConfig.get('suppressLspErrorToasts'); return { @@ -34,6 +35,7 @@ export function resolveRazorLanguageServerOptions( outputChannel: logger.outputChannel, usingOmniSharp, forceRuntimeCodeGeneration, + useRoslynTokenizer, suppressErrorToasts, } as RazorLanguageServerOptions; } From b3310ed5b598418df1c586a185e0ea359d1446d9 Mon Sep 17 00:00:00 2001 From: David Wengier Date: Tue, 12 Nov 2024 08:29:54 +1100 Subject: [PATCH 2/2] Update package.nls.json --- package.nls.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.nls.json b/package.nls.json index 3c5e66c55..90f51a167 100644 --- a/package.nls.json +++ b/package.nls.json @@ -128,7 +128,7 @@ "configuration.razor.server.trace": "Specifies the logging level to use for the Razor server.", "configuration.razor.languageServer.forceRuntimeCodeGeneration": "(EXPERIMENTAL) Enable combined design time/runtime code generation for Razor files", "configuration.razor.languageServer.useRoslynTokenizer": { - "message": "(EXPERIMENTAL) Use the C# tokenizer for Razor files in the IDE. Enables some new C# features, like interpolated and raw strings, in Razor files opened in Visual Studio. This matches using `use-roslyn-tokenizer` in a `.csproj` file for command line builds, and may result in inconsistencies if this option and your project files do not match.", + "message": "(EXPERIMENTAL) Use the C# tokenizer for Razor files in the IDE. Enables some new C# features, like interpolated and raw strings, in Razor files opened in Visual Studio Code. This matches using `use-roslyn-tokenizer` in a `.csproj` file for command line builds, and may result in inconsistencies if this option and your project files do not match.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ]