Skip to content

Commit 4011c1a

Browse files
authored
Merge branch 'main' into merge_xaml_tools
2 parents 12f5e99 + 4d3c647 commit 4011c1a

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,6 +1725,11 @@
17251725
"default": true,
17261726
"description": "%configuration.dotnet.enableXamlToolsPreview%"
17271727
},
1728+
"dotnet.server.suppressLspErrorToasts": {
1729+
"type": "boolean",
1730+
"default": false,
1731+
"description": "%configuration.dotnet.server.suppressLspErrorToasts%"
1732+
},
17281733
"dotnet.projects.binaryLogPath": {
17291734
"scope": "machine-overridable",
17301735
"type": "string",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
3636
"configuration.dotnet.server.crashDumpPath": "Sets a folder path where crash dumps are written to if the language server crashes. Must be writeable by the user.",
3737
"configuration.dotnet.enableXamlToolsPreview": "[Experimental] Enables XAML tools when using C# Dev Kit",
38+
"configuration.dotnet.server.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
3839
"configuration.dotnet.projects.enableAutomaticRestore": "Enables automatic NuGet restore if the extension detects assets are missing.",
3940
"configuration.dotnet.preferCSharpExtension": "Forces projects to load with the C# extension only. This can be useful when using legacy project types that are not supported by C# Dev Kit. (Requires window reload)",
4041
"configuration.dotnet.implementType.insertionBehavior": "The insertion location of properties, events, and methods When implement interface or abstract class.",

src/lsptoolshost/roslynLanguageClient.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
6+
import {
7+
CancellationToken,
8+
LanguageClient,
9+
LanguageClientOptions,
10+
MessageSignature,
11+
ServerOptions,
12+
} from 'vscode-languageclient/node';
713
import CompositeDisposable from '../compositeDisposable';
814
import { IDisposable } from '../disposable';
15+
import { languageServerOptions } from '../shared/options';
916

1017
/**
1118
* Implementation of the base LanguageClient type that allows for additional items to be disposed of
@@ -31,6 +38,27 @@ export class RoslynLanguageClient extends LanguageClient {
3138
return super.dispose(timeout);
3239
}
3340

41+
override handleFailedRequest<T>(
42+
type: MessageSignature,
43+
token: CancellationToken | undefined,
44+
error: any,
45+
defaultValue: T,
46+
showNotification?: boolean
47+
) {
48+
// Temporarily allow LSP error toasts to be suppressed if configured.
49+
// There are a few architectural issues preventing us from solving some of the underlying problems,
50+
// for example Razor cohosting to fix text mismatch issues and unification of serialization libraries
51+
// to fix URI identification issues. Once resolved, we should remove this option.
52+
//
53+
// See also https://github.com/microsoft/vscode-dotnettools/issues/722
54+
// https://github.com/dotnet/vscode-csharp/issues/6973
55+
// https://github.com/microsoft/vscode-languageserver-node/issues/1449
56+
if (languageServerOptions.suppressLspErrorToasts) {
57+
return super.handleFailedRequest(type, token, error, defaultValue, false);
58+
}
59+
return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
60+
}
61+
3462
/**
3563
* Adds a disposable that should be disposed of when the LanguageClient instance gets disposed.
3664
*/

src/shared/options.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface LanguageServerOptions {
7979
readonly compilerDiagnosticScope: string;
8080
readonly componentPaths: { [key: string]: string } | null;
8181
readonly enableXamlToolsPreview: boolean;
82+
readonly suppressLspErrorToasts: boolean;
8283
}
8384

8485
export interface RazorOptions {
@@ -405,6 +406,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
405406
public get enableXamlToolsPreview() {
406407
return readOption<boolean>('dotnet.enableXamlToolsPreview', false);
407408
}
409+
public get suppressLspErrorToasts() {
410+
return readOption<boolean>('dotnet.server.suppressLspErrorToasts', false);
411+
}
408412
}
409413

410414
class RazorOptionsImpl implements RazorOptions {

0 commit comments

Comments
 (0)