Skip to content

Commit eb38986

Browse files
authored
Merge pull request #7748 from davidwengier/UseRoslynTokenizerInRazor
Allow opting in to using the Roslyn tokenizer in Razor files
2 parents 2ac68d6 + 0746853 commit eb38986

6 files changed

+25
-2
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

66
# 2.57.x
7+
* Update Razor to 9.0.0-preview.24561.3 (PR: [#7748](https://github.com/dotnet/vscode-csharp/pull/7748))
8+
* Add feature flag to turn on the new Roslyn tokenizer (PR: [#11185](https://github.com/dotnet/razor/pull/11185))
79

810
# 2.56.x
911
* Update Roslyn to 4.13.0-2.24561.3 (PR: [#7765](https://github.com/dotnet/vscode-csharp/pull/7765))
@@ -28,7 +30,7 @@
2830
* Reduce memory and CPU costs due to SegmentedList usage (PR: [#75661](https://github.com/dotnet/roslyn/pull/75661))
2931
* Bump xamltools to 17.13.35506.24 (PR: [#7740](https://github.com/dotnet/vscode-csharp/pull/7740))
3032
* Bump xamltools to 17.13.35507.225 (PR: [#7755](https://github.com/dotnet/vscode-csharp/pull/7755))
31-
* XAML IntelliseSense completions for Image.Source
33+
* XAML IntelliseSense completions for Image.Source
3234

3335
# 2.55.x
3436
* Update Razor to 9.0.0-preview.24557.10 (PR: [#7757](https://github.com/dotnet/vscode-csharp/pull/7757))

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"defaults": {
4040
"roslyn": "4.13.0-2.24561.3",
4141
"omniSharp": "1.39.11",
42-
"razor": "9.0.0-preview.24557.11",
42+
"razor": "9.0.0-preview.24561.3",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.13.35507.225"
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

+6
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 Code. 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

+5
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

+1
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

+2
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)