Skip to content

Commit 5e3588c

Browse files
authored
Make SDK build of OmniSharp the default (#5176)
* Make SDK build of OmniSharp the default * Move to new testing npm package * Install NET 6 SDK in CI
1 parent a1e98f9 commit 5e3588c

21 files changed

+124
-343
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ indent_size = 4
1010
trim_trailing_whitespace = true
1111

1212
# 2 space indentation and utf-8 for *.yml, package.json, and .json files under src
13-
[{*.yml,package.json,src/**/*.json}]
13+
[{*.yml,package.json,*.json}]
1414
indent_size = 2
1515
charset = utf-8

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
- name: Setup virtual display
1919
run: /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
2020

21-
- name: Install .NET Core 5.0 SDK
21+
- name: Install .NET Core 6.0 SDK
2222
uses: actions/[email protected]
2323
with:
24-
dotnet-version: 5.0.x
24+
dotnet-version: 6.0.x
2525

2626
- name: Install Node.js 15.x
2727
uses: actions/setup-node@v1

package-lock.json

Lines changed: 54 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"@types/unzipper": "^0.9.1",
9898
"@types/vscode": "1.65.0",
9999
"@types/yauzl": "2.9.1",
100+
"@vscode/test-electron": "2.1.3",
100101
"archiver": "5.3.0",
101102
"chai": "4.3.4",
102103
"chai-arrays": "2.2.0",
@@ -121,7 +122,6 @@
121122
"typescript": "4.2.4",
122123
"unzipper": "0.10.11",
123124
"vsce": "1.100.2",
124-
"vscode-test": "1.6.1",
125125
"webpack": "5.34.0",
126126
"webpack-cli": "4.6.0"
127127
},
@@ -921,30 +921,15 @@
921921
},
922922
"omnisharp.useModernNet": {
923923
"type": "boolean",
924-
"default": false,
924+
"default": true,
925925
"scope": "window",
926-
"title": "Use .NET 6 build of OmniSharp (experimental)",
927-
"description": "Use OmniSharp build for .NET 6. This version _does not_ support non-SDK-style .NET Framework projects, including Unity. SDK-style Framework, .NET Core, and .NET 5+ projects should see significant performance improvements, but there may still be bugs. Please open issues if you find any bugs."
928-
},
929-
"omnisharp.useGlobalMono": {
930-
"type": "string",
931-
"default": "auto",
932-
"enum": [
933-
"auto",
934-
"always",
935-
"never"
936-
],
937-
"enumDescriptions": [
938-
"Automatically launch OmniSharp with internal \"mono\", since \"mono\" 6.12.0 does not support .NET Core 3.1.40x or .NET 5 SDKs.",
939-
"Always launch OmniSharp with \"mono\". If version 6.4.0 or greater is not available on the PATH, an error will be printed.",
940-
"Never launch OmniSharp on a globally-installed Mono."
941-
],
942-
"description": "Launch OmniSharp with the globally-installed Mono. If set to \"always\", \"mono\" version 6.4.0 or greater must be available on the PATH. If set to \"auto\", OmniSharp will be launched with \"mono\" if version 6.4.0 or greater is available on the PATH."
926+
"title": "Use .NET 6 build of OmniSharp",
927+
"description": "Use OmniSharp build for .NET 6. This version _does not_ support non-SDK-style .NET Framework projects, including Unity. SDK-style Framework, .NET Core, and .NET 5+ projects should see significant performance improvements."
943928
},
944929
"omnisharp.monoPath": {
945930
"type": "string",
946931
"scope": "machine",
947-
"description": "Specifies the path to a mono installation to use when \"useGlobalMono\" is set to \"always\", instead of the default system one. Example: \"/Library/Frameworks/Mono.framework/Versions/Current\""
932+
"description": "Specifies the path to a mono installation to use when \"useModernNet\" is set to false, instead of the default system one. Example: \"/Library/Frameworks/Mono.framework/Versions/Current\""
948933
},
949934
"omnisharp.dotnetPath": {
950935
"type": "string",

src/features/reportIssue.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ async function getMonoIfPlatformValid(isValidPlatformForMono: boolean, options:
8585
if (isValidPlatformForMono) {
8686
let monoVersion: string;
8787
try {
88-
let globalMonoInfo = await monoResolver.getHostExecutableInfo(options);
89-
if (globalMonoInfo) {
90-
monoVersion = `OmniSharp using global mono :${globalMonoInfo.version}`;
91-
}
92-
else {
93-
monoVersion = `OmniSharp using built-in mono`;
88+
let monoInfo = await monoResolver.getHostExecutableInfo(options);
89+
if (monoInfo) {
90+
monoVersion = `OmniSharp using mono :${monoInfo.version}`;
9491
}
9592
}
9693
catch (error) {

src/observers/OmnisharpLoggerObserver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class OmnisharpLoggerObserver extends BaseLoggerObserver {
5858
this.logger.append(`OmniSharp server started`);
5959
if (event.hostVersion) {
6060
this.logger.append(` with ${event.hostIsMono ? 'Mono' : '.NET'} ${event.hostVersion}`);
61-
if (event.hostPath !== undefined) {
61+
if (event.hostPath?.length > 0) {
6262
this.logger.append(` (${event.hostPath})`);
6363
}
6464
}

src/observers/OptionChangeObserver.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ type OptionsKey = keyof Options;
1414

1515
const omniSharpOptions: ReadonlyArray<OptionsKey> = [
1616
"path",
17-
"useGlobalMono",
1817
"enableMsBuildLoadProjectsOnDemand",
1918
"waitForDebugger",
2019
"loggingLevel",

src/omnisharp/OmniSharpMonoResolver.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ export class OmniSharpMonoResolver implements IHostExecutableResolver {
1717
}
1818

1919
private async configureEnvironmentAndGetInfo(options: Options): Promise<HostExecutableInformation> {
20-
let env = { ...process.env };
20+
const env = { ...process.env };
2121
let monoPath: string;
22-
if (options.useGlobalMono !== "never" && options.monoPath.length > 0) {
22+
23+
if (options.monoPath.length > 0) {
2324
env['PATH'] = path.join(options.monoPath, 'bin') + path.delimiter + env['PATH'];
2425
env['MONO_GAC_PREFIX'] = options.monoPath;
2526
monoPath = options.monoPath;
2627
}
2728

28-
let version = await this.getMonoVersion(env);
29+
const version = await this.getMonoVersion(env);
2930

3031
return {
3132
version,
@@ -35,29 +36,21 @@ export class OmniSharpMonoResolver implements IHostExecutableResolver {
3536
}
3637

3738
public async getHostExecutableInfo(options: Options): Promise<HostExecutableInformation> {
38-
let monoInfo = await this.configureEnvironmentAndGetInfo(options);
39-
let isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`);
40-
if (options.useGlobalMono === "always") {
41-
let isMissing = monoInfo.version === undefined;
42-
if (isMissing) {
43-
const suggestedAction = options.monoPath.length > 0
44-
? "Update the \"omnisharp.monoPath\" setting to point to the folder containing Mono's '/bin' folder."
45-
: "Ensure that Mono's '/bin' folder is added to your environment's PATH variable.";
46-
throw new Error(`Unable to find Mono. ${suggestedAction}`);
47-
}
48-
49-
if (!isValid) {
50-
throw new Error(`Found Mono version ${monoInfo.version}. Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`);
51-
}
52-
53-
return monoInfo;
39+
const monoInfo = await this.configureEnvironmentAndGetInfo(options);
40+
const isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`);
41+
42+
const isMissing = monoInfo.version === undefined;
43+
if (isMissing) {
44+
const suggestedAction = options.monoPath
45+
? "Update the \"omnisharp.monoPath\" setting to point to the folder containing Mono's '/bin' folder."
46+
: "Ensure that Mono's '/bin' folder is added to your environment's PATH variable.";
47+
throw new Error(`Unable to find Mono. ${suggestedAction}`);
5448
}
55-
else if (options.useGlobalMono === "auto" && isValid) {
56-
// While waiting for Mono to ship with a MSBuild version 16.8 or higher, we will treat "auto"
57-
// as "Use included Mono".
58-
// return monoInfo;
49+
50+
if (!isValid) {
51+
throw new Error(`Found Mono version ${monoInfo.version}. Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`);
5952
}
6053

61-
return undefined;
54+
return monoInfo;
6255
}
6356
}

src/omnisharp/launcher.ts

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -312,21 +312,7 @@ async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platf
312312
return launchWindows(launchInfo.LaunchPath, cwd, args);
313313
}
314314

315-
let monoInfo = await monoResolver.getHostExecutableInfo(options);
316-
317-
if (monoInfo) {
318-
const launchPath = launchInfo.MonoLaunchPath || launchInfo.LaunchPath;
319-
let childEnv = monoInfo.env;
320-
return {
321-
...launchNixMono(launchPath, cwd, args, childEnv, options.waitForDebugger),
322-
hostIsMono: true,
323-
hostVersion: monoInfo.version,
324-
hostPath: monoInfo.path
325-
};
326-
}
327-
else {
328-
return launchNix(launchInfo.LaunchPath, cwd, args);
329-
}
315+
return await launchNix(launchInfo, cwd, args, options, monoResolver);
330316
}
331317

332318
function getConfigurationValue(globalConfig: vscode.WorkspaceConfiguration, csharpConfig: vscode.WorkspaceConfiguration,
@@ -393,20 +379,20 @@ function launchWindows(launchPath: string, cwd: string, args: string[]): LaunchR
393379
};
394380
}
395381

396-
function launchNix(launchPath: string, cwd: string, args: string[]): LaunchResult {
397-
let process = spawn(launchPath, args, {
398-
detached: false,
399-
cwd: cwd
400-
});
382+
async function launchNix(launchInfo: LaunchInfo, cwd: string, args: string[], options: Options, monoResolver: IHostExecutableResolver): Promise<LaunchResult> {
383+
const monoInfo = await monoResolver.getHostExecutableInfo(options);
384+
const launchPath = launchInfo.MonoLaunchPath || launchInfo.LaunchPath;
401385

402386
return {
403-
process,
387+
process: launchNixMono(launchPath, cwd, args, monoInfo.env, options.waitForDebugger),
404388
command: launchPath,
405-
hostIsMono: false
389+
hostIsMono: true,
390+
hostVersion: monoInfo.version,
391+
hostPath: monoInfo.path
406392
};
407393
}
408394

409-
function launchNixMono(launchPath: string, cwd: string, args: string[], environment: NodeJS.ProcessEnv, useDebugger: boolean): LaunchResult {
395+
function launchNixMono(launchPath: string, cwd: string, args: string[], environment: NodeJS.ProcessEnv, useDebugger: boolean): ChildProcess {
410396
let argsCopy = args.slice(0); // create copy of details args
411397
argsCopy.unshift(launchPath);
412398
argsCopy.unshift("--assembly-loader=strict");
@@ -422,9 +408,5 @@ function launchNixMono(launchPath: string, cwd: string, args: string[], environm
422408
env: environment
423409
});
424410

425-
return {
426-
process,
427-
command: launchPath,
428-
hostIsMono: true
429-
};
411+
return process;
430412
}

0 commit comments

Comments
 (0)