Skip to content

Commit

Permalink
Set meaning of UseGlobalMono 'auto' to 'never'
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Aug 18, 2020
1 parent 3601445 commit 5a57303
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Register FixAll commands for disposal ([#3984](https://github.com/OmniSharp/omnisharp-vscode/issues/3984), PR: [#3985](https://github.com/OmniSharp/omnisharp-vscode/pull/3985))
* Include version matched target files with minimal MSBuild (PR: [omnisharp-roslyn#1895](https://github.com/OmniSharp/omnisharp-roslyn/pull/1895))
* Fix lack of trailing italics in quickinfo (PR: [omnisharp-roslyn#1894](https://github.com/OmniSharp/omnisharp-roslyn/pull/1894))
* Start moving omnisharp to directly using Roslyn's completion service (PR: [omnisharp-roslyn#1877](https://github.com/OmniSharp/omnisharp-roslyn/pull/1877))
* Set meaning of UseGlobalMono "auto" to "never" until Mono updates their MSBuild (PR: [#3998](https://github.com/OmniSharp/omnisharp-vscode/pull/3998))

## 1.23.0 (August 14, 2020)
* Fix typo in supressBuildAssetsNotification setting name ([#3941](https://github.com/OmniSharp/omnisharp-vscode/issues/3941), PR: [#3942](https://github.com/OmniSharp/omnisharp-vscode/pull/3942))
Expand Down
10 changes: 7 additions & 3 deletions src/omnisharp/OmniSharpMonoResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ export class OmniSharpMonoResolver implements IMonoResolver {

return monoInfo;
}
else if (options.useGlobalMono === "auto" && isValid) {
return monoInfo;
}

// While wwaiting for Mono to ship with a MSBuild version 16.7 or higher, we will treat "auto"
// as "Use included Mono".

// else if (options.useGlobalMono === "auto" && isValid) {
// return monoInfo;
//}

return undefined;
}
Expand Down
36 changes: 27 additions & 9 deletions test/unitTests/omnisharp/OmniSharpMonoResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
const requiredMonoVersion = "6.4.0";
const higherMonoVersion = "6.6.0";

// Sets the meaning of UseGlobalMono "auto". When false, "auto" means "never".
const autoMeansAlways = false;

const getMono = (version: string) => async (env: NodeJS.ProcessEnv) => {
getMonoCalled = true;
environment = env;
Expand Down Expand Up @@ -54,7 +57,7 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
expect(monoInfo).to.be.undefined;
});

test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and getGlobalMonoInfo is always`, async () => {
test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and useGlobalMono is always`, async () => {
let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion));
let monoInfo = await monoResolver.getGlobalMonoInfo({
...options,
Expand All @@ -66,16 +69,21 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
expect(monoInfo.path).to.be.equal(monoPath);
});

test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and getGlobalMonoInfo is auto`, async () => {
test(`it returns the path and version if the version is greater than or equal to ${requiredMonoVersion} and useGlobalMono is auto`, async () => {
let monoResolver = new OmniSharpMonoResolver(getMono(higherMonoVersion));
let monoInfo = await monoResolver.getGlobalMonoInfo({
...options,
useGlobalMono: "auto",
monoPath: monoPath
});

expect(monoInfo.version).to.be.equal(higherMonoVersion);
expect(monoInfo.path).to.be.equal(monoPath);
if (!autoMeansAlways) {
expect(monoInfo).to.be.undefined;
}
else {
expect(monoInfo.version).to.be.equal(higherMonoVersion);
expect(monoInfo.path).to.be.equal(monoPath);
}
});

test(`it throws exception if getGlobalMonoInfo is always and version<${requiredMonoVersion}`, async () => {
Expand All @@ -96,20 +104,30 @@ suite(`${OmniSharpMonoResolver.name}`, () => {
monoPath: monoPath
});

expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin'));
expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath);
if (!autoMeansAlways) {
expect(monoInfo).to.be.undefined;
}
else {
expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin'));
expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath);
}
});

test("sets the environment with the monoPath id useGlobalMono is always", async () => {
test("sets the environment with the monoPath id useGlobalMono is auto", async () => {
let monoResolver = new OmniSharpMonoResolver(getMono(requiredMonoVersion));
let monoInfo = await monoResolver.getGlobalMonoInfo({
...options,
useGlobalMono: "auto",
monoPath: monoPath
});

expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin'));
expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath);
if (!autoMeansAlways) {
expect(monoInfo).to.be.undefined;
}
else {
expect(monoInfo.env["PATH"]).to.contain(join(monoPath, 'bin'));
expect(monoInfo.env["MONO_GAC_PREFIX"]).to.be.equal(monoPath);
}
});

test("doesn't set the environment with the monoPath if useGlobalMono is never", async () => {
Expand Down

0 comments on commit 5a57303

Please sign in to comment.