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

Add C# 7.1 version to compiler #17894

Merged
merged 1 commit into from
Mar 15, 2017
Merged

Add C# 7.1 version to compiler #17894

merged 1 commit into from
Mar 15, 2017

Conversation

OmarTawfik
Copy link
Contributor

cc @AlekseyTs @jcouv @dotnet/roslyn-compiler

Contributes to #17173

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM

if (int.TryParse(version, NumberStyles.None, CultureInfo.InvariantCulture, out versionNumber) &&
versionNumber <= 6 &&
((LanguageVersion)versionNumber).IsValid())
if (int.TryParse(version, NumberStyles.None, CultureInfo.InvariantCulture, out int versionNumber) && versionNumber <= 7)
Copy link
Member

@cston cston Mar 15, 2017

Choose a reason for hiding this comment

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

Do we now allow "07"? Consider reporting errors for leading zeros on any version number. #Resolved

Copy link
Contributor Author

@OmarTawfik OmarTawfik Mar 15, 2017

Choose a reason for hiding this comment

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

@cston this wasn't introduced in this PR. In fact, I think RTM has this behaviour:
c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Roslyn\csc.exe" a.cs /langversion:05
If you think this should be an error, we can change it in a later PR, but I wanted to merge this to unblock @AlekseyTs. Do I've a sign off? #Resolved

Copy link
Member

@cston cston Mar 15, 2017

Choose a reason for hiding this comment

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

It was a minor point. Previously we allowed 7 but not 07, now we allow 07 and 7.1 but not 07.1. #Resolved

Copy link
Member

@jcouv jcouv Mar 15, 2017

Choose a reason for hiding this comment

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

I agree. The weird format like 05 should no longer be allowed, starting with version 7. #Resolved

@OmarTawfik OmarTawfik merged commit 4b6bb0c into dotnet:master Mar 15, 2017
@OmarTawfik OmarTawfik deleted the fix-17173-add-7.1-to-master branch March 15, 2017 23:09
@@ -1355,7 +1357,7 @@ public void LanguageVersion_MapSpecifiedToEffectiveVersion()
Assert.Equal(LanguageVersion.CSharp6, LanguageVersion.CSharp6.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7, LanguageVersion.CSharp7.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7, LanguageVersion.Default.MapSpecifiedToEffectiveVersion());
Assert.Equal(LanguageVersion.CSharp7, LanguageVersion.Latest.MapSpecifiedToEffectiveVersion());
Copy link
Member

@jcouv jcouv Mar 15, 2017

Choose a reason for hiding this comment

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

You're missing a test for CSharp7_1 #Resolved

@@ -1332,14 +1334,14 @@ public void LanguageVersionAdded_Canary()
// - update the "UpgradeProject" codefixer
Copy link
Member

@jcouv jcouv Mar 15, 2017

Choose a reason for hiding this comment

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

Did you update the UpgradeProject codefixer? We should add a diagnostic for "error CS80XX: Feature is not available in C# 7." and handle it in CSharpUpgradeProjectCodeFixProvider.
This also mean updating the method for checking feature availability. #ByDesign

Copy link
Member

@jcouv jcouv Mar 16, 2017

Choose a reason for hiding this comment

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

Also, could you add a test for the LanguageVersionExtensionsInternal.GetErrorCode method. It should loop over Enum.GetValues(typeof(LanguageVersion)).Cast<LanguageVersion>() so that it breaks any time a new enum value is added.
#Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jcouv If I understand the fixer correctly, this will have to wait until any of the 7.1 features actually make it to master.
I'll log an item for it in the master issue.


In reply to: 106310848 [](ancestors = 106310848)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I realized that too. But I came up with a solution, by leveraging another feature that's useful for point releases, the #version directive.

I have a PR almost ready: #17957

@OmarTawfik
Copy link
Contributor Author

OmarTawfik commented Mar 16, 2017

@jcouv had to merge this as soon as it got sign offs to unblock Aleksey. Will send another PR in the morning to cover the additional comments you left. #Resolved

@jcouv
Copy link
Member

jcouv commented Mar 16, 2017

No problem.
Thanks #Resolved

@@ -2690,7 +2690,7 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep
<value>This warning occurs if the assembly attributes AssemblyKeyFileAttribute or AssemblyKeyNameAttribute found in source conflict with the /keyfile or /keycontainer command line option or key file name or key container specified in the Project Properties.</value>
</data>
<data name="ERR_BadCompatMode" xml:space="preserve">
<value>Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default or an integer in range 1 to 7.</value>
<value>Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.</value>
Copy link
Member

@jcouv jcouv Mar 16, 2017

Choose a reason for hiding this comment

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

I wonder if we should enumerate the valid versions in the message (1, 2, 3, 4, 5, 6, 7, 7.1) #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it be too long? Consider in a couple of point releases:
Invalid option '{0}' for /langversion; must be ISO-1, ISO-2, Default, Latest, 1, 2, 3, 4, 5, 6, 7, 7,1, 7.2, 8.
I'd claim that people calling csc from command line already know what they're doing (and they don't need to know which C# versions were shipped), VS UI or first time users who would normally use VS project dialogs to enumerate available versions.


In reply to: 106479809 [](ancestors = 106479809)

Copy link
Member

@jcouv jcouv Mar 17, 2017

Choose a reason for hiding this comment

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

Ok. Let's leave as-is. #Resolved

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

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

Added a couple suggestions.

@@ -5032,4 +5032,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_InvalidPreprocessingSymbol" xml:space="preserve">
<value>Invalid name for a preprocessing symbol; '{0}' is not a valid identifier</value>
</data>
<data name="ERR_FeatureNotAvailableInVersion7_1" xml:space="preserve">
<value>Feature '{0}' is not available in C# 7.1. Please use language version {1} or greater.</value>
Copy link
Member

@jcouv jcouv Mar 16, 2017

Choose a reason for hiding this comment

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

Nit: two spaces after 7.1. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Paste issue from similar messages :) will fix all of them now.


In reply to: 106479940 [](ancestors = 106479940)

@@ -212,6 +229,7 @@ public static LanguageVersion MapSpecifiedToEffectiveVersion(this LanguageVersio
switch (version)
{
case LanguageVersion.Latest:
return LanguageVersion.CSharp7_1;
Copy link
Member

@jcouv jcouv Mar 16, 2017

Choose a reason for hiding this comment

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

I wonder if we could make this code invariant so it doesn't have to be updated with every point release. Maybe we just return the largest enum entry except for LanguageVersion.Latest. #Resolved

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 think this file is very easy to edit. After the recent rectoring (by you), all our version work is done here, and adding a new version is simply editing 3~4 lines in that file, plus the required testing.


In reply to: 106483298 [](ancestors = 106483298)

@jcouv
Copy link
Member

jcouv commented Mar 16, 2017

This PR implements parts of #17173 #Resolved

@jcouv
Copy link
Member

jcouv commented Mar 17, 2017

@OmarTawfik As a side note, I noticed that you merge your PRs, rather than squash them. I find that the history is more readable with squashed PRs (it avoids commits like "PR feedback", or "fix" making it into the github history). For your consideration :-) #Resolved

@OmarTawfik
Copy link
Contributor Author

Thanks :)


In reply to: 287243222 [](ancestors = 287243222)

OmarTawfik added a commit that referenced this pull request Mar 21, 2017
* Responded to PR comments on #17894

* Added more tests, and supporting 1.0, 2.0, 3.0, etc... versions

* Clean up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants