Skip to content

Commit e830be5

Browse files
sharwellJoeRobich
authored andcommitted
Support solution filters (*.slnf)
1 parent b6d16ba commit e830be5

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,12 @@
409409
"workspaceContains:project.json",
410410
"workspaceContains:*.csproj",
411411
"workspaceContains:*.sln",
412+
"workspaceContains:*.slnf",
412413
"workspaceContains:*.csx",
413414
"workspaceContains:*.cake",
414415
"workspaceContains:**/*.csproj",
415416
"workspaceContains:**/*.sln",
417+
"workspaceContains:**/*.slnf",
416418
"workspaceContains:**/*.csx",
417419
"workspaceContains:**/*.cake"
418420
],

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);

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

0 commit comments

Comments
 (0)