-
Notifications
You must be signed in to change notification settings - Fork 4k
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 LanguageVersion 10 #54359
Add LanguageVersion 10 #54359
Conversation
322d150
to
bb957a3
Compare
804a63e
to
f236add
Compare
@@ -876,7 +876,7 @@ public static SyntaxTree Parse(string text, string filename = "", CSharpParseOpt | |||
{ | |||
if ((object)options == null) | |||
{ | |||
options = TestOptions.Regular; | |||
options = TestOptions.RegularPreview; |
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 changes the default for tests using APIs like CreateCompilation
.
@@ -17,6 +17,10 @@ | |||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '5.0' AND | |||
'$(_MaxSupportedLangVersion)' == ''">9.0</_MaxSupportedLangVersion> | |||
|
|||
<!-- .NETCoreApp == 6.0 --> | |||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '6.0' AND | |||
'$(_MaxSupportedLangVersion)' == ''">10.0</_MaxSupportedLangVersion> |
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.
@chsienki The LanguageVersionGivenTargetFramework
test was good at catching the new language version :-)
Can you take a look?
I left GeneratorDriver
with a LanguageVersion.Preview
check at the moment (based on offline discussion).
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.
IDE side LGTM
| [Mix declarations and variables in deconstruction](https://github.com/dotnet/csharplang/issues/125) | main | [Merged into 16.10](https://github.com/dotnet/roslyn/issues/47746) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [jcouv](https://github.com/jcouv) | [MadsTorgersen](https://github.com/MadsTorgersen) | | ||
| [List patterns](https://github.com/dotnet/csharplang/issues/3435) | [list-patterns](https://github.com/dotnet/roslyn/tree/features/list-patterns) | [In Progress](https://github.com/dotnet/roslyn/issues/51289) | [alrz](https://github.com/alrz) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [333fred](https://github.com/333fred) | | ||
|
||
# C# 10.0 |
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.
Should we have individually done this at the time we marked the features merged?
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.
Nah, it's fine. But it would be good if features that get merged following this PR updated this doc individually.
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.
LGTM
@@ -115,18 +115,18 @@ class C | |||
"; | |||
var compilation = CreateCompilationWithMscorlib45(source, parseOptions: TestOptions.Regular9); | |||
compilation.VerifyDiagnostics( | |||
// (11,25): error CS8652: The feature 'async method builder override' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version. | |||
// (11,25): error CS8773: Feature 'async method builder override' is not available in C# 9.0. Please use language version 10.0 or greater. |
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 feels like even with the new scheme of "use LanguageVersionFacts.CSharpNext" we still have this churn of updating diagnostic IDs when we snap off a new language version.
When we snap a language version, should we also introduce an error code specific to 'C# vNext' which becomes the ERR_FeatureNotAvailableInVersionN
error code when the language version gets snapped? (although this perhaps doesn't work for features like static abstracts in interfaces where we don't yet know what language version they are likely to ship in.)
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.
You're right that such diagnostics will still churn. We can explore some mitigations when we start working on C# 11.
@@ -1337,7 +1339,7 @@ public void Incremental_Generators_Exception_During_Execution() | |||
var source = @" | |||
class C { } | |||
"; | |||
var parseOptions = TestOptions.Regular.WithLanguageVersion(LanguageVersion.Preview); | |||
var parseOptions = TestOptions.RegularPreview; |
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 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.
The GeneratorDriver
only uses incremental general when LangVer==Preview at the moment. That is kept that way intentionally (based on chat with Chris).
@jcouv Just to clarify: The features now listed under C# Next are still (tentatively) planned for C# 10 but just haven't merged to |
@PathogenDavid Yes. Most are still in progress for C# 10. Which one are you asking about? |
@jcouv Thanks for confirming! As boring as it might sound, parameterless struct constructors is the main C# 10 feature I care about. It's something that'd really help Biohazrd since we wrap arbitrary C++ code and C++ uses parameterless constructors a lot. Currently parameterless constructors are a weird edge case that creates awkward friction, enough so that I was investigating maintaining a soft fork of Roslyn at one point just to build the generated wrappers. (My main sponsor wants to standardize on .NET 6 since it'll be LTS, so it'd be really disappointing to see the feature bumped again.) It appears to me like the PR for it is purring along smoothly, but if there's anything I can do to help with it definitely let me know. |
@PathogenDavid Parameterless struct constructors are still on track for C# 10. Should be in dev17.0p3. |
| [Async method builder override](https://github.com/dotnet/csharplang/issues/1407) | main | [In Progress](https://github.com/dotnet/roslyn/issues/51999) | [jcouv](https://github.com/jcouv) | TBD | [stephentoub](https://github.com/stephentoub) | | ||
| [Source Generator V2 APIs](https://github.com/dotnet/roslyn/issues/51257) | [features/source-generators](https://github.com/dotnet/roslyn/tree/features/source-generators) | [Merged into 17.0p2](https://github.com/dotnet/roslyn/issues/51257) | [chsienki](https://github.com/chsienki/) | [rikkigibson](https://github.com/rikkigibson), [jaredpar](https://github.com/jaredpar), [cston](https://github.com/cston) | N/A | | ||
| [Mix declarations and variables in deconstruction](https://github.com/dotnet/csharplang/issues/125) | main | [Merged into 16.10](https://github.com/dotnet/roslyn/issues/47746) | [YairHalberstadt ](https://github.com/YairHalberstadt) | [jcouv](https://github.com/jcouv) | [MadsTorgersen](https://github.com/MadsTorgersen) | | ||
| [Async method builder override](https://github.com/dotnet/csharplang/issues/1407) | main | [Merged into 17.0p2](https://github.com/dotnet/roslyn/issues/51999) | [jcouv](https://github.com/jcouv) | [cston](https://github.com/cston), [RikkiGibson](https://github.com/RikkiGibson) | [stephentoub](https://github.com/stephentoub) | |
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.
#line directives? dotnet/csharplang#4747
@jcouv Excellent news, I'll look forward to using them. Thanks for the info! |
…ures/caller-argument-expression * upstream/main: (492 commits) Add nullable ref annotations to SyntaxFactory (#54199) Add 'replace' APIs and hook them up to the IDE (#54270) Allow implicit implementation of non-public interface members (#54182) Make insertion a stage of the official build (#54376) Cleanup Remove unused property Simplify glyph computation Report all-empty top level statements. (#54385) Calculate TypeParameterKind based on the container type (#54200) vert not roaming Split tests Multple matches Report as we get results Fixup tests Update tests Avoid thread dependency in VirtualMemoryNotificationListener constructor Fast progression search. Add LanguageVersion 10 (#54359) Sure, why not ...
Hey @jcouv I'm trying to use C# 10 features in the dotnet/SDK repo without needing the However, even though it seems like the ingestion of Roslyn bits have been occurring regularly in the SDK repo, e.g. dotnet/sdk#18630, I still encounter errors like:
What else is needed here so that global usings are supported by default? FYI @wli3 |
It would be useful to know the output when Does the project where the error occurs actually have a PackageReference to |
Hmm I see, I'm not too familiar with the workings of the dotnet/SDK repo so let me dig a little. |
Recording for future reference:
|
Fixes #53857
This PR:
LanguageVersion.CSharp10
, makes it the current version and attaches the new feature that are inmain
already to itLanguageVersion.Preview
andTestOptions.RegularPreview
in tests as-isCreateCompilation
to useLanguageVersion.Preview
, so most new tests don't have to specify a language version at allTestOptions.RegularNext
andLanguageVersionFacts.CSharpNext
. Those should be used in new tests that are specifically about language version. We'll do a search&replace