Skip to content

Commit bd18521

Browse files
Merged PR 474132: Update support for dotnet.defaultSolution to recognize 'disable' and other tweaks
- Update the message for dotnet.defaultSolution to match the Dev Kit one - Remove order: 0 for options that should only be set by extension developers - Make the "useOmnisharp" option order first - Update support for dotnet.defaultSolution to recognize 'disable'
2 parents 7a95508 + 81213cb commit bd18521

File tree

3 files changed

+37
-33
lines changed

3 files changed

+37
-33
lines changed

package.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,8 @@
714714
"dotnet.server.useOmnisharp": {
715715
"type": "boolean",
716716
"default": false,
717-
"description": "Switches to use the Omnisharp server for language features when enabled (requires restart). This option will not work with C# Dev Kit"
717+
"description": "Switches to use the Omnisharp server for language features when enabled (requires restart). This option will not work with C# Dev Kit.",
718+
"order": 0
718719
},
719720
"csharp.format.enable": {
720721
"type": "boolean",
@@ -1146,26 +1147,24 @@
11461147
"properties": {
11471148
"dotnet.defaultSolution": {
11481149
"type": "string",
1149-
"description": "The name of the default solution used at start up if the repo has multiple solutions. e.g.'MyAwesomeSolution.sln'. Default value is `null` which will cause the first in alphabetical order to be chosen."
1150+
"description": "The path of the default solution to be opened in the workspace, or set to 'disable' to skip it.",
1151+
"order": 0
11501152
},
11511153
"dotnet.dotnetPath": {
11521154
"type": "string",
11531155
"scope": "machine-overridable",
1154-
"description": "Specified the path to a dotnet installation to use instead of the default system one. This only influences the dotnet installation to use for hosting the language server itself. Example: \"/home/username/mycustomdotnetdirectory\".",
1155-
"order": 0
1156+
"description": "Specified the path to a dotnet installation to use instead of the default system one. This only influences the dotnet installation to use for hosting the language server itself. Example: \"/home/username/mycustomdotnetdirectory\"."
11561157
},
11571158
"dotnet.server.path": {
11581159
"type": "string",
11591160
"scope": "machine-overridable",
1160-
"description": "Specifies the absolute path to the server (LSP or O#) executable. When left empty the version pinned to the C# Extension is used.",
1161-
"order": 0
1161+
"description": "Specifies the absolute path to the server (LSP or O#) executable. When left empty the version pinned to the C# Extension is used."
11621162
},
11631163
"dotnet.server.waitForDebugger": {
11641164
"type": "boolean",
11651165
"scope": "machine-overridable",
11661166
"default": false,
1167-
"description": "Passes the --debug flag when launching the server to allow a debugger to be attached.",
1168-
"order": 0
1167+
"description": "Passes the --debug flag when launching the server to allow a debugger to be attached."
11691168
},
11701169
"dotnet.server.trace": {
11711170
"scope": "window",
@@ -1180,8 +1179,7 @@
11801179
"None"
11811180
],
11821181
"default": "Information",
1183-
"description": "Sets the logging level for the language server",
1184-
"order": 0
1182+
"description": "Sets the logging level for the language server"
11851183
},
11861184
"dotnet.server.extensionPaths": {
11871185
"type": [

src/lsptoolshost/roslynLanguageServer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ export class RoslynLanguageServer {
217217
// Register Razor dynamic file info handling
218218
this.registerRazor(this._languageClient);
219219

220-
// If Dev Kit isn't installed, then we are responsible for picking the solution to open. Check the workpace setting,
221-
// or fallback to looking for a solution
222-
if (!this._wasActivatedWithCSharpDevkit) {
223-
if (this._solutionFile === undefined && options.commonOptions.defaultSolution !== '') {
220+
// If Dev Kit isn't installed, then we are responsible for picking the solution to open, assuming the user hasn't explicitly
221+
// disabled it.
222+
if (!this._wasActivatedWithCSharpDevkit && options.commonOptions.defaultSolution !== 'disable' && this._solutionFile === undefined) {
223+
if (options.commonOptions.defaultSolution !== '') {
224224
this.openSolution(vscode.Uri.file(options.commonOptions.defaultSolution));
225225
} else {
226-
// Auto open if there is just one solution target, if not the let the user trigger an open solution themselves
226+
// Auto open if there is just one solution target; if there's more the one we'll just let the user pick with the picker.
227227
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
228228
if (solutionUris && solutionUris.length === 1) {
229229
this.openSolution(solutionUris[0]);

src/shared/options.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,31 @@ export class Options {
3838

3939
let defaultSolution = '';
4040

41-
if (vscode.workspace.workspaceFolders !== undefined) {
42-
// If this is multi-folder, then check to see if we have a fully qualified path set directly in the workspace settings; this will let the user directly specify in their
43-
// workspace settings which one is active in the case of a multi-folder workspace. This has to be absolute because in this case, there's no clear folder to resolve a relative
44-
// path against.
45-
if (vscode.workspace.workspaceFolders.length > 1) {
46-
const defaultSolutionFromWorkspace = Options.readOption<string>(config, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
47-
if (path.isAbsolute(defaultSolutionFromWorkspace)) {
48-
defaultSolution = defaultSolutionFromWorkspace;
41+
const defaultSolutionFromWorkspace = Options.readOption<string>(config, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
42+
43+
// If the workspace has defaultSolution disabled, just be done
44+
if (defaultSolutionFromWorkspace === "disable") {
45+
defaultSolution = "disable";
46+
} else {
47+
if (vscode.workspace.workspaceFolders !== undefined) {
48+
// If this is multi-folder, then check to see if we have a fully qualified path set directly in the workspace settings; this will let the user directly specify in their
49+
// workspace settings which one is active in the case of a multi-folder workspace. This has to be absolute because in this case, there's no clear folder to resolve a relative
50+
// path against.
51+
if (vscode.workspace.workspaceFolders.length > 1) {
52+
if (path.isAbsolute(defaultSolutionFromWorkspace)) {
53+
defaultSolution = defaultSolutionFromWorkspace;
54+
}
4955
}
50-
}
5156

52-
// If we didn't have an absolute workspace setting, then check each workspace folder and resolve any relative paths against it
53-
if(defaultSolution == '') {
54-
for (let workspaceFolder of vscode.workspace.workspaceFolders) {
55-
const workspaceFolderConfig = vscode.workspace.getConfiguration(undefined, workspaceFolder.uri);
56-
const defaultSolutionFromWorkspaceFolder = Options.readOption<string>(workspaceFolderConfig, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
57-
if (defaultSolutionFromWorkspaceFolder !== '') {
58-
defaultSolution = path.join(workspaceFolder.uri.fsPath, defaultSolutionFromWorkspaceFolder);
59-
break;
57+
// If we didn't have an absolute workspace setting, then check each workspace folder and resolve any relative paths against it
58+
if(defaultSolution == '') {
59+
for (let workspaceFolder of vscode.workspace.workspaceFolders) {
60+
const workspaceFolderConfig = vscode.workspace.getConfiguration(undefined, workspaceFolder.uri);
61+
const defaultSolutionFromWorkspaceFolder = Options.readOption<string>(workspaceFolderConfig, 'dotnet.defaultSolution', '', 'omnisharp.defaultLaunchSolution');
62+
if (defaultSolutionFromWorkspaceFolder !== '' && defaultSolutionFromWorkspaceFolder !== "disable") {
63+
defaultSolution = path.join(workspaceFolder.uri.fsPath, defaultSolutionFromWorkspaceFolder);
64+
break;
65+
}
6066
}
6167
}
6268
}
@@ -251,7 +257,7 @@ export interface CommonOptions {
251257
useOmnisharpServer: boolean;
252258
excludePaths: string[];
253259

254-
/** The default solution; this has been normalized to a full file path from the workspace folder it was configured in */
260+
/** The default solution; this has been normalized to a full file path from the workspace folder it was configured in, or the string "disable" if that has been disabled */
255261
defaultSolution: string;
256262
}
257263

0 commit comments

Comments
 (0)