Skip to content

Conversation

@akshita31
Copy link
Contributor

@akshita31 akshita31 commented Jan 22, 2018

This is the first step in a series of changes to solve the issue : #1909

Changes :

  1. Added option alternateVersion in 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.

  2. Added option useLatestExperimentalBuild which if set will start the server from the latest version present in the .omnisharp/experiment folder.

Next steps:

  1. For the latest option , download a version.txt kind 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.

  2. For the release option , if the version is not present download and install it and then start the server.

@akshita31 akshita31 force-pushed the experiment_omnisharp_1 branch from 653165c to e9457f2 Compare January 22, 2018 22:13
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"
Copy link

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.

Copy link
Member

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


export class OmnisharpDownloader {

public GetLatestExperimentVersion(): string {
Copy link

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?

let latestVersion: string;
let items = fs.readdirSync(basePath);
if (items) {
items.sort(compareVersions);
Copy link

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).

Copy link
Member

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

let items = fs.readdirSync(basePath);
if (items) {
items.sort(compareVersions);
latestVersion = items[items.length - 1];
Copy link

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?

basePath = path.resolve(util.getExtensionPath(), `.omnisharp/experiment/${experimentVersion}`);
}
else {
// If the user has not provided a path, we'll use the locally-installed OmniSharp
Copy link

Choose a reason for hiding this comment

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

This comment needs updated.

public showTestsCodeLens?: boolean,
public disableCodeActions?: boolean) { }
public disableCodeActions?: boolean,
public experimentOmnisharp?: string) { }
Copy link

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? :)

//get the latest version after sorting
}

return latestVersion;
Copy link

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 :).

@akshita31 akshita31 changed the base branch from master to experiment_download January 23, 2018 22:29
@akshita31 akshita31 force-pushed the experiment_omnisharp_1 branch from b621073 to 7237fd3 Compare January 24, 2018 21:52
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.

Looks great! Just the one question for you.

}
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');
Copy link

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?

if (installedItems && installedItems.length > 0) {
let validVersions = installedItems.filter(value => semver.valid(value));
if (validVersions && validVersions.length > 0) {
latestVersion = validVersions.reduce((latestTillNow, element) => {
Copy link

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@DustinCampbell DustinCampbell left a 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"
},
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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?

export class OmnisharpDownloader {

public GetLatestInstalledExperimentalVersion(basePath: string) {
const semver = require('semver');
Copy link
Member

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?


import * as fs from 'fs';

export class OmnisharpDownloader {
Copy link
Member

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.

let extensionPath = utils.getExtensionPath();

if(experimentalOption == "latest"){
let downloader = new OmnisharpDownloader();
Copy link
Member

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 @@
/*---------------------------------------------------------------------------------------------
Copy link
Member

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 ?

@akshita31 akshita31 force-pushed the experiment_omnisharp_1 branch from f65f377 to c32eda4 Compare January 26, 2018 21:08
@akshita31 akshita31 force-pushed the experiment_omnisharp_1 branch from c32eda4 to 498ccab Compare January 26, 2018 21:10
@TheRealPiotrP
Copy link

@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:

  • merge this feature
  • temporarily fork the downloader, refactoring it to be testable and tested
  • once we're happy with the downloader, extend it to provide for the O# scenario as well

Let's chat about this next week?

@DustinCampbell
Copy link
Member

DustinCampbell commented Jan 29, 2018

@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.

@akshita31
Copy link
Contributor Author

The approach to the feature changed a bit #2028 and #2039, hence the functionality added here is no more needed. Closing this for now

@akshita31 akshita31 closed this Feb 16, 2018
@akshita31 akshita31 deleted the experiment_omnisharp_1 branch February 23, 2018 23:13
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