Skip to content

Commit

Permalink
Merge pull request #7633 from dotnet/merge/main-to-prerelease
Browse files Browse the repository at this point in the history
[automated] Merge branch 'main' => 'prerelease'
  • Loading branch information
dibarbet authored Oct 7, 2024
2 parents 780d6a8 + 52dfbd4 commit 17c9cbb
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 9 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
- Diagnostics related feature requests and improvements [#5951](https://github.com/dotnet/vscode-csharp/issues/5951)
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)

# Latest
* Update Roslyn to 4.13.0-1.24503.11 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
* LSP hover responses escape backticks within inline code (PR: [#75364](https://github.com/dotnet/roslyn/pull/75364))
* Localize build host message output (PR: [#74910](https://github.com/dotnet/roslyn/pull/74910))
* Log and report NFW when we fail to apply project system update (PR: [#75362](https://github.com/dotnet/roslyn/pull/75362))
* Reduce allocations and UI thread CPU costs in WithDoNotCreateCreationPolicy (PR: [#75358](https://github.com/dotnet/roslyn/pull/75358))
* Enable support for an LSP client to open source generated files (PR: [#75180](https://github.com/dotnet/roslyn/pull/75180))
* Improve error reporting when reading bad metadata during EnC (PR: [#75304](https://github.com/dotnet/roslyn/pull/75304))
* Suppress recoverable errors from razor LSP (PR: [#7624](https://github.com/dotnet/vscode-csharp/pull/7624))
* NOTE: this can be re-enabled by setting `razor.languageServer.suppressLspErrorToasts = false`
* Update Roslyn to 4.13.0-1.24501.3 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
* Fix issue loading analyzers when using EnforceCodeStyleInBuild (PR: [#75250](https://github.com/dotnet/roslyn/pull/75250))
* Update Razor to 9.0.0-preview.24480.1 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
* Fuse fix usings (PR: [#10925](https://github.com/dotnet/razor/pull/10925))
* Fuse incorrect page directives (PR: [#10907](https://github.com/dotnet/razor/pull/10907))
* Calculate SuppressAddComponentParameter in tooling (PR: [#10763](https://github.com/dotnet/razor/pull/10763))
* Fix some `AssumeNotNull` assumptions (PR: [#10901](https://github.com/dotnet/razor/pull/10901))
* Fixing HTML attribute commit (PR: [#10897](https://github.com/dotnet/razor/pull/10897))
* Fix `FormattingContext` disposal (PR: [#10887](https://github.com/dotnet/razor/pull/10887))
* Fix #10891 - Formatting does not respect indentation within Razor comment blocks (PR: [#10893](https://github.com/dotnet/razor/pull/10893))

# 2.50.x
* Update Roslyn to 4.13.0-1.24477.2 (PR: [#<>](https://github.com/dotnet/vscode-csharp/pull/<>))
* Use MSBuild globs to determine which file changes are relevant (PR: [#75139](https://github.com/dotnet/roslyn/pull/75139))
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
}
},
"defaults": {
"roslyn": "4.13.0-1.24477.2",
"roslyn": "4.13.0-1.24503.11",
"omniSharp": "1.39.11",
"razor": "9.0.0-preview.24467.1",
"razor": "9.0.0-preview.24480.1",
"razorOmnisharp": "7.0.0-preview.23363.1",
"xamlTools": "17.12.35326.17"
},
Expand Down Expand Up @@ -1536,6 +1536,11 @@
"default": false,
"description": "%configuration.razor.languageServer.forceRuntimeCodeGeneration%",
"order": 90
},
"razor.languageServer.suppressLspErrorToasts": {
"type": "boolean",
"default": true,
"description": "%configuration.razor.languageServer.suppressLspErrorToasts%"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"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.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)",
"debuggers.coreclr.configurationSnippets.label.attach-local": ".NET: Attach to a .NET process",
Expand Down
12 changes: 10 additions & 2 deletions src/lsptoolshost/copilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@ import { UriConverter } from './uriConverter';
import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
import { languageServerOptions } from '../shared/options';

interface CopilotTrait {
name: string;
value: string;
includeInPrompt?: boolean;
promptTextOverride?: string;
}

interface CopilotRelatedFilesProviderRegistration {
registerRelatedFilesProvider(
providerId: { extensionId: string; languageId: string },
callback: (
uri: vscode.Uri,
context: { flags: Record<string, unknown> },
cancellationToken?: vscode.CancellationToken
) => Promise<{ entries: vscode.Uri[]; traits?: { name: string; value: string }[] }>
) => Promise<{ entries: vscode.Uri[]; traits?: CopilotTrait[] }>
): vscode.Disposable;
}

Expand Down Expand Up @@ -55,7 +63,7 @@ export function registerCopilotExtension(languageServer: RoslynLanguageServer, c
languageId: 'csharp',
};

relatedAPI.registerRelatedFilesProvider(id, async (uri, token) => {
relatedAPI.registerRelatedFilesProvider(id, async (uri, _, token) => {
const buildResult = (reports: CopilotRelatedDocumentsReport[], builder?: vscode.Uri[]) => {
if (reports) {
for (const report of reports) {
Expand Down
3 changes: 3 additions & 0 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {
showErrorMessage,
showInformationMessage,
} from '../shared/observers/utils/showMessage';
import { registerSourceGeneratedFilesContentProvider } from './sourceGeneratedFilesContentProvider';

let _channel: vscode.OutputChannel;
let _traceChannel: vscode.OutputChannel;
Expand Down Expand Up @@ -1068,6 +1069,8 @@ export async function activateRoslynLanguageServer(

registerRestoreCommands(context, languageServer, dotnetChannel);

registerSourceGeneratedFilesContentProvider(context, languageServer);

context.subscriptions.push(registerLanguageServerOptionChanges(optionObservable));

return languageServer;
Expand Down
14 changes: 14 additions & 0 deletions src/lsptoolshost/roslynProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ export interface CopilotRelatedDocumentsReport {
_vs_file_paths?: string[];
}

export interface SourceGeneratorGetRequestParams {
textDocument: lsp.TextDocumentIdentifier;
}

export interface SourceGeneratedDocumentText {
text: string;
}

export namespace WorkspaceDebugConfigurationRequest {
export const method = 'workspace/debugConfiguration';
export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer;
Expand Down Expand Up @@ -351,3 +359,9 @@ export namespace CopilotRelatedDocumentsRequest {
void
>(method);
}

export namespace SourceGeneratorGetTextRequest {
export const method = 'sourceGeneratedDocument/_roslyn_getText';
export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer;
export const type = new lsp.RequestType<SourceGeneratorGetRequestParams, SourceGeneratedDocumentText, void>(method);
}
31 changes: 31 additions & 0 deletions src/lsptoolshost/sourceGeneratedFilesContentProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import * as RoslynProtocol from './roslynProtocol';
import { RoslynLanguageServer } from './roslynLanguageServer';
import { UriConverter } from './uriConverter';
import * as lsp from 'vscode-languageserver-protocol';

export function registerSourceGeneratedFilesContentProvider(
context: vscode.ExtensionContext,
languageServer: RoslynLanguageServer
) {
context.subscriptions.push(
vscode.workspace.registerTextDocumentContentProvider(
'roslyn-source-generated',
new (class implements vscode.TextDocumentContentProvider {
async provideTextDocumentContent(uri: vscode.Uri, token: vscode.CancellationToken): Promise<string> {
const result = await languageServer.sendRequest(
RoslynProtocol.SourceGeneratorGetTextRequest.type,
{ textDocument: lsp.TextDocumentIdentifier.create(UriConverter.serialize(uri)) },
token
);
return result.text;
}
})()
)
);
}
43 changes: 43 additions & 0 deletions src/razor/src/razorLanguageClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import {
CancellationToken,
LanguageClient,
LanguageClientOptions,
MessageSignature,
ServerOptions,
} from 'vscode-languageclient/node';
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';

export class RazorLanguageClient extends LanguageClient {
razorOptions: RazorLanguageServerOptions;

constructor(
id: string,
name: string,
serverOptions: ServerOptions,
clientOptions: LanguageClientOptions,
razorOptions: RazorLanguageServerOptions,
forceDebug?: boolean
) {
super(id, name, serverOptions, clientOptions, forceDebug);
this.razorOptions = razorOptions;
}

override handleFailedRequest<T>(
type: MessageSignature,
token: CancellationToken | undefined,
error: any,
defaultValue: T,
showNotification?: boolean
) {
if (this.razorOptions.suppressErrorToasts) {
return super.handleFailedRequest(type, token, error, defaultValue, false);
}

return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
}
}
10 changes: 6 additions & 4 deletions src/razor/src/razorLanguageServerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EventEmitter } from 'events';
import * as vscode from 'vscode';
import { RequestHandler, RequestType } from 'vscode-jsonrpc';
import { GenericNotificationHandler, InitializeResult, LanguageClientOptions, State } from 'vscode-languageclient';
import { LanguageClient, ServerOptions } from 'vscode-languageclient/node';
import { ServerOptions } from 'vscode-languageclient/node';
import { RazorLanguage } from './razorLanguage';
import { RazorLanguageServerOptions } from './razorLanguageServerOptions';
import { resolveRazorLanguageServerOptions } from './razorLanguageServerOptionsResolver';
Expand All @@ -18,6 +18,7 @@ import { TelemetryReporter as RazorTelemetryReporter } from './telemetryReporter
import TelemetryReporter from '@vscode/extension-telemetry';
import { randomUUID } from 'crypto';
import { showErrorMessage } from '../../shared/observers/utils/showMessage';
import { RazorLanguageClient } from './razorLanguageClient';

const events = {
ServerStop: 'ServerStop',
Expand All @@ -26,7 +27,7 @@ const events = {
export class RazorLanguageServerClient implements vscode.Disposable {
private clientOptions!: LanguageClientOptions;
private serverOptions!: ServerOptions;
private client!: LanguageClient;
private client!: RazorLanguageClient;
private onStartListeners: Array<() => Promise<any>> = [];
private onStartedListeners: Array<() => Promise<any>> = [];
private eventBus: EventEmitter;
Expand Down Expand Up @@ -299,11 +300,12 @@ export class RazorLanguageServerClient implements vscode.Disposable {

this.serverOptions = childProcess;

this.client = new LanguageClient(
this.client = new RazorLanguageClient(
'razorLanguageServer',
'Razor Language Server',
this.serverOptions,
this.clientOptions
this.clientOptions,
options
);
}
}
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,4 +13,5 @@ export interface RazorLanguageServerOptions {
logLevel: LogLevel;
usingOmniSharp: boolean;
forceRuntimeCodeGeneration: 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 suppressErrorToasts = serverConfig.get<boolean>('suppressLspErrorToasts');

return {
serverPath: languageServerExecutablePath,
Expand All @@ -33,6 +34,7 @@ export function resolveRazorLanguageServerOptions(
outputChannel: logger.outputChannel,
usingOmniSharp,
forceRuntimeCodeGeneration,
suppressErrorToasts,
} as RazorLanguageServerOptions;
}

Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "2.50",
"version": "2.51",
"publicReleaseRefSpec": [
"^refs/heads/release$",
"^refs/heads/prerelease$",
Expand Down

0 comments on commit 17c9cbb

Please sign in to comment.