Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using .NET 6 OmniSharp #4926

Merged
merged 7 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
140 changes: 135 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,27 @@
],
"installTestPath": "./.omnisharp/1.37.17/OmniSharp.exe",
"platformId": "win-x86",
"isFramework": true,
"integrity": "95ECBABF821ED45E4E6F3173E2165C5F593FC4611040475DBD6D54C16D78F4F8"
},
{
"id": "OmniSharp",
"description": "OmniSharp for Windows (.NET 6 / x86)",
"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"win32"
],
"architectures": [
"x86",
"arm64"
],
"installTestPath": null,
"platformId": "win-x86",
"isFramework": false,
"integrity": null
},
{
"id": "OmniSharp",
"description": "OmniSharp for Windows (.NET 4.6 / x64)",
Expand All @@ -154,11 +173,29 @@
],
"installTestPath": "./.omnisharp/1.37.17/OmniSharp.exe",
"platformId": "win-x64",
"isFramework": true,
"integrity": "BD81F1284FA4A9E6D63292074D0304B65CD39C24539CB761B54E8727619070DF"
},
{
"id": "OmniSharp",
"description": "OmniSharp for OSX",
"description": "OmniSharp for Windows (.NET 6 / x64)",
"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"win32"
],
"architectures": [
"x86_64"
],
"installTestPath": null,
"platformId": "win-x64",
"isFramework": false,
"integrity": null
},
{
"id": "OmniSharp",
"description": "OmniSharp for OSX (Mono)",
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/9f560aead2b823079775c00110972c04/omnisharp-osx-1.37.17.zip",
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-osx-1.37.17.zip",
"installPath": ".omnisharp/1.37.17",
Expand All @@ -171,11 +208,30 @@
],
"installTestPath": "./.omnisharp/1.37.17/run",
"platformId": "osx",
"isFramework": true,
"integrity": "43D6B18F390B8ED92231044E87413831E565E9AB5938223B19CA97B3628DDDF4"
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (x86)",
"description": "OmniSharp for OSX (.NET 6)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are missing a split into x64 and arm64 here

Copy link
Member

@JoeRobich JoeRobich Dec 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch. We don't have one currently, because we install the x64 for both architectures. Since the net6 builds are currently being built as self-contained this might cause issues. Certainly wouldn't perform as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added profiles for the other platforms. @filipw, can you give it a try on Mac?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through this list and updated our profiles based on it, from the beta83 publish of omnisharp-roslyn:

1.37.18-beta.83/omnisharp-win-x86.zip
1.37.18-beta.83/omnisharp-win-x86-net6.0.zip
1.37.18-beta.83/omnisharp-win-x64.zip
1.37.18-beta.83/omnisharp-win-x64-net6.0.zip
1.37.18-beta.83/omnisharp-win-arm64.zip
1.37.18-beta.83/omnisharp-win-arm64-net6.0.zip
1.37.18-beta.83/omnisharp-osx.zip
1.37.18-beta.83/omnisharp-osx.tar.gz
1.37.18-beta.83/omnisharp-osx-x64-net6.0.zip
1.37.18-beta.83/omnisharp-osx-x64-net6.0.tar.gz
1.37.18-beta.83/omnisharp-osx-arm64-net6.0.zip
1.37.18-beta.83/omnisharp-osx-arm64-net6.0.tar.gz
1.37.18-beta.83/omnisharp-mono.zip
1.37.18-beta.83/omnisharp-mono.tar.gz
1.37.18-beta.83/omnisharp-linux-x86.zip
1.37.18-beta.83/omnisharp-linux-x86.tar.gz
1.37.18-beta.83/omnisharp-linux-x64.zip
1.37.18-beta.83/omnisharp-linux-x64.tar.gz
1.37.18-beta.83/omnisharp-linux-x64-net6.0.zip
1.37.18-beta.83/omnisharp-linux-x64-net6.0.tar.gz
1.37.18-beta.83/omnisharp-linux-arm64.zip
1.37.18-beta.83/omnisharp-linux-arm64.tar.gz

