From fca992f17ea190567597440394b9e2d1268d66bd Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 22 Aug 2018 14:55:44 -0700 Subject: [PATCH 1/3] Add support for misc files --- src/omnisharp/launcher.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index a31a30803..e0232a5cf 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -16,7 +16,8 @@ export enum LaunchTargetKind { ProjectJson, Folder, Csx, - Cake + Cake, + MiscellaneousCS } /** @@ -42,7 +43,7 @@ export function findLaunchTargets(options: Options): Thenable { } return vscode.workspace.findFiles( - /*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}', + /*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake,**/*.cs}', /*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}', /*maxResults*/ options.maxProjectResults) .then(resourcesToLaunchTargets); @@ -90,7 +91,8 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] { hasProjectJson = false, hasProjectJsonAtRoot = false, hasCSX = false, - hasCake = false; + hasCake = false, + hasCs = false; hasCsProjFiles = resources.some(isCSharpProject); @@ -134,6 +136,11 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] { if (!hasCake && isCake(resource)) { hasCake = true; } + + //Discover if there is any cs file + if (!hasCs && isCs(resource)) { + hasCs = true; + } }); // Add the root folder under the following circumstances: @@ -170,6 +177,16 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] { kind: LaunchTargetKind.Cake }); } + + if (hasCs && !hasSlnFile && !hasCsProjFiles && !hasProjectJson && !hasProjectJsonAtRoot) { + targets.push({ + label: "Miscellaneous", + description: path.basename(folderPath), + target: folderPath, + directory: folderPath, + kind: LaunchTargetKind.MiscellaneousCS + }); + } }); return targets.sort((a, b) => a.directory.localeCompare(b.directory)); @@ -195,6 +212,10 @@ function isCake(resource: vscode.Uri): boolean { return /\.cake$/i.test(resource.fsPath); } +function isCs(resource: vscode.Uri): boolean { + return /\.cs$/i.test(resource.fsPath); +} + export interface LaunchResult { process: ChildProcess; command: string; From 179d23d87a183111947014076b30b4f6cdccd444 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Mon, 27 Aug 2018 15:07:58 -0700 Subject: [PATCH 2/3] PR feedback --- src/omnisharp/launcher.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/omnisharp/launcher.ts b/src/omnisharp/launcher.ts index e0232a5cf..21f5f393c 100644 --- a/src/omnisharp/launcher.ts +++ b/src/omnisharp/launcher.ts @@ -16,8 +16,7 @@ export enum LaunchTargetKind { ProjectJson, Folder, Csx, - Cake, - MiscellaneousCS + Cake } /** @@ -180,11 +179,11 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] { if (hasCs && !hasSlnFile && !hasCsProjFiles && !hasProjectJson && !hasProjectJsonAtRoot) { targets.push({ - label: "Miscellaneous", - description: path.basename(folderPath), + label: path.basename(folderPath), + description: '', target: folderPath, directory: folderPath, - kind: LaunchTargetKind.MiscellaneousCS + kind: LaunchTargetKind.Folder }); } }); From 4bd398cb840c334d745db379b434e667171c6792 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 28 Aug 2018 12:11:33 -0700 Subject: [PATCH 3/3] Add changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0afad3aea..965b3703f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ * Added support for tracking opening, closing and changing of virtual documents that don't exist on disk. (PR: [#2436](https://github.com/OmniSharp/omnisharp-vscode/pull/2436)) _(Contributed by [@NTaylorMullen](https://github.com/NTaylorMullen))_ +* Enabled IDE features for .cs files that are not part of a project. (PR: [#2471](https://github.com/OmniSharp/omnisharp-vscode/pull/2471), [omnisharp-roslyn#1252](https://github.com/OmniSharp/omnisharp-roslyn/pull/1252)) + #### Misc * Added a prompt to "Restart OmniSharp" when there is a change in omnisharp "path", "useGlobalMono" or "waitForDebugger" settings.(PR: [#2316](https://github.com/OmniSharp/omnisharp-vscode/pull/2316))