Skip to content

Commit f88b1a7

Browse files
Merge pull request #2254 from OmniSharp/master
Merge master into release
2 parents 81df57c + 2ae1efa commit f88b1a7

19 files changed

+337
-186
lines changed

CHANGELOG.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,36 @@
1919
* Fixes async call stacks with the .NET Core 2.1 runtime. ([#1892](https://github.com/OmniSharp/omnisharp-vscode/issues/1892))
2020
* Fixes the debugger's browser launch code when launching projects configured to use Application Insights. ([2177](https://github.com/OmniSharp/omnisharp-vscode/issues/2177))
2121

22-
#### Specify OmniSharp Version
23-
Enables the use of pre-release builds of Omnisharp. Downloading a pre-release build of Omnisharp allows the C# extension for VS Code to use features that have been merged into the "master" branch of omnisharp-roslyn(https://github.com/OmniSharp/omnisharp-roslyn) but that have not been officially released
24-
* Adds support to use the "omnisharp.path" option to download a specific copy of OmniSharp. The possible values for this option are:
25-
* `<Path to the omnisharp executable>` - Use a local copy of OmniSharp. The value must point to a directory which contains OmniSharp, typically a user's build output directory for the OmniSharp-Roslyn project. Example: C:\omnisharp-roslyn\artifacts\publish\OmniSharp.Stdio\win7-x64\OmniSharp.exe.
26-
* `latest` - Use the latest CI build
27-
* `<version>` - Use a specific version of OmniSharp. Example: `1.29.2-beta.60`
22+
#### Options
2823

29-
#### Editor
24+
* "omnisharp.path": This option has been updated to enable the user to specify different versions of OmniSharp, including prerelease versions. ([#1909](https://github.com/OmniSharp/omnisharp-vscode/issues/1909), PR: [#2039](https://github.com/OmniSharp/omnisharp-vscode/pull/2039))
25+
26+
Possible values for this option are:
27+
* `<Path to the omnisharp executable>`: Use a local copy of OmniSharp. The value must point directly to the OmniSharp executable. This is typically the build output directory of the [omnisharp-roslyn](https://github.com/OmniSharp/omnisharp-roslyn) project on the current machine, for example, `C:/omnisharp-roslyn/artifacts/publish/OmniSharp.Stdio/win7-x64/OmniSharp.exe`.
28+
* `latest`: Use the latest CI build from [omnisharp-roslyn](https://github.com/OmniSharp/omnisharp-roslyn).
29+
* `<version>`: Use a specific version of OmniSharp. Example: `1.29.2-beta.60`
30+
If "omnisharp.path" is not set, the defalut version of OmniSharp for the current release of C# for VS Code is used.
31+
32+
* "omnisharp.useGlobalMono": This option replaces the old "omnisharp.useMono" option and controls whether or not OmniSharp will be launched with a globally-installed version of Mono. (PR: [#2244](https://github.com/OmniSharp/omnisharp-vscode/pull/2244))
3033

31-
* Splits the OmniSharp status bar item into two parts, both of which appear on the left and have specific responsibilities. ([#2146](https://github.com/OmniSharp/omnisharp-vscode/issues/2146), PR: [@2133](https://github.com/OmniSharp/omnisharp-vscode/pull/2133))
32-
* OmniSharp server status bar item - Shows the various stages that the OmniSharp server initialization might be in (eg: Downloading, Installing, etc). The flame icon is green when the server is initialized and running properly, or red if there is an error.
33-
* Project Information status bar item -
34-
* Displays the name of the selected project regardless of the currently active document.
35-
* If a project is already selected, it displays the name of the selected project. Clicking on it displays a menu to switch to other projects in the workspace.
34+
There are three possible values:
35+
* "auto": Automatically launch OmniSharp with `mono` if version 5.2.0 or greater is available on the PATH.
36+
* "always": Always launch OmniSharp with `mono`. If version 5.2.0 or greater is not available on the PATH, an error will be printed.
37+
* "never": Never launch OmniSharp on a globally-installed Mono.
38+
39+
#### Status Bar
40+
41+
* Splits the OmniSharp status bar item into two parts, both of which appear on the left side of VS Code's status bar and have specific responsibilities. ([#2146](https://github.com/OmniSharp/omnisharp-vscode/issues/2146), PR: [#2133](https://github.com/OmniSharp/omnisharp-vscode/pull/2133))
42+
* OmniSharp Server info:
43+
* Displays the current state of the OmniSharp server, such as Downloading, Installing, etc. The flame icon is green when the server is initialized and running properly, or red if there is an error.
44+
* Selected Project info:
45+
* Displays the name of the selected project regardless of the currently active document.
46+
* If a project is already selected, it displays the name of the selected project. Clicking on it displays a menu to switch to other projects in the workspace.
3647
* If there are multiple possible launch targets, it displays 'Select Project'. Clicking on it displays a menu to select one.
3748

3849
#### Misc
39-
* Enables suppressing the "some projects had trouble loading" popup using the `omnisharp.disableMsBuildDiagnosticWarning` option ([#2110]https://github.com/OmniSharp/omnisharp-vscode/issues/2110)
50+
51+
* Enables suppressing the "Some projects have trouble loading" popup using the `omnisharp.disableMSBuildDiagnosticWarning` option ([#2110]https://github.com/OmniSharp/omnisharp-vscode/issues/2110)
4052

4153
## 1.14.0 (February 14, 2018)
4254

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,20 @@
521521
"default": null,
522522
"description": "Specifies the path to OmniSharp. This can be the absolute path to an OmniSharp executable, a specific version number, or \"latest\". If a version number or \"latest\" is specified, the appropriate version of OmniSharp will be downloaded on your behalf."
523523
},
524-
"omnisharp.useMono": {
525-
"type": "boolean",
526-
"default": false,
527-
"description": "Launch OmniSharp with Mono."
524+
"omnisharp.useGlobalMono": {
525+
"type": "string",
526+
"default": "auto",
527+
"enum": [
528+
"auto",
529+
"always",
530+
"never"
531+
],
532+
"enumDescriptions": [
533+
"Automatically launch OmniSharp with \"mono\" if version 5.2.0 or greater is available on the PATH.",
534+
"Always launch OmniSharp with \"mono\". If version 5.2.0 or greater is not available on the PATH, an error will be printed.",
535+
"Never launch OmniSharp on a globally-installed Mono."
536+
],
537+
"description": "Launch OmniSharp with the globally-installed Mono. If set to \"always\", \"mono\" version 5.2.0 or greater must be available on the PATH. If set to \"auto\", OmniSharp will be launched with \"mono\" if version 5.2.0 or greater is available on the PATH."
528538
},
529539
"omnisharp.waitForDebugger": {
530540
"type": "boolean",

src/features/codeActionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class CodeActionProvider extends AbstractProvider implements vsco
3232
}
3333

3434
private _resetCachedOptions(): void {
35-
this._options = Options.Read();
35+
this._options = Options.Read(vscode);
3636
}
3737

3838
public async provideCodeActions(document: vscode.TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): Promise<vscode.Command[]> {

src/features/codeLensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
3939
}
4040

4141
private _resetCachedOptions(): void {
42-
this._options = Options.Read();
42+
this._options = Options.Read(vscode);
4343
}
4444

4545
private static filteredSymbolNames: { [name: string]: boolean } = {

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
6161
eventStream.subscribe(omnisharpLogObserver.post);
6262
eventStream.subscribe(omnisharpChannelObserver.post);
6363

64-
let warningMessageObserver = new WarningMessageObserver(vscode, () => Options.Read().disableMSBuildDiagnosticWarning || false);
64+
let warningMessageObserver = new WarningMessageObserver(vscode, () => Options.Read(vscode).disableMSBuildDiagnosticWarning || false);
6565
eventStream.subscribe(warningMessageObserver.post);
6666

6767
let informationMessageObserver = new InformationMessageObserver(vscode);

src/omnisharp/OmnisharpDownloader.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as fs from 'fs';
76
import { GetPackagesFromVersion } from './OmnisharpPackageCreator';
87
import { PlatformInformation } from '../platform';
98
import { PackageInstallation, LogPlatformInfo, InstallationSuccess, InstallationFailure, LatestBuildDownloadStart } from './loggingEvents';
109
import { EventStream } from '../EventStream';
1110
import { NetworkSettingsProvider } from '../NetworkSettings';
1211
import { DownloadAndInstallPackages } from '../packageManager/PackageManager';
13-
import { CreateTmpFile, TmpAsset } from '../CreateTmpAsset';
1412
import { DownloadFile } from '../packageManager/FileDownloader';
1513
import { ResolveFilePaths } from '../packageManager/PackageFilePathResolver';
1614

@@ -43,23 +41,16 @@ export class OmnisharpDownloader {
4341
}
4442

4543
public async GetLatestVersion(serverUrl: string, latestVersionFileServerPath: string): Promise<string> {
46-
let description = "Latest Omnisharp Version Information";
44+
let description = "Latest OmniSharp Version Information";
4745
let url = `${serverUrl}/${latestVersionFileServerPath}`;
48-
let tmpFile: TmpAsset;
4946
try {
5047
this.eventStream.post(new LatestBuildDownloadStart());
51-
tmpFile = await CreateTmpFile();
52-
await DownloadFile(tmpFile.fd, description, this.eventStream, this.networkSettingsProvider, url);
53-
return fs.readFileSync(tmpFile.name, 'utf8');
48+
let versionBuffer = await DownloadFile(description, this.eventStream, this.networkSettingsProvider, url);
49+
return versionBuffer.toString('utf8');
5450
}
5551
catch (error) {
5652
this.eventStream.post(new InstallationFailure('getLatestVersionInfoFile', error));
5753
throw error;
5854
}
59-
finally {
60-
if (tmpFile) {
61-
tmpFile.dispose();
62-
}
63-
}
6455
}
6556
}

src/omnisharp/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function activate(context: vscode.ExtensionContext, eventStream: Ev
4343
scheme: 'file' // only files from disk
4444
};
4545

46-
const options = Options.Read();
46+
const options = Options.Read(vscode);
4747
const server = new OmniSharpServer(vscode, provider, eventStream, packageJSON, platformInfo);
4848
omnisharp = server;
4949
const advisor = new Advisor(server); // create before server is started

src/omnisharp/launcher.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function findLaunchTargets(): Thenable<LaunchTarget[]> {
4141
return Promise.resolve([]);
4242
}
4343

44-
const options = Options.Read();
44+
const options = Options.Read(vscode);
4545

4646
return vscode.workspace.findFiles(
4747
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
@@ -204,9 +204,9 @@ export interface LaunchResult {
204204
monoVersion?: string;
205205
}
206206

207-
export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation): Promise<LaunchResult> {
207+
export async function launchOmniSharp(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation, options: Options): Promise<LaunchResult> {
208208
return new Promise<LaunchResult>((resolve, reject) => {
209-
launch(cwd, args, launchInfo, platformInfo)
209+
launch(cwd, args, launchInfo, platformInfo, options)
210210
.then(result => {
211211
// async error - when target not not ENEOT
212212
result.process.on('error', err => {
@@ -222,9 +222,7 @@ export async function launchOmniSharp(cwd: string, args: string[], launchInfo: L
222222
});
223223
}
224224

225-
async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation): Promise<LaunchResult> {
226-
const options = Options.Read();
227-
225+
async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platformInfo: PlatformInformation, options: Options): Promise<LaunchResult> {
228226
if (options.useEditorFormattingSettings) {
229227
let globalConfig = vscode.workspace.getConfiguration();
230228
let csharpConfig = vscode.workspace.getConfiguration('[csharp]');
@@ -242,16 +240,18 @@ async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platf
242240
let isValidMonoAvailable = await satisfies(monoVersion, '>=5.2.0');
243241

244242
// If the user specifically said that they wanted to launch on Mono, respect their wishes.
245-
if (options.useMono) {
243+
if (options.useGlobalMono === "always") {
246244
if (!isValidMonoAvailable) {
247245
throw new Error('Cannot start OmniSharp because Mono version >=5.2.0 is required.');
248246
}
249247

250-
return launchNixMono(launchInfo.LaunchPath, monoVersion, cwd, args);
248+
const launchPath = launchInfo.MonoLaunchPath || launchInfo.LaunchPath;
249+
250+
return launchNixMono(launchPath, monoVersion, cwd, args);
251251
}
252252

253253
// If we can launch on the global Mono, do so; otherwise, launch directly;
254-
if (isValidMonoAvailable && launchInfo.MonoLaunchPath) {
254+
if (options.useGlobalMono === "auto" && isValidMonoAvailable && launchInfo.MonoLaunchPath) {
255255
return launchNixMono(launchInfo.MonoLaunchPath, monoVersion, cwd, args);
256256
}
257257
else {

src/omnisharp/options.ts

Lines changed: 64 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,43 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as vscode from 'vscode';
6+
import { vscode, WorkspaceConfiguration } from '../vscodeAdapter';
77

88
export class Options {
99
constructor(
10-
public path?: string,
11-
public useMono?: boolean,
12-
public waitForDebugger?: boolean,
13-
public loggingLevel?: string,
14-
public autoStart?: boolean,
15-
public projectLoadTimeout?: number,
16-
public maxProjectResults?: number,
17-
public useEditorFormattingSettings?: boolean,
18-
public useFormatting?: boolean,
19-
public showReferencesCodeLens?: boolean,
20-
public showTestsCodeLens?: boolean,
21-
public disableCodeActions?: boolean,
22-
public disableMSBuildDiagnosticWarning?: boolean) { }
23-
24-
public static Read(): Options {
10+
public path: string,
11+
public useGlobalMono: string,
12+
public waitForDebugger: boolean,
13+
public loggingLevel: string,
14+
public autoStart: boolean,
15+
public projectLoadTimeout: number,
16+
public maxProjectResults: number,
17+
public useEditorFormattingSettings: boolean,
18+
public useFormatting: boolean,
19+
public showReferencesCodeLens: boolean,
20+
public showTestsCodeLens: boolean,
21+
public disableCodeActions: boolean,
22+
public disableMSBuildDiagnosticWarning: boolean) { }
23+
24+
public static Read(vscode: vscode): Options {
2525
// Extra effort is taken below to ensure that legacy versions of options
2626
// are supported below. In particular, these are:
2727
//
2828
// - "csharp.omnisharp" -> "omnisharp.path"
2929
// - "csharp.omnisharpUsesMono" -> "omnisharp.useMono"
30+
// - "omnisharp.useMono" -> "omnisharp.useGlobalMono"
3031

3132
const omnisharpConfig = vscode.workspace.getConfiguration('omnisharp');
3233
const csharpConfig = vscode.workspace.getConfiguration('csharp');
3334

34-
const path = csharpConfig.has('omnisharp')
35-
? csharpConfig.get<string>('omnisharp')
36-
: omnisharpConfig.get<string>('path');
37-
38-
const useMono = csharpConfig.has('omnisharpUsesMono')
39-
? csharpConfig.get<boolean>('omnisharpUsesMono')
40-
: omnisharpConfig.get<boolean>('useMono');
35+
const path = Options.readPathOption(csharpConfig, omnisharpConfig);
36+
const useGlobalMono = Options.readUseGlobalMonoOption(omnisharpConfig, csharpConfig);
4137

4238
const waitForDebugger = omnisharpConfig.get<boolean>('waitForDebugger', false);
4339

4440
// support the legacy "verbose" level as "debug"
45-
let loggingLevel = omnisharpConfig.get<string>('loggingLevel');
46-
if (loggingLevel.toLowerCase() === 'verbose') {
41+
let loggingLevel = omnisharpConfig.get<string>('loggingLevel', 'information');
42+
if (loggingLevel && loggingLevel.toLowerCase() === 'verbose') {
4743
loggingLevel = 'debug';
4844
}
4945

@@ -60,10 +56,11 @@ export class Options {
6056

6157
const disableCodeActions = csharpConfig.get<boolean>('disableCodeActions', false);
6258

63-
const disableMSBuildDiagnosticWarning = omnisharpConfig.get<boolean>('disableMSBuildDiagnosticWarning');
59+
const disableMSBuildDiagnosticWarning = omnisharpConfig.get<boolean>('disableMSBuildDiagnosticWarning', false);
6460

65-
return new Options(path,
66-
useMono,
61+
return new Options(
62+
path,
63+
useGlobalMono,
6764
waitForDebugger,
6865
loggingLevel,
6966
autoStart,
@@ -76,4 +73,43 @@ export class Options {
7673
disableCodeActions,
7774
disableMSBuildDiagnosticWarning);
7875
}
76+
77+
private static readPathOption(csharpConfig: WorkspaceConfiguration, omnisharpConfig: WorkspaceConfiguration): string | null {
78+
if (omnisharpConfig.has('path')) {
79+
// If 'omnisharp.path' setting was found, use it.
80+
return omnisharpConfig.get<string>('path');
81+
}
82+
else if (csharpConfig.has('omnisharp')) {
83+
// BACKCOMPAT: If 'csharp.omnisharp' setting was found, use it.
84+
return csharpConfig.get<string>('omnisharp');
85+
}
86+
else {
87+
// Otherwise, null.
88+
return null;
89+
}
90+
}
91+
92+
private static readUseGlobalMonoOption(omnisharpConfig: WorkspaceConfiguration, csharpConfig: WorkspaceConfiguration): string {
93+
function toUseGlobalMonoValue(value: boolean): string {
94+
// True means 'always' and false means 'auto'.
95+
return value ? "always" : "auto";
96+
}
97+
98+
if (omnisharpConfig.has('useGlobalMono')) {
99+
// If 'omnisharp.useGlobalMono' setting was found, just use it.
100+
return omnisharpConfig.get<string>('useGlobalMono', "auto");
101+
}
102+
else if (omnisharpConfig.has('useMono')) {
103+
// BACKCOMPAT: If 'omnisharp.useMono' setting was found, true maps to "always" and false maps to "auto"
104+
return toUseGlobalMonoValue(omnisharpConfig.get<boolean>('useMono'));
105+
}
106+
else if (csharpConfig.has('omnisharpUsesMono')) {
107+
// BACKCOMPAT: If 'csharp.omnisharpUsesMono' setting was found, true maps to "always" and false maps to "auto"
108+
return toUseGlobalMonoValue(csharpConfig.get<boolean>('omnisharpUsesMono'));
109+
}
110+
else {
111+
// Otherwise, the default value is "auto".
112+
return "auto";
113+
}
114+
}
79115
}

0 commit comments

Comments
 (0)