"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"darwin"
],
"binaries": [
"./mono.osx",
"./run"
],
"installTestPath": null,
"platformId": "osx",
"isFramework": false,
"integrity": null
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (Mono, x86)",
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/6f3d66d4ffa4fa627225221fb00e106e/omnisharp-linux-x86-1.37.17.zip",
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-linux-x86-1.37.17.zip",
"installPath": ".omnisharp/1.37.17",
Expand All @@ -192,11 +248,34 @@
],
"installTestPath": "./.omnisharp/1.37.17/run",
"platformId": "linux-x86",
"isFramework": true,
"integrity": "75676E50D9FB62B9DC20A6A10E65420B54EFE2FFAE80AC21F59A4C483A4902BB"
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (x64)",
"description": "OmniSharp for Linux (.NET 6 x86)",
"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"linux"
],
"architectures": [
"x86",
"i686"
],
"binaries": [
"./mono.linux-x86",
"./run"
],
"installTestPath": null,
"platformId": "linux-x86",
"isFramework": false,
"integrity": null
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (Mono, x64)",
"url": "https://download.visualstudio.microsoft.com/download/pr/47df6cf8-7648-4fff-9e9c-304f0202d31c/6cf1b92d91f942929922013b2139cca9/omnisharp-linux-x64-1.37.17.zip",
"fallbackUrl": "https://roslynomnisharp.blob.core.windows.net/releases/1.37.17/omnisharp-linux-x64-1.37.17.zip",
"installPath": ".omnisharp/1.37.17",
Expand All @@ -212,11 +291,33 @@
],
"installTestPath": "./.omnisharp/1.37.17/run",
"platformId": "linux-x64",
"isFramework": true,
"integrity": "34276181B4C1F9968AFA10DEC058F6A2D79DE362FA01B565A04E879CA84A74FE"
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (arm64)",
"description": "OmniSharp for Linux (.NET 6, x64)",
"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"linux"
],
"architectures": [
"x86_64"
],
"binaries": [
"./mono.linux-x86_64",
"./run"
],
"installTestPath": null,
"platformId": "linux-x64",
"isFramework": false,
"integrity": null
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (Framework, arm64)",
"url": null,
"fallbackUrl": null,
"installPath": null,
Expand All @@ -232,7 +333,29 @@
],
"installTestPath": null,
"platformId": "linux-arm64",
"integrity": null
"integrity": null,
"isFramework": true
},
{
"id": "OmniSharp",
"description": "OmniSharp for Linux (.NET 6, arm64)",
"url": null,
"fallbackUrl": null,
"installPath": null,
"platforms": [
"linux"
],
"architectures": [
"arm64"
],
"binaries": [
"./mono.linux-arm64",
"./run"
],
"installTestPath": null,
"platformId": "linux-arm64",
"integrity": null,
"isFramework": false
},
{
"id": "Debugger",
Expand Down Expand Up @@ -742,6 +865,13 @@
"scope": "machine",
"description": "Specifies the path to OmniSharp. When left empty the OmniSharp version pinned to the C# Extension is used. 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. Setting \"latest\" is an opt-in into latest beta releases of OmniSharp."
},
"omnisharp.useModernNet": {
"type": "boolean",
"default": false,
"scope": "window",
"title": "Use .NET 6 build of OmniSharp (experimental)",
"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."
},
"omnisharp.useGlobalMono": {
"type": "string",
"default": "auto",
Expand Down
1 change: 1 addition & 0 deletions src/observers/OptionChangeObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const omniSharpOptions: ReadonlyArray<OptionsKey> = [
"enableImportCompletion",
"organizeImportsOnFormat",
"enableAsyncCompletion",
"useModernNet",
];

function OmniSharpOptionChangeObservable(optionObservable: Observable<Options>): Observable<Options> {
Expand Down
6 changes: 3 additions & 3 deletions src/omnisharp/OmnisharpDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export class OmnisharpDownloader {
private extensionPath: string) {
}

public async DownloadAndInstallOmnisharp(version: string, serverUrl: string, installPath: string): Promise<boolean> {
public async DownloadAndInstallOmnisharp(version: string, useFramework: boolean, serverUrl: string, installPath: string): Promise<boolean> {
let runtimeDependencies = getRuntimeDependenciesPackages(this.packageJSON);
let omniSharpPackages = GetPackagesFromVersion(version, runtimeDependencies, serverUrl, installPath);
let omniSharpPackages = GetPackagesFromVersion(version, useFramework, runtimeDependencies, serverUrl, installPath);
let packagesToInstall = await getAbsolutePathPackagesToInstall(omniSharpPackages, this.platformInfo, this.extensionPath);
if (packagesToInstall && packagesToInstall.length > 0) {
this.eventStream.post(new PackageInstallation(`OmniSharp Version = ${version}`));
Expand All @@ -53,4 +53,4 @@ export class OmnisharpDownloader {
throw error;
}
}
}
}
36 changes: 21 additions & 15 deletions src/omnisharp/OmnisharpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as semver from 'semver';
import * as util from '../common';
import { OmnisharpDownloader } from './OmnisharpDownloader';
import { PlatformInformation } from '../platform';
import { modernNetVersion } from './OmnisharpPackageCreator';

export interface LaunchInfo {
LaunchPath: string;
Expand All @@ -20,11 +21,11 @@ export class OmnisharpManager {
private platformInfo: PlatformInformation) {
}

public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
public async GetOmniSharpLaunchInfo(defaultOmnisharpVersion: string, omnisharpPath: string, useFramework: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
if (!omnisharpPath) {
// If omnisharpPath was not specified, return the default path.
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion);
return this.GetLaunchInfo(this.platformInfo, basePath);
let basePath = path.resolve(extensionPath, '.omnisharp', defaultOmnisharpVersion + (useFramework ? '' : `-net${modernNetVersion}`));
return this.GetLaunchInfo(this.platformInfo, useFramework, basePath);
}

// Looks at the options path, installs the dependencies and returns the path to be loaded by the omnisharp server
Expand All @@ -38,48 +39,53 @@ export class OmnisharpManager {
};
}
else if (omnisharpPath === 'latest') {
return await this.InstallLatestAndReturnLaunchInfo(serverUrl, latestVersionFileServerPath, installPath, extensionPath);
return await this.InstallLatestAndReturnLaunchInfo(useFramework, serverUrl, latestVersionFileServerPath, installPath, extensionPath);
}

// If the path is neither a valid path on disk not the string "latest", treat it as a version
return await this.InstallVersionAndReturnLaunchInfo(omnisharpPath, serverUrl, installPath, extensionPath);
return await this.InstallVersionAndReturnLaunchInfo(omnisharpPath, useFramework, serverUrl, installPath, extensionPath);
}

private async InstallLatestAndReturnLaunchInfo(serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
private async InstallLatestAndReturnLaunchInfo(useFramework: boolean, serverUrl: string, latestVersionFileServerPath: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
let version = await this.downloader.GetLatestVersion(serverUrl, latestVersionFileServerPath);
return await this.InstallVersionAndReturnLaunchInfo(version, serverUrl, installPath, extensionPath);
return await this.InstallVersionAndReturnLaunchInfo(version, useFramework, serverUrl, installPath, extensionPath);
}

private async InstallVersionAndReturnLaunchInfo(version: string, serverUrl: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
private async InstallVersionAndReturnLaunchInfo(version: string, useFramework: boolean, serverUrl: string, installPath: string, extensionPath: string): Promise<LaunchInfo> {
if (semver.valid(version)) {
await this.downloader.DownloadAndInstallOmnisharp(version, serverUrl, installPath);
return this.GetLaunchPathForVersion(this.platformInfo, version, installPath, extensionPath);
await this.downloader.DownloadAndInstallOmnisharp(version, useFramework, serverUrl, installPath);
return this.GetLaunchPathForVersion(this.platformInfo, useFramework, version, installPath, extensionPath);
}
else {
throw new Error(`Invalid OmniSharp version - ${version}`);
}
}

private GetLaunchPathForVersion(platformInfo: PlatformInformation, version: string, installPath: string, extensionPath: string): LaunchInfo {
private GetLaunchPathForVersion(platformInfo: PlatformInformation, isFramework: boolean, version: string, installPath: string, extensionPath: string): LaunchInfo {
if (!version) {
throw new Error('Invalid Version');
}

let basePath = path.resolve(extensionPath, installPath, version);
let basePath = path.resolve(extensionPath, installPath, version + (isFramework ? '' : `-net${modernNetVersion}`));

return this.GetLaunchInfo(platformInfo, basePath);
return this.GetLaunchInfo(platformInfo, isFramework, basePath);
}

private GetLaunchInfo(platformInfo: PlatformInformation, basePath: string): LaunchInfo {
private GetLaunchInfo(platformInfo: PlatformInformation, isFramework: boolean, basePath: string): LaunchInfo {
if (platformInfo.isWindows()) {
return {
LaunchPath: path.join(basePath, 'OmniSharp.exe')
};
}
else if (!isFramework) {
return {
LaunchPath: path.join(basePath, 'OmniSharp')
};
}

return {
LaunchPath: path.join(basePath, 'run'),
MonoLaunchPath: path.join(basePath, 'omnisharp', 'OmniSharp.exe')
};
}
}
}
28 changes: 18 additions & 10 deletions src/omnisharp/OmnisharpPackageCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,56 @@

import { Package } from "../packageManager/Package";

export function GetPackagesFromVersion(version: string, runTimeDependencies: Package[], serverUrl: string, installPath: string): Package[] {
export const modernNetVersion = "6.0";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed OmniSharp/omnisharp-roslyn#2294 to track removing the need for this constant.


export function GetPackagesFromVersion(version: string, useFramework: boolean, runTimeDependencies: Package[], serverUrl: string, installPath: string): Package[] {
if (!version) {
throw new Error('Invalid version');
}

let versionPackages = new Array<Package>();
for (let inputPackage of runTimeDependencies) {
if (inputPackage.platformId) {
versionPackages.push(SetBinaryAndGetPackage(inputPackage, serverUrl, version, installPath));
if (inputPackage.platformId && inputPackage.isFramework === useFramework) {
versionPackages.push(SetBinaryAndGetPackage(inputPackage, useFramework, serverUrl, version, installPath));
}
}

return versionPackages;
}

export function SetBinaryAndGetPackage(inputPackage: Package, serverUrl: string, version: string, installPath: string): Package {
export function SetBinaryAndGetPackage(inputPackage: Package, useFramework: boolean, serverUrl: string, version: string, installPath: string): Package {
let installBinary: string;
if (inputPackage.platformId === "win-x86" || inputPackage.platformId === "win-x64") {
installBinary = "OmniSharp.exe";
}
else if (!useFramework) {
installBinary = 'OmniSharp';
}
else {
installBinary = "run";
}

return GetPackage(inputPackage, serverUrl, version, installPath, installBinary);
return GetPackage(inputPackage, useFramework, serverUrl, version, installPath, installBinary);
}

function GetPackage(inputPackage: Package, serverUrl: string, version: string, installPath: string, installBinary: string): Package {
function GetPackage(inputPackage: Package, useFramework: boolean, serverUrl: string, version: string, installPath: string, installBinary: string): Package {
if (!version) {
throw new Error('Invalid version');
}

const packageSuffix = useFramework ? '' : `-net${modernNetVersion}`;

let versionPackage: Package = {
id: inputPackage.id,
description: `${inputPackage.description}, Version = ${version}`,
url: `${serverUrl}/releases/${version}/omnisharp-${inputPackage.platformId}.zip`,
installPath: `${installPath}/${version}`,
installTestPath: `./${installPath}/${version}/${installBinary}`,
url: `${serverUrl}/releases/${version}/omnisharp-${inputPackage.platformId}${packageSuffix}.zip`,
installPath: `${installPath}/${version}${packageSuffix}`,
installTestPath: `./${installPath}/${version}${packageSuffix}/${installBinary}`,
platforms: inputPackage.platforms,
architectures: inputPackage.architectures,
binaries: inputPackage.binaries,
platformId: inputPackage.platformId
platformId: inputPackage.platformId,
isFramework: useFramework
};

return versionPackage;
Expand Down
Loading