-
Notifications
You must be signed in to change notification settings - Fork 727
Enable usage of multiple versions of omnisharp instead of just the released version #1972
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 usage of multiple versions of omnisharp instead of just the released version #1972
Conversation
653165c to
e9457f2
Compare
package.json
Outdated
| "omnisharp.experimentOmnisharp":{ | ||
| "type":"string", | ||
| "default": null, | ||
| "description": "Specifies if the user wants to use the experiment build. Possible values - latest or some version number" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a way of specifying possible values so they show up in completions. Don't block on this, but something to consider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an example of how to do that in this very file: https://github.com/OmniSharp/omnisharp-vscode/blob/master/package.json#L376-L388
src/omnisharp/OmnisharpDownloader.ts
Outdated
|
|
||
| export class OmnisharpDownloader { | ||
|
|
||
| public GetLatestExperimentVersion(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this tells you the most recently installed version, maybe GetLatestInstalledExperimentalVersion?
src/omnisharp/OmnisharpDownloader.ts
Outdated
| let latestVersion: string; | ||
| let items = fs.readdirSync(basePath); | ||
| if (items) { | ||
| items.sort(compareVersions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be a for loop (or whatever JS/TS equivalent there is to Enumerable.Min).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better to do a loop and use package like semver to address also the non-semantic version string (this will return a null object) and also handling pre-release versions
src/omnisharp/OmnisharpDownloader.ts
Outdated
| let items = fs.readdirSync(basePath); | ||
| if (items) { | ||
| items.sort(compareVersions); | ||
| latestVersion = items[items.length - 1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what if there are folders whose names aren't parseable versions?
src/omnisharp/launcher.ts
Outdated
| basePath = path.resolve(util.getExtensionPath(), `.omnisharp/experiment/${experimentVersion}`); | ||
| } | ||
| else { | ||
| // If the user has not provided a path, we'll use the locally-installed OmniSharp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment needs updated.
src/omnisharp/options.ts
Outdated
| public showTestsCodeLens?: boolean, | ||
| public disableCodeActions?: boolean) { } | ||
| public disableCodeActions?: boolean, | ||
| public experimentOmnisharp?: string) { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we replace all instances of experiment with experimental? :)
src/omnisharp/OmnisharpDownloader.ts
Outdated
| //get the latest version after sorting | ||
| } | ||
|
|
||
| return latestVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like something we could unit test :).
b621073 to
7237fd3
Compare
rchande
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just the one question for you.
src/omnisharp/launcher.ts
Outdated
| } | ||
| else { | ||
| // If the user has not provided a path and some experimental version, we'll use the locally-installed OmniSharp | ||
| basePath = path.resolve(util.getExtensionPath(), '.omnisharp'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this computation happen in server.ts and this file?
src/omnisharp/OmnisharpDownloader.ts
Outdated
| if (installedItems && installedItems.length > 0) { | ||
| let validVersions = installedItems.filter(value => semver.valid(value)); | ||
| if (validVersions && validVersions.length > 0) { | ||
| latestVersion = validVersions.reduce((latestTillNow, element) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
added colomn to test functions
remove unused import to comply with tslint
DustinCampbell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to tell since this PR doesn't represent the entire feature, but I'm a little concerned that it seems like we might be planning to write another downloader here. I would recommend against that and leverage the code we already have to leverage packages.
| "type": "string", | ||
| "default": null, | ||
| "description": "Specifies if the user wants to use the experiment build. Possible values - latest or some version number" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide "enum" values to help with JSON completion and schema validation. See "omnisharp.loggingLevel" below for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please clean up the grammar in the description. This is a user-facing string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, omnisharp.experimentalOmniSharp is a bit redundant. It's also not clear to me why this is "experimental". Maybe omnisharp.alternateVersion or something like that? @rchande?
src/omnisharp/OmnisharpDownloader.ts
Outdated
| export class OmnisharpDownloader { | ||
|
|
||
| public GetLatestInstalledExperimentalVersion(basePath: string) { | ||
| const semver = require('semver'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just import * as semver from 'semver' at the top of the module?
src/omnisharp/OmnisharpDownloader.ts
Outdated
|
|
||
| import * as fs from 'fs'; | ||
|
|
||
| export class OmnisharpDownloader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused by this name since this class doesn't actually download anything at all.
src/omnisharp/server.ts
Outdated
| let extensionPath = utils.getExtensionPath(); | ||
|
|
||
| if(experimentalOption == "latest"){ | ||
| let downloader = new OmnisharpDownloader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expected to actually download something from the Internet somehow? If so, should this be plugged into the package downloader that already exists in omnisharp-vscode?
| @@ -0,0 +1,28 @@ | |||
| /*--------------------------------------------------------------------------------------------- | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would not be better to call this file VersionSelectors.ts ?
f65f377 to
c32eda4
Compare
c32eda4 to
498ccab
Compare
|
@DustinCampbell I share your concern about duplication. We took a good hard look at the existing downloader and in fact started by modifying it. However, that code is very lightly tested and the current structure doesn't lend itself to testability. We intend to:
Let's chat about this next week? |
|
@TheRealPiotrP : Sounds gool! Although, this PR doesn't actually do any downloading, so there's not a lot of duplication yet. 😄 I just want to be sure that we don't regress any of the bugs that were fixed in the original downloader. |
This is the first step in a series of changes to solve the issue : #1909
Changes :
Added option
alternateVersionin which a string value can be specified, and if the particular version is present in .omnisharp/experimental folder, the server will be started using that.Added option
useLatestExperimentalBuildwhich if set will start the server from the latest version present in the .omnisharp/experiment folder.Next steps:
For the latest option , download a
version.txtkind of file and get the latest version from that. If the version is not present then download and install the appropriate packages and then start the server.For the release option , if the version is not present download and install it and then start the server.