Skip to content

Commit

Permalink
Merge pull request #4431 from JoeRobich/improve-invalid-mono-error
Browse files Browse the repository at this point in the history
Give more information when Mono is missing or invalid.
  • Loading branch information
JoeRobich authored Mar 8, 2021
2 parents 0ac831b + 2dab57f commit 0409d32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@
],
"default": null,
"scope": "machine",
"description": "Specifies the path to a mono installation to use when \"useGlobalMono\" is set to \"always\" or \"auto\", instead of the default system one."
"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\""
},
"omnisharp.waitForDebugger": {
"type": "boolean",
Expand Down Expand Up @@ -3666,4 +3666,4 @@
]
}
}
}
}
12 changes: 10 additions & 2 deletions src/omnisharp/OmniSharpMonoResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ export class OmniSharpMonoResolver implements IMonoResolver {

public async getGlobalMonoInfo(options: Options): Promise<MonoInformation> {
let monoInfo = await this.configureEnvironmentAndGetInfo(options);
let isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`);

let isMissing = monoInfo.version === undefined;
if (isMissing) {
const suggestedAction = options.monoPath
? "Update the \"omnisharp.monoPath\" setting to point to the folder containing Mono's '/bin' folder."
: "Ensure that Mono's '/bin' folder is added to your environment's PATH variable.";
throw new Error(`Unable to find Mono. ${suggestedAction}`);
}

let isValid = monoInfo.version && satisfies(monoInfo.version, `>=${this.minimumMonoVersion}`);
if (options.useGlobalMono === "always") {
if (!isValid) {
throw new Error(`Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`);
throw new Error(`Found Mono version ${monoInfo.version}. Cannot start OmniSharp because Mono version >=${this.minimumMonoVersion} is required.`);
}

return monoInfo;
Expand Down

0 comments on commit 0409d32

Please sign in to comment.