Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow opting in to using the Roslyn tokenizer in Razor files #7748

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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.",
davidwengier marked this conversation as resolved.
Show resolved Hide resolved
"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)",
Expand Down
5 changes: 5 additions & 0 deletions src/razor/src/razorLanguageServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions src/razor/src/razorLanguageServerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export interface RazorLanguageServerOptions {
logLevel: LogLevel;
usingOmniSharp: boolean;
forceRuntimeCodeGeneration: boolean;
useRoslynTokenizer: boolean;
suppressErrorToasts: boolean;
}
2 changes: 2 additions & 0 deletions src/razor/src/razorLanguageServerOptionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function resolveRazorLanguageServerOptions(
const usingOmniSharp =
!getCSharpDevKit() && vscodeApi.workspace.getConfiguration().get<boolean>('dotnet.server.useOmnisharp');
const forceRuntimeCodeGeneration = serverConfig.get<boolean>('forceRuntimeCodeGeneration');
const useRoslynTokenizer = serverConfig.get<boolean>('useRoslynTokenizer');
const suppressErrorToasts = serverConfig.get<boolean>('suppressLspErrorToasts');

return {
Expand All @@ -34,6 +35,7 @@ export function resolveRazorLanguageServerOptions(
outputChannel: logger.outputChannel,
usingOmniSharp,
forceRuntimeCodeGeneration,
useRoslynTokenizer,
suppressErrorToasts,
} as RazorLanguageServerOptions;
}
Expand Down
Loading