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

Enable multiple download of omnisharp #2065

Merged
merged 16 commits into from
Feb 27, 2018
Merged

Enable multiple download of omnisharp #2065

merged 16 commits into from
Feb 27, 2018

Conversation

akshita31
Copy link
Contributor

@akshita31 akshita31 commented Feb 23, 2018

Fixes: #1909
Final PR including all the changes.

…ns of omnisharp (#2028)

* Enable usage of multiple versions

* Either load the server from a path or download the version packages

* Tests for the package creator

* Added null check and removed semver check in package creator

* Test for the experiment omnisharp downloader

* Added test for package manager

* Code clean up

* Added null or empty check for version

* Changes

* Modified the description

Put the clean up logic in the teardown function

* Remove comment

* Remove unnecessary usage

* CR comments

* Removed experimental

* Modified launcher

* Removed experimental

* Modified tests

* Modified package description to include version information

* Renamed launch path

* Add more tests

* Changed the description in package.json
* Enable usage of multiple versions

* Either load the server from a path or download the version packages

* Tests for the package creator

* Added null check and removed semver check in package creator

* Test for the experiment omnisharp downloader

* Added test for package manager

* Code clean up

* Added null or empty check for version

* Changes

* Modified the description

* Put the clean up logic in the teardown function

* Remove comment

* Remove unnecessary usage

* CR comments

* Removed experimental

* Modified launcher

* Removed experimental

* Modified tests

* Modified package description to include version information

* Renamed launch path

* Add more tests

* Changed the description in package.json

* Getting latest version info

* Refactored code and added tests

* Remove unnecessary using

* CR comments

* Use common function for latest download

* Add new line

* Resolve binaries on linux
package.json Outdated
@@ -39,6 +39,7 @@
"postinstall": "node ./node_modules/vscode/bin/install"
},
"dependencies": {
"chai-as-promised": "^7.1.1",
Copy link
Member

Choose a reason for hiding this comment

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

should this be a dev dependency only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is automatically added when I npm install the package. What do you think should be changed here?

Copy link
Member

Choose a reason for hiding this comment

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

I would just move this dependency in the devdependecies list and fix it to 7.1.1 instead of compatible versions

package.json Outdated
@@ -93,7 +94,8 @@
"architectures": [
"x86"
],
"installTestPath": "./.omnisharp/OmniSharp.exe"
"installTestPath": "./.omnisharp/OmniSharp.exe",
"experimentalPackageId": "win-x86"

Choose a reason for hiding this comment

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

let's rename experimentalPackageId to platformId

Copy link

@rchande rchande left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good. There's probably some stuff we can clean up later. I made a couple of comments--fix those up and I think we're good to go.

installationStage = '';
logger.appendLine('Finished');

statusItem.dispose();
Copy link

Choose a reason for hiding this comment

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

Seems weird that this method takes statusItem just to call dispose on it.

if (platformInfo.distribution) {
telemetryProps['platform.distribution'] = platformInfo.distribution.toTelemetryString();
}
if (reporter) {
Copy link

Choose a reason for hiding this comment

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

Is reporter ever null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont think so. But I just followed by the pattern followed by CSharpExtDownloader.

Currently this pattern helps because in testing I am conveniently passing this field as null, but in future we might want to test the Telemetry as well.

For the current PR, I think we can retain this pattern. What do you think ?

Copy link

Choose a reason for hiding this comment

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

Sure, we can refactor later.


public async DownloadAndInstallOmnisharp(version: string, serverUrl: string, installPath: string) {
if (!version) {
throw new Error('Invalid version');
Copy link

Choose a reason for hiding this comment

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

If this happens, this is basically a bug in our code, right? Since this method is not expecting a null version. "invalid version" makes it sound like a user mistake, which it isn't.

}
}
else if (omnisharpPath == "latest") {
return await this.LatestInstallAndReturnLaunchPath(downloader, useMono, serverUrl, versionFilePathInServer, installPath, extensionPath, platformInfo);
Copy link

Choose a reason for hiding this comment

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

call this method InstallLatestAndReturnLaunchPath

return GetLaunchPathForVersion(platformInfo, version, installPath, extensionPath, useMono);
}
else {
throw new Error('Invalid omnisharp version specified');
Copy link

Choose a reason for hiding this comment

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

Can we include the specified version in this message?


let basePath = path.resolve(extensionPath, installPath, version);

if (platformInfo.isWindows()) {
Copy link

Choose a reason for hiding this comment

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

platformInfo.isWindows() || useMono ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, in case of useMono we append an extra "omnisharp" to the path

Copy link

Choose a reason for hiding this comment

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

Ok.

throw new Error('Invalid version');
}

let versionPackage = <Package>{
Copy link

Choose a reason for hiding this comment

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

Can you use the ... operator and just change the fields you care about?
{...package, url = zzz, experimentalPackageId = xxx
Means the same thing, but might be easier to tell what fields you're changing.

let launchPath: string;
if (this._options.path) {
try {
let serverUrl = "https://roslynomnisharp.blob.core.windows.net";
Copy link

Choose a reason for hiding this comment

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

Maybe move these into some obvious constant definitions somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where do you suggest can these be moved? Should we define some object that contains these fields in the package.json and just read from it here ?

Copy link

Choose a reason for hiding this comment

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

You could just move them up to be const fields in server.ts

src/packages.ts Outdated
@@ -24,6 +24,7 @@ export interface Package {
architectures: string[];
binaries: string[];
tmpFile: tmp.SynchrounousResult;
experimentalPackageId?: string;
Copy link

Choose a reason for hiding this comment

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

Change to whatever name Peter came up with :)

Copy link

@TheRealPiotrP TheRealPiotrP left a comment

Choose a reason for hiding this comment

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

let's rename the experimentalPackageId. Otherwise lgtm.

@akshita31 akshita31 merged commit 0342385 into master Feb 27, 2018
@akshita31 akshita31 deleted the experiment_download branch February 28, 2018 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants