Skip to content

Commit

Permalink
Add option to disable devkit
Browse files Browse the repository at this point in the history
  • Loading branch information
dibarbet committed Sep 18, 2023
1 parent a62858c commit 28e2485
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@
"default": null,
"description": "Sets a path where MSBuild binary logs are written to when loading projects, to help diagnose loading errors."
},
"dotnet.loadProjectsWithCSharpExtension": {
"scope": "machine-overridable",
"type": "boolean",
"default": false,
"description": "%configuration.dotnet.loadProjectsWithCSharpExtension%"
},
"dotnet.implementType.insertionBehavior": {
"type": "string",
"enum": [
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"configuration.dotnet.server.waitForDebugger": "Passes the --debug flag when launching the server to allow a debugger to be attached. (Previously `omnisharp.waitForDebugger`)",
"configuration.dotnet.server.trace": "Sets the logging level for the language server",
"configuration.dotnet.server.extensionPaths": "Override for path to language server --extension arguments",
"configuration.dotnet.loadProjectsWithCSharpExtension": "Forces projects to load with the C# extension only. This can be useful when using legacy project types that are not supported by the C# Dev Kit. (Requires window reload)",
"configuration.dotnet.implementType.insertionBehavior": "The insertion location of properties, events, and methods When implement interface or abstract class.",
"configuration.dotnet.implementType.insertionBehavior.withOtherMembersOfTheSameKind": "Place them with other members of the same kind.",
"configuration.dotnet.implementType.insertionBehavior.atTheEnd": "Place them at the end.",
Expand Down
4 changes: 2 additions & 2 deletions src/lsptoolshost/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class RoslynLanguageServer {
}

private async sendOrSubscribeForServiceBrokerConnection(): Promise<void> {
const csharpDevKitExtension = vscode.extensions.getExtension<CSharpDevKitExports>(csharpDevkitExtensionId);
const csharpDevKitExtension = getCSharpDevKit();
if (csharpDevKitExtension) {
const exports = await csharpDevKitExtension.activate();

Expand Down Expand Up @@ -469,7 +469,7 @@ export class RoslynLanguageServer {
// Get the brokered service pipe name from C# Dev Kit (if installed).
// We explicitly call this in the LSP server start action instead of awaiting it
// in our activation because C# Dev Kit depends on C# activation completing.
const csharpDevkitExtension = vscode.extensions.getExtension<CSharpDevKitExports>(csharpDevkitExtensionId);
const csharpDevkitExtension = getCSharpDevKit();
if (csharpDevkitExtension) {
_wasActivatedWithCSharpDevkit = true;

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function activate(

requiredPackageIds.push('Razor');

const csharpDevkitExtension = vscode.extensions.getExtension(csharpDevkitExtensionId);
const csharpDevkitExtension = getCSharpDevKit();
const useOmnisharpServer = !csharpDevkitExtension && commonOptions.useOmnisharpServer;
if (useOmnisharpServer) {
requiredPackageIds.push('OmniSharp');
Expand Down
5 changes: 5 additions & 0 deletions src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface LanguageServerOptions {
readonly logLevel: string;
readonly documentSelector: DocumentSelector;
readonly extensionsPaths: string[] | null;
readonly loadProjectsWithCSharpExtension: boolean;
}

export interface RazorOptions {
Expand Down Expand Up @@ -377,6 +378,9 @@ class LanguageServerOptionsImpl implements LanguageServerOptions {
public get extensionsPaths() {
return readOption<string[] | null>('dotnet.server.extensionPaths', null);
}
public get loadProjectsWithCSharpExtension() {
return readOption<boolean>('dotnet.loadProjectsWithCSharpExtension', false);
}
}

class RazorOptionsImpl implements RazorOptions {
Expand Down Expand Up @@ -469,4 +473,5 @@ export const OmnisharpOptionsThatTriggerReload: ReadonlyArray<keyof OmnisharpSer
export const LanguageServerOptionsThatTriggerReload: ReadonlyArray<keyof LanguageServerOptions> = [
'logLevel',
'documentSelector',
'loadProjectsWithCSharpExtension',
];
6 changes: 6 additions & 0 deletions src/utils/getCSharpDevKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

import * as vscode from 'vscode';
import { CSharpDevKitExports } from '../csharpDevKitExports';
import { languageServerOptions } from '../shared/options';

export const csharpDevkitExtensionId = 'ms-dotnettools.csdevkit';
export const csharpDevkitIntelliCodeExtensionId = 'ms-dotnettools.vscodeintellicode-csharp';

export function getCSharpDevKit(): vscode.Extension<CSharpDevKitExports> | undefined {
// Devkit is explicitly disabled via the option - we should ignore it even if it exists.
if (languageServerOptions.loadProjectsWithCSharpExtension) {
return undefined;
}

return vscode.extensions.getExtension<CSharpDevKitExports>(csharpDevkitExtensionId);
}

0 comments on commit 28e2485

Please sign in to comment.