Skip to content

Commit 4bf5adc

Browse files
committed
Pass UseRoslynTokenizer setting to the LSP server
1 parent b894c3e commit 4bf5adc

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"defaults": {
4040
"roslyn": "4.13.0-2.24531.3",
4141
"omniSharp": "1.39.11",
42-
"razor": "9.0.0-preview.24531.4",
42+
"razor": "9.0.0-preview.24555.12",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.13.35506.24"
4545
},
@@ -1528,6 +1528,13 @@
15281528
"description": "%configuration.razor.languageServer.forceRuntimeCodeGeneration%",
15291529
"order": 90
15301530
},
1531+
"razor.languageServer.useRoslynTokenizer": {
1532+
"type": "boolean",
1533+
"scope": "machine-overridable",
1534+
"default": false,
1535+
"markdownDescription": "%configuration.razor.languageServer.useRoslynTokenizer%",
1536+
"order": 90
1537+
},
15311538
"razor.languageServer.suppressLspErrorToasts": {
15321539
"type": "boolean",
15331540
"default": true,

package.nls.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@
127127
"configuration.razor.languageServer.debug": "Specifies whether to wait for debug attach when launching the language server.",
128128
"configuration.razor.server.trace": "Specifies the logging level to use for the Razor server.",
129129
"configuration.razor.languageServer.forceRuntimeCodeGeneration": "(EXPERIMENTAL) Enable combined design time/runtime code generation for Razor files",
130+
"configuration.razor.languageServer.useRoslynTokenizer": {
131+
"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 `<features>use-roslyn-tokenizer</feature>` in a `.csproj` file for command line builds, and may result in inconsistencies if this option and your project files do not match.",
132+
"comment": [
133+
"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."
134+
]
135+
},
130136
"configuration.razor.languageServer.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
131137
"debuggers.coreclr.configurationSnippets.label.console-local": ".NET: Launch Executable file (Console)",
132138
"debuggers.coreclr.configurationSnippets.label.web-local": ".NET: Launch Executable file (Web)",

src/razor/src/razorLanguageServerClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ export class RazorLanguageServerClient implements vscode.Disposable {
271271
args.push('true');
272272
}
273273

274+
if (options.useRoslynTokenizer) {
275+
args.push('--UseRoslynTokenizer');
276+
args.push('true');
277+
}
278+
274279
if (this.telemetryExtensionDllPath.length > 0) {
275280
args.push('--telemetryLevel', this.vscodeTelemetryReporter.telemetryLevel);
276281
args.push('--sessionId', getSessionId());

src/razor/src/razorLanguageServerOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export interface RazorLanguageServerOptions {
1313
logLevel: LogLevel;
1414
usingOmniSharp: boolean;
1515
forceRuntimeCodeGeneration: boolean;
16+
useRoslynTokenizer: boolean;
1617
suppressErrorToasts: boolean;
1718
}

src/razor/src/razorLanguageServerOptionsResolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function resolveRazorLanguageServerOptions(
2525
const usingOmniSharp =
2626
!getCSharpDevKit() && vscodeApi.workspace.getConfiguration().get<boolean>('dotnet.server.useOmnisharp');
2727
const forceRuntimeCodeGeneration = serverConfig.get<boolean>('forceRuntimeCodeGeneration');
28+
const useRoslynTokenizer = serverConfig.get<boolean>('useRoslynTokenizer');
2829
const suppressErrorToasts = serverConfig.get<boolean>('suppressLspErrorToasts');
2930

3031
return {
@@ -34,6 +35,7 @@ export function resolveRazorLanguageServerOptions(
3435
outputChannel: logger.outputChannel,
3536
usingOmniSharp,
3637
forceRuntimeCodeGeneration,
38+
useRoslynTokenizer,
3739
suppressErrorToasts,
3840
} as RazorLanguageServerOptions;
3941
}

0 commit comments

Comments
 (0)