Skip to content

Commit d883348

Browse files
authored
.slnx support (#9286)
2 parents f2caf72 + a20102d commit d883348

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A [Visual Studio Code](https://code.visualstudio.com/) [extension](https://marke
55
While it is possible to use the C# extension as a standalone extension, we highly recommend using [C# Dev Kit][csdevkitextension].
66

77
1. Installing [C# Dev Kit][csdevkitextension] will automatically install this extension as a required dependency.
8-
2. Open a folder/workspace that contains a C# project (.csproj) and a C# solution (.sln) and the extension will activate.
8+
2. Open a folder/workspace that contains a C# project (.csproj) and a C# solution (.sln/.slnx) and the extension will activate.
99
3. Whether you install C# Dev Kit or just the C# extension, the [.NET Install Tool](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.vscode-dotnet-runtime) will be installed as a dependency.
1010

1111
Note: If working on a solution that requires versions prior to .NET 6 or non-solution based projects, install a .NET Framework runtime and [MSBuild tooling](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022).

src/lsptoolshost/server/roslynLanguageServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export class RoslynLanguageServer {
562562
await this.openSolution(vscode.Uri.file(defaultSolution));
563563
} else {
564564
// 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.
565-
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
565+
const solutionUris = await vscode.workspace.findFiles('**/*.slnx?', '**/node_modules/**', 2);
566566
if (solutionUris) {
567567
if (solutionUris.length === 1) {
568568
await this.openSolution(solutionUris[0]);

src/lsptoolshost/workspace/workspaceCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async function openSolution(languageServer: RoslynLanguageServer): Promise<vscod
2424
return undefined;
2525
}
2626

27-
const solutionFiles = await vscode.workspace.findFiles('**/*.{sln,slnf}');
27+
const solutionFiles = await vscode.workspace.findFiles('**/*.{sln,slnx,slnf}');
2828
const launchTargets = solutionFiles.map(createLaunchTargetForSolution);
2929
const launchTarget = await vscode.window.showQuickPick(launchTargets, {
3030
matchOnDescription: true,

src/omnisharp/launcher.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ export const disabledSchemes = new Set([vsls]);
3131

3232
/**
3333
* Returns a list of potential targets on which OmniSharp can be launched.
34-
* This includes `*.sln` and `*.slnf` files (if any `*.csproj` files are found), and the root folder
35-
* In addition, the root folder is included if there are any `*.csproj` files present, but a `*.sln` or `*.slnf` file is not found.
34+
* This includes `*.sln`, `*.slnx`, and `*.slnf` files (if any `*.csproj` files are found), and the root folder
35+
* In addition, the root folder is included if there are any `*.csproj` files present, but a `*.sln`, `*.slnx`, or `*.slnf` file is not found.
3636
*/
3737
export async function findLaunchTargets(): Promise<LaunchTarget[]> {
3838
if (!vscode.workspace.workspaceFolders) {
3939
return Promise.resolve([]);
4040
}
4141

4242
const projectFiles = await vscode.workspace.findFiles(
43-
/*include*/ '{**/*.sln,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
43+
/*include*/ '{**/*.sln,**/*.slnx,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
4444
/*exclude*/ `{${omnisharpOptions.projectFilesExcludePattern}}`
4545
);
4646

@@ -63,12 +63,12 @@ export function resourcesToLaunchTargets(
6363
maxProjectResults: number
6464
): LaunchTarget[] {
6565
// The list of launch targets is calculated like so:
66-
// * If there are .csproj files, .sln and .slnf files are considered as launch targets.
66+
// * If there are .csproj files, .sln, .slnx, and .slnf files are considered as launch targets.
6767
// * Additionally, if there are .csproj files, but no .sln or .slnf file, the root is added as a launch target.
6868
//
6969
// TODO:
7070
// * It should be possible to choose a .csproj as a launch target
71-
// * It should be possible to choose a .sln or .slnf file even when no .csproj files are found
71+
// * It should be possible to choose a .sln, .slnx, or .slnf file even when no .csproj files are found
7272
// within the root.
7373

7474
if (resources.length === 0) {
@@ -129,7 +129,7 @@ export function resourcesAndFolderMapToLaunchTargets(
129129
const folderPath = folder.uri.fsPath;
130130

131131
resources.forEach((resource) => {
132-
// Add .sln and .slnf files
132+
// Add .sln, .slnx, and .slnf files
133133
if (isSolution(resource)) {
134134
solutionTargets.push(createLaunchTargetForSolution(resource));
135135
}
@@ -161,7 +161,7 @@ export function resourcesAndFolderMapToLaunchTargets(
161161
const hasSlnFile = solutionTargets.length > 0;
162162

163163
// Add the root folder under the following circumstances:
164-
// * If there are .csproj files, but no .sln or .slnf file, and none in the root.
164+
// * If there are .csproj files, but no .sln, .slnx, or .slnf file, and none in the root.
165165
if (hasCsProjFiles && !hasSlnFile) {
166166
projectRootTargets.push({
167167
label: path.basename(folderPath),
@@ -224,7 +224,7 @@ function isCSharpProject(resource: vscode.Uri): boolean {
224224
}
225225

226226
function isSolution(resource: vscode.Uri): boolean {
227-
return /\.slnf?$/i.test(resource.fsPath);
227+
return /\.sln[xf]?$/i.test(resource.fsPath);
228228
}
229229

230230
function isCsx(resource: vscode.Uri): boolean {

src/omnisharp/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,12 @@ export class OmniSharpServer {
677677
const launchTargets = await findLaunchTargets();
678678

679679
// If there aren't any potential launch targets, we create file watcher and try to
680-
// start the server again once a *.sln, *.slnf, *.csproj, CSX or Cake file is created.
680+
// start the server again once a *.sln, *.slnx, *.slnf, *.csproj, CSX or Cake file is created.
681681
if (launchTargets.length === 0) {
682682
await new Promise<void>((resolve) => {
683683
// 1st watch for files
684684
const watcher = this.vscode.workspace.createFileSystemWatcher(
685-
'{**/*.sln,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
685+
'{**/*.sln,**/*.slnx,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
686686
/*ignoreCreateEvents*/ false,
687687
/*ignoreChangeEvents*/ true,
688688
/*ignoreDeleteEvents*/ true

test-plan.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ See [OmniSharp Options](https://github.com/dotnet/vscode-csharp/blob/main/test-p
1414
All the validations below should be performed on both Windows and at least one Unix platform (MacOS, Linux). These can be done on x64 versions unless there are ARM specific changes to validate.
1515

1616
#### Opening projects
17-
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.
17+
When you open a directory in VS Code, the C# extension should look for a .csproj, .sln, .slnx, 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.
1818
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
1919

2020
Project types to test:
2121
* Standalone csproj
22-
* Directory containing .sln or .slnf file that references csprojs--projects should be loaded
22+
* Directory containing .sln, .slnx, or .slnf file that references csprojs--projects should be loaded
2323
* .NET Core/.NET Standard csproj
2424
* (Windows) Desktop .NET projects
2525
* Unity projects
26-
* A directory containing a .cs file without a csproj/sln. As stated above, intellisense should appear only when a change is made to the file.
26+
* A directory containing a .cs file without a csproj/sln/slnx. As stated above, intellisense should appear only when a change is made to the file.
2727

2828
The easist way to verify that a project was successfully loaded is to open a .cs file within it and verify that the references codelens indicator appears.
2929

0 commit comments

Comments
 (0)