Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A [Visual Studio Code](https://code.visualstudio.com/) [extension](https://marke
While it is possible to use the C# extension as a standalone extension, we highly recommend using [C# Dev Kit][csdevkitextension].

1. Installing [C# Dev Kit][csdevkitextension] will automatically install this extension as a required dependency.
2. Open a folder/workspace that contains a C# project (.csproj) and a C# solution (.sln) and the extension will activate.
2. Open a folder/workspace that contains a C# project (.csproj) and a C# solution (.sln/.slnx) and the extension will activate.
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.

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).
Expand Down
2 changes: 1 addition & 1 deletion src/lsptoolshost/server/roslynLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class RoslynLanguageServer {
await this.openSolution(vscode.Uri.file(defaultSolution));
} else {
// 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.
const solutionUris = await vscode.workspace.findFiles('**/*.sln', '**/node_modules/**', 2);
const solutionUris = await vscode.workspace.findFiles('**/*.slnx?', '**/node_modules/**', 2);
if (solutionUris) {
if (solutionUris.length === 1) {
await this.openSolution(solutionUris[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/lsptoolshost/workspace/workspaceCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function openSolution(languageServer: RoslynLanguageServer): Promise<vscod
return undefined;
}

const solutionFiles = await vscode.workspace.findFiles('**/*.{sln,slnf}');
const solutionFiles = await vscode.workspace.findFiles('**/*.{sln,slnx,slnf}');
const launchTargets = solutionFiles.map(createLaunchTargetForSolution);
const launchTarget = await vscode.window.showQuickPick(launchTargets, {
matchOnDescription: true,
Expand Down
16 changes: 8 additions & 8 deletions src/omnisharp/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export const disabledSchemes = new Set([vsls]);

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

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

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

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

resources.forEach((resource) => {
// Add .sln and .slnf files
// Add .sln, .slnx, and .slnf files
if (isSolution(resource)) {
solutionTargets.push(createLaunchTargetForSolution(resource));
}
Expand Down Expand Up @@ -161,7 +161,7 @@ export function resourcesAndFolderMapToLaunchTargets(
const hasSlnFile = solutionTargets.length > 0;

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

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

function isCsx(resource: vscode.Uri): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,12 @@ export class OmniSharpServer {
const launchTargets = await findLaunchTargets();

// If there aren't any potential launch targets, we create file watcher and try to
// start the server again once a *.sln, *.slnf, *.csproj, CSX or Cake file is created.
// start the server again once a *.sln, *.slnx, *.slnf, *.csproj, CSX or Cake file is created.
if (launchTargets.length === 0) {
await new Promise<void>((resolve) => {
// 1st watch for files
const watcher = this.vscode.workspace.createFileSystemWatcher(
'{**/*.sln,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
'{**/*.sln,**/*.slnx,**/*.slnf,**/*.csproj,**/*.csx,**/*.cake}',
/*ignoreCreateEvents*/ false,
/*ignoreChangeEvents*/ true,
/*ignoreDeleteEvents*/ true
Expand Down
6 changes: 3 additions & 3 deletions test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ See [OmniSharp Options](https://github.com/dotnet/vscode-csharp/blob/main/test-p
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.

#### Opening projects
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.
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.
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

Project types to test:
* Standalone csproj
* Directory containing .sln or .slnf file that references csprojs--projects should be loaded
* Directory containing .sln, .slnx, or .slnf file that references csprojs--projects should be loaded
* .NET Core/.NET Standard csproj
* (Windows) Desktop .NET projects
* Unity projects
* 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.
* 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.

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.

Expand Down