Skip to content

Commit d820b2e

Browse files
authored
Merge pull request #4481 from JoeRobich/solution-filters
Support solution filters (*.slnf)
2 parents b6d16ba + 5e8f728 commit d820b2e

35 files changed

+436
-15
lines changed

.vscode/launch.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,31 @@
128128
],
129129
"preLaunchTask": "buildDev"
130130
},
131+
{
132+
"name": "Launch slnFilterWithCsproj Workspace Tests",
133+
"type": "extensionHost",
134+
"request": "launch",
135+
"runtimeExecutable": "${execPath}",
136+
"args": [
137+
"--disable-extensions",
138+
"${workspaceRoot}/test/integrationTests/testAssets/slnFilterWithCsproj",
139+
"--extensionDevelopmentPath=${workspaceRoot}",
140+
"--extensionTestsPath=${workspaceRoot}/out/test/integrationTests"
141+
],
142+
"env": {
143+
"CODE_WORKSPACE_ROOT": "${workspaceRoot}",
144+
"CODE_TESTS_PATH": "${workspaceRoot}/out/test/integrationTests",
145+
"CODE_TESTS_WORKSPACE": "${workspaceRoot}/test/integrationTests/testAssets/slnFilterWithCsproj",
146+
"CODE_EXTENSIONS_PATH": "${workspaceRoot}",
147+
"OSVC_SUITE": "slnFilterWithCsproj"
148+
},
149+
"stopOnEntry": false,
150+
"sourceMaps": true,
151+
"outFiles": [
152+
"${workspaceRoot}/dist/*.js"
153+
],
154+
"preLaunchTask": "buildDev"
155+
},
131156
{
132157
"type": "node",
133158
"request": "launch",

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"test:integration": "gulp test:integration",
4646
"test:integration:singleCsproj": "gulp test:integration:singleCsproj",
4747
"test:integration:slnWithCsproj": "gulp test:integration:slnWithCsproj",
48+
"test:integration:slnFilterWithCsproj": "gulp test:integration:slnFilterWithCsproj",
4849
"test:release": "mocha --config ./.mocharc.jsonc test/releaseTests/**/*.test.ts",
4950
"test:artifacts": "mocha --config ./.mocharc.jsonc test/artifactTests/**/*.test.ts",
5051
"postinstall": "node ./node_modules/vscode/bin/install",
@@ -409,10 +410,12 @@
409410
"workspaceContains:project.json",
410411
"workspaceContains:*.csproj",
411412
"workspaceContains:*.sln",
413+
"workspaceContains:*.slnf",
412414
"workspaceContains:*.csx",
413415
"workspaceContains:*.cake",
414416
"workspaceContains:**/*.csproj",
415417
"workspaceContains:**/*.sln",
418+
"workspaceContains:**/*.slnf",
416419
"workspaceContains:**/*.csx",
417420
"workspaceContains:**/*.cake"
418421
],

src/configurationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class CSharpConfigurationProvider implements vscode.DebugConfigurationPro
4040
}
4141

