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

No support for 'preview' language versions? #1487

Closed
FiniteReality opened this issue May 12, 2019 · 4 comments · Fixed by #1488
Closed

No support for 'preview' language versions? #1487

FiniteReality opened this issue May 12, 2019 · 4 comments · Fixed by #1488

Comments

@FiniteReality
Copy link
Contributor

I'm writing some code to try out the new 'unmanaged constructed types' and 'static local functions' features, and as expected OmniSharp is flagging this up with error CS8652, stating that the feature is not supported and currently in preview.

However, the error says to use the preview language version to use these features, and upon specifying this in the LangVersion property, these errors remain. To hide these errors, I had to specify 8.0 as the value, instead of what the error had specified.

I believe this is due to this switch not including preview as a possible value, though I may be wrong since I'm not familiar with the code:

switch (propertyValue.ToLower())
{
case "latest": return LanguageVersion.Latest;
case "iso-1": return LanguageVersion.CSharp1;
case "iso-2": return LanguageVersion.CSharp2;
case "3": return LanguageVersion.CSharp3;
case "4": return LanguageVersion.CSharp4;
case "5": return LanguageVersion.CSharp5;
case "6": return LanguageVersion.CSharp6;
case "7": return LanguageVersion.CSharp7;
case "7.1": return LanguageVersion.CSharp7_1;
case "7.2": return LanguageVersion.CSharp7_2;
case "7.3": return LanguageVersion.CSharp7_3;
case "8.0": return LanguageVersion.CSharp8;
default: return LanguageVersion.Default;
}

@FiniteReality
Copy link
Contributor Author

FiniteReality commented May 12, 2019

I don't think there'll be any breaking changes if that entire snippet was replaced with LanguageVersionFacts.TryParse, so that could be a possible fix ensuring that this won't happen again in the future.

@filipw
Copy link
Member

filipw commented May 12, 2019

You are right, the Preview value is missing (as well as another new value LatestMajor) - both came in Roslyn 3.0 and we managed to miss them, thanks for opening the issue.

The reason why the built-in Roslyn language version parser was not used in the first place is because when the project parsing code was originally added, the LanguageVersion.TryParse (or its old version LanguageVersionFacts.TryParse) API didn't exist yet - it only came in Roslyn 2.1.

@FiniteReality
Copy link
Contributor Author

Ah, I had guessed as much. I'm alright to make a PR to fix this then, right? I'll probably replace it with the TryParse method I mentioned, which is indeed under LanguageVersionFacts, I had missed the class declaration a few lines above it while browsing the code.

@filipw
Copy link
Member

filipw commented May 12, 2019

sure, please do!

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 a pull request may close this issue.

2 participants