Skip to content

Commit 17c9cbb

Browse files
authored
Merge pull request #7633 from dotnet/merge/main-to-prerelease
[automated] Merge branch 'main' => 'prerelease'
2 parents 780d6a8 + 52dfbd4 commit 17c9cbb

12 files changed

+140
-9
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
- Diagnostics related feature requests and improvements [#5951](https://github.com/dotnet/vscode-csharp/issues/5951)
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

6+
# Latest
7+
* Update Roslyn to 4.13.0-1.24503.11 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
8+
* LSP hover responses escape backticks within inline code (PR: [#75364](https://github.com/dotnet/roslyn/pull/75364))
9+
* Localize build host message output (PR: [#74910](https://github.com/dotnet/roslyn/pull/74910))
10+
* Log and report NFW when we fail to apply project system update (PR: [#75362](https://github.com/dotnet/roslyn/pull/75362))
11+
* Reduce allocations and UI thread CPU costs in WithDoNotCreateCreationPolicy (PR: [#75358](https://github.com/dotnet/roslyn/pull/75358))
12+
* Enable support for an LSP client to open source generated files (PR: [#75180](https://github.com/dotnet/roslyn/pull/75180))
13+
* Improve error reporting when reading bad metadata during EnC (PR: [#75304](https://github.com/dotnet/roslyn/pull/75304))
14+
* Suppress recoverable errors from razor LSP (PR: [#7624](https://github.com/dotnet/vscode-csharp/pull/7624))
15+
* NOTE: this can be re-enabled by setting `razor.languageServer.suppressLspErrorToasts = false`
16+
* Update Roslyn to 4.13.0-1.24501.3 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
17+
* Fix issue loading analyzers when using EnforceCodeStyleInBuild (PR: [#75250](https://github.com/dotnet/roslyn/pull/75250))
18+
* Update Razor to 9.0.0-preview.24480.1 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
19+
* Fuse fix usings (PR: [#10925](https://github.com/dotnet/razor/pull/10925))
20+
* Fuse incorrect page directives (PR: [#10907](https://github.com/dotnet/razor/pull/10907))
21+
* Calculate SuppressAddComponentParameter in tooling (PR: [#10763](https://github.com/dotnet/razor/pull/10763))
22+
* Fix some `AssumeNotNull` assumptions (PR: [#10901](https://github.com/dotnet/razor/pull/10901))
23+
* Fixing HTML attribute commit (PR: [#10897](https://github.com/dotnet/razor/pull/10897))
24+
* Fix `FormattingContext` disposal (PR: [#10887](https://github.com/dotnet/razor/pull/10887))
25+
* Fix #10891 - Formatting does not respect indentation within Razor comment blocks (PR: [#10893](https://github.com/dotnet/razor/pull/10893))
26+
627
# 2.50.x
728
* Update Roslyn to 4.13.0-1.24477.2 (PR: [#<>](https://github.com/dotnet/vscode-csharp/pull/<>))
829
* Use MSBuild globs to determine which file changes are relevant (PR: [#75139](https://github.com/dotnet/roslyn/pull/75139))

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
}
3838
},
3939
"defaults": {
40-
"roslyn": "4.13.0-1.24477.2",
40+
"roslyn": "4.13.0-1.24503.11",
4141
"omniSharp": "1.39.11",
42-
"razor": "9.0.0-preview.24467.1",
42+
"razor": "9.0.0-preview.24480.1",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.12.35326.17"
4545
},
@@ -1536,6 +1536,11 @@
15361536
"default": false,
15371537
"description": "%configuration.razor.languageServer.forceRuntimeCodeGeneration%",
15381538
"order": 90
1539+
},
1540+
"razor.languageServer.suppressLspErrorToasts": {
1541+
"type": "boolean",
1542+
"default": true,
1543+
"description": "%configuration.razor.languageServer.suppressLspErrorToasts%"
15391544
}
15401545
}
15411546
},

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
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.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
130131
"debuggers.coreclr.configurationSnippets.label.console-local": ".NET: Launch Executable file (Console)",
131132
"debuggers.coreclr.configurationSnippets.label.web-local": ".NET: Launch Executable file (Web)",
132133
"debuggers.coreclr.configurationSnippets.label.attach-local": ".NET: Attach to a .NET process",

src/lsptoolshost/copilot.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ import { UriConverter } from './uriConverter';
1111
import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
1212
import { languageServerOptions } from '../shared/options';
1313

14+
interface CopilotTrait {
15+
name: string;
16+
value: string;
17+
includeInPrompt?: boolean;
18+
promptTextOverride?: string;
19+
}
20+
1421
interface CopilotRelatedFilesProviderRegistration {
1522
registerRelatedFilesProvider(
1623
providerId: { extensionId: string; languageId: string },
1724
callback: (
1825
uri: vscode.Uri,
26+
context: { flags: Record<string, unknown> },
1927
cancellationToken?: vscode.CancellationToken
20-
) => Promise<{ entries: vscode.Uri[]; traits?: { name: string; value: string }[] }>
28+
) => Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }>
2129
): vscode.Disposable;
2230
}
2331

@@ -55,7 +63,7 @@ export function registerCopilotExtension(languageServer: RoslynLanguageServer, c
5563
languageId: 'csharp',
5664
};
5765

58-
relatedAPI.registerRelatedFilesProvider(id, async (uri, token) => {
66+
relatedAPI.registerRelatedFilesProvider(id, async (uri, _, token) => {
5967
const buildResult = (reports: CopilotRelatedDocumentsReport[], builder?: vscode.Uri[]) => {
6068
if (reports) {
6169
for (const report of reports) {

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ import {
7474
showErrorMessage,
7575
showInformationMessage,
7676
} from '../shared/observers/utils/showMessage';
77+
import { registerSourceGeneratedFilesContentProvider } from './sourceGeneratedFilesContentProvider';
7778

7879
let _channel: vscode.OutputChannel;
7980
let _traceChannel: vscode.OutputChannel;
@@ -1068,6 +1069,8 @@ export async function activateRoslynLanguageServer(
10681069

10691070
registerRestoreCommands(context, languageServer, dotnetChannel);
10701071

1072+
registerSourceGeneratedFilesContentProvider(context, languageServer);
1073+
10711074
context.subscriptions.push(registerLanguageServerOptionChanges(optionObservable));
10721075

10731076
return languageServer;

src/lsptoolshost/roslynProtocol.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ export interface CopilotRelatedDocumentsReport {
230230
_vs_file_paths?: string[];
231231
}
232232

233+
export interface SourceGeneratorGetRequestParams {
234+
textDocument: lsp.TextDocumentIdentifier;
235+
}
236+
237+
export interface SourceGeneratedDocumentText {
238+
text: string;
239+
}
240+
233241
export namespace WorkspaceDebugConfigurationRequest {
234242
export const method = 'workspace/debugConfiguration';
235243
export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer;
@@ -351,3 +359,9 @@ export namespace CopilotRelatedDocumentsRequest {
351359
void
352360
>(method);
353361
}
362+
363+
export namespace SourceGeneratorGetTextRequest {
364+
export const method = 'sourceGeneratedDocument/_roslyn_getText';
365+
export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer;
366+
export const type = new lsp.RequestType<SourceGeneratorGetRequestParams, SourceGeneratedDocumentText, void>(method);
367+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as vscode from 'vscode';
7+
import * as RoslynProtocol from './roslynProtocol';
8+
import { RoslynLanguageServer } from './roslynLanguageServer';
9+
import { UriConverter } from './uriConverter';
10+
import * as lsp from 'vscode-languageserver-protocol';
11+
12+
export function registerSourceGeneratedFilesContentProvider(
13+
context: vscode.ExtensionContext,
14+
languageServer: RoslynLanguageServer
15+
) {
16+
context.subscriptions.push(
17+
vscode.workspace.registerTextDocumentContentProvider(
18+
'roslyn-source-generated',
19+
new (class implements vscode.TextDocumentContentProvider {
20+
async provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): Promise<string> {
21+
const result = await languageServer.sendRequest(
22+
RoslynProtocol.SourceGeneratorGetTextRequest.type,
23+
{ textDocument: lsp.TextDocumentIdentifier.create(UriConverter.serialize(uri)) },
24+
token
25+
);
26+
return result.text;
27+
}
28+
})()
29+
)
30+
);
31+
}

src/razor/src/razorLanguageClient.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import {
7+
CancellationToken,
8+
LanguageClient,
9+
LanguageClientOptions,
10+
MessageSignature,
11+
ServerOptions,
12+
} from 'vscode-languageclient/node';
13+
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
14+
15+
export class RazorLanguageClient extends LanguageClient {
16+
razorOptions: RazorLanguageServerOptions;
17+
18+
constructor(
19+
id: string,
20+
name: string,
21+
serverOptions: ServerOptions,
22+
clientOptions: LanguageClientOptions,
23+
razorOptions: RazorLanguageServerOptions,
24+
forceDebug?: boolean
25+
) {
26+
super(id, name, serverOptions, clientOptions, forceDebug);
27+
this.razorOptions = razorOptions;
28+
}
29+
30+
override handleFailedRequest<T>(
31+
type: MessageSignature,
32+
token: CancellationToken | undefined,
33+
error: any,
34+
defaultValue: T,
35+
showNotification?: boolean
36+
) {
37+
if (this.razorOptions.suppressErrorToasts) {
38+
return super.handleFailedRequest(type, token, error, defaultValue, false);
39+
}
40+
41+
return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
42+
}
43+
}

src/razor/src/razorLanguageServerClient.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { EventEmitter } from 'events';
88
import * as vscode from 'vscode';
99
import { RequestHandler, RequestType } from 'vscode-jsonrpc';
1010
import { GenericNotificationHandler, InitializeResult, LanguageClientOptions, State } from 'vscode-languageclient';
11-
import { LanguageClient, ServerOptions } from 'vscode-languageclient/node';
11+
import { ServerOptions } from 'vscode-languageclient/node';
1212
import { RazorLanguage } from './razorLanguage';
1313
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
1414
import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver';
@@ -18,6 +18,7 @@ import { TelemetryReporter as RazorTelemetryReporter } from './telemetryReporter
1818
import TelemetryReporter from '@vscode/extension-telemetry';
1919
import { randomUUID } from 'crypto';
2020
import { showErrorMessage } from '../../shared/observers/utils/showMessage';
21+
import { RazorLanguageClient } from './razorLanguageClient';
2122

2223
const events = {
2324
ServerStop: 'ServerStop',
@@ -26,7 +27,7 @@ const events = {
2627
export class RazorLanguageServerClient implements vscode.Disposable {
2728
private clientOptions!: LanguageClientOptions;
2829
private serverOptions!: ServerOptions;
29-
private client!: LanguageClient;
30+
private client!: RazorLanguageClient;
3031
private onStartListeners: Array<() => Promise<any>> = [];
3132
private onStartedListeners: Array<() => Promise<any>> = [];
3233
private eventBus: EventEmitter;
@@ -299,11 +300,12 @@ export class RazorLanguageServerClient implements vscode.Disposable {
299300

300301
this.serverOptions = childProcess;
301302

302-
this.client = new LanguageClient(
303+
this.client = new RazorLanguageClient(
303304
'razorLanguageServer',
304305
'Razor Language Server',
305306
this.serverOptions,
306-
this.clientOptions
307+
this.clientOptions,
308+
options
307309
);
308310
}
309311
}

src/razor/src/razorLanguageServerOptions.ts

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

0 commit comments

Comments
 (0)