4242
let serverFolder = solutionPathOrFolder;
43-
// If its a .sln file, get the folder of the solution.
43+
// If its a .sln or .slnf file, get the folder of the solution.
4444
return fs.lstat(solutionPathOrFolder).then(stat => {
4545
return stat.isFile();
4646
}).then(isFile => {

src/omnisharp/launcher.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ export const disabledSchemes = new Set([
5252

5353
/**
5454
* Returns a list of potential targets on which OmniSharp can be launched.
55-
* This includes `project.json` files, `*.sln` files (if any `*.csproj` files are found), and the root folder
55+
* This includes `project.json` files, `*.sln` and `*.slnf` files (if any `*.csproj` files are found), and the root folder
5656
* (if it doesn't contain a `project.json` file, but `project.json` files exist). In addition, the root folder
57-
* is included if there are any `*.csproj` files present, but a `*.sln* file is not found.
57+
* is included if there are any `*.csproj` files present, but a `*.sln` or `*.slnf` file is not found.
5858
*/
5959
export async function findLaunchTargets(options: Options): Promise<LaunchTarget[]> {
6060
if (!vscode.workspace.workspaceFolders) {
6161
return Promise.resolve([]);
6262
}
6363

6464
const projectFiles = await vscode.workspace.findFiles(
65-
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
65+
/*include*/ '{**/*.sln,**/*.slnf,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
6666
/*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}',
6767
/*maxResults*/ options.maxProjectResults);
6868

@@ -76,14 +76,14 @@ export async function findLaunchTargets(options: Options): Promise<LaunchTarget[
7676

7777
export function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
7878
// The list of launch targets is calculated like so:
79-
// * If there are .csproj files, .sln files are considered as launch targets.
79+
// * If there are .csproj files, .sln and .slnf files are considered as launch targets.
8080
// * Any project.json file is considered a launch target.
8181
// * If there is no project.json file in a workspace folder, the workspace folder as added as a launch target.
82-
// * Additionally, if there are .csproj files, but no .sln file, the root is added as a launch target.
82+
// * Additionally, if there are .csproj files, but no .sln or .slnf file, the root is added as a launch target.
8383
//
8484
// TODO:
8585
// * It should be possible to choose a .csproj as a launch target
86-
// * It should be possible to choose a .sln file even when no .csproj files are found
86+
// * It should be possible to choose a .sln or .slnf file even when no .csproj files are found
8787
// within the root.
8888

8989
if (!Array.isArray(resources) || resources.length === 0) {
@@ -132,7 +132,7 @@ export function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[
132132
let folderPath = folder.uri.fsPath;
133133

134134
resources.forEach(resource => {
135-
// Add .sln files if there are .csproj files
135+
// Add .sln and .slnf files if there are .csproj files
136136
if (hasCsProjFiles && isSolution(resource)) {
137137
hasSlnFile = true;
138138
targets.push({
@@ -176,7 +176,7 @@ export function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[
176176
});
177177

178178
// Add the root folder under the following circumstances:
179-
// * If there are .csproj files, but no .sln file, and none in the root.
179+
// * If there are .csproj files, but no .sln or .slnf file, and none in the root.
180180
// * If there are project.json files, but none in the root.
181181
if ((hasCsProjFiles && !hasSlnFile) || (hasProjectJson && !hasProjectJsonAtRoot)) {
182182
targets.push({
@@ -229,7 +229,7 @@ function isCSharpProject(resource: vscode.Uri): boolean {
229229
}
230230

231231
function isSolution(resource: vscode.Uri): boolean {
232-
return /\.sln$/i.test(resource.fsPath);
232+
return /\.slnf?$/i.test(resource.fsPath);
233233
}
234234

235235
function isProjectJson(resource: vscode.Uri): boolean {

src/omnisharp/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ export class OmniSharpServer {
498498
const options = this.optionProvider.GetLatestOptions();
499499
return findLaunchTargets(options).then(async launchTargets => {
500500
// If there aren't any potential launch targets, we create file watcher and try to
501-
// start the server again once a *.sln, *.csproj, project.json, CSX or Cake file is created.
501+
// start the server again once a *.sln, *.slnf, *.csproj, project.json, CSX or Cake file is created.
502502
if (launchTargets.length === 0) {
503503
return new Promise<void>((resolve, reject) => {
504504
// 1st watch for files
505-
let watcher = this.vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
505+
let watcher = this.vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.slnf,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
506506
/*ignoreCreateEvents*/ false,
507507
/*ignoreChangeEvents*/ true,
508508
/*ignoreDeleteEvents*/ true);

tasks/testTasks.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ gulp.task("test:integration:slnWithCsproj", async () => {
4545
return runIntegrationTest("slnWithCsproj");
4646
});
4747

48+
gulp.task("test:integration:slnFilterWithCsproj", async () => {
49+
return runIntegrationTest("slnFilterWithCsproj");
50+
});
51+
4852
gulp.task("test:integration:BasicRazorApp2_1", async () => {
4953
return runIntegrationTest("BasicRazorApp2_1");
5054
});
@@ -53,6 +57,7 @@ gulp.task(
5357
"test:integration", gulp.series(
5458
"test:integration:singleCsproj",
5559
"test:integration:slnWithCsproj",
60+
"test:integration:slnFilterWithCsproj",
5661
"test:integration:BasicRazorApp2_1"
5762
));
5863

test-plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Validating C# Extension for VS Code
22

33
#### Opening projects
4-
When you open a directory in VS Code, the C# extension should look for a .csproj or .sln file in that directory and use "OmniSharp" to load it. If a .cs file is present and no .csproj or .sln file are present, Omnisharp should start but the intellisense should only appear when a change is made to the file.
4+
When you open a directory in VS Code, the C# extension should look for a .csproj, .sln, or .slnf file in that directory and use "OmniSharp" to load it. If a .cs file is present and no .csproj, .sln, or .slnf file are present, Omnisharp should start but the intellisense should only appear when a change is made to the file.
55
If you look in "Output > Omnisharp Log" a bunch of information should be printed about what copy of MSBuild was used and what projects were load
66

77
Project types to test:
88
* Standalone csproj
9-
* Directory containing .sln file that references csprojs--projects should be loaded
9+
* Directory containing .sln or .slnf file that references csprojs--projects should be loaded
1010
* .NET Core/.NET Standard csproj
1111
* (Windows) Desktop .NET projects
1212
* Unity projects
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 { ITestAssetWorkspace } from "./testAssets";
7+
8+
let workspace: ITestAssetWorkspace = {
9+
description: "sln filter with a csproj's",
10+
projects: [{
11+
relativeFilePath: "src/app/app.csproj"
12+
}]
13+
};
14+
15+
export default workspace;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/obj/
2+
**/bin/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"omnisharp.defaultLaunchSolution": "SolutionFilter.slnf",
3+
"omnisharp.path": "latest",
4+
"omnisharp.enableRoslynAnalyzers": true
5+
}

0 commit comments

Comments
 (0)