-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Make MaxSupportedLangVersion calculation dynamic #75795
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,31 +7,25 @@ | |
<!-- .NETCoreApp < 3.0, .NETStandard < 2.1, or any other target framework --> | ||
<_MaxSupportedLangVersion Condition="('$(TargetFrameworkIdentifier)' != '.NETCoreApp' OR '$(_TargetFrameworkVersionWithoutV)' < '3.0') AND | ||
('$(TargetFrameworkIdentifier)' != '.NETStandard' OR '$(_TargetFrameworkVersionWithoutV)' < '2.1')">7.3</_MaxSupportedLangVersion> | ||
|
||
<!-- .NETCoreApp < 5.0, .NETStandard == 2.1 --> | ||
<_MaxSupportedLangVersion Condition="(('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' < '5.0') OR | ||
('$(TargetFrameworkIdentifier)' == '.NETStandard' AND '$(_TargetFrameworkVersionWithoutV)' == '2.1')) AND | ||
'$(_MaxSupportedLangVersion)' == ''">8.0</_MaxSupportedLangVersion> | ||
|
||
<!-- .NETCoreApp == 5.0 --> | ||
<_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> | ||
|
||
<!-- .NETCoreApp == 7.0 --> | ||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '7.0' AND | ||
'$(_MaxSupportedLangVersion)' == ''">11.0</_MaxSupportedLangVersion> | ||
|
||
<!-- .NETCoreApp == 8.0 --> | ||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '8.0' AND | ||
'$(_MaxSupportedLangVersion)' == ''">12.0</_MaxSupportedLangVersion> | ||
|
||
<!-- .NETCoreApp == 9.0 --> | ||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(_TargetFrameworkVersionWithoutV)' == '9.0' AND | ||
'$(_MaxSupportedLangVersion)' == ''">13.0</_MaxSupportedLangVersion> | ||
<!-- | ||
Automatically calculate the maximum supported C# language version based on the .NET Target Framework. | ||
- Pattern: .NET 5.0 uses C# 9.0, .NET 6.0 uses C# 10.0, and so on. | ||
- Starting from C# 9.0 for .NET 5.0, we add the difference between the major .NET version and 5 | ||
to determine the correct language version. | ||
--> | ||
<_MaxSupportedLangVersion Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND | ||
'$(_MaxSupportedLangVersion)' == ''">$([MSBuild]::Add(9, $([MSBuild]::Subtract($(_TargetFrameworkVersionWithoutV), 5)))).0</_MaxSupportedLangVersion> | ||
|
||
<!-- Cap _MaxSupportedLangVersion if it exceeds _MaxAvailableLangVersion --> | ||
<_MaxAvailableLangVersion>13.0</_MaxAvailableLangVersion> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcouv When a new language version is released, we'll just need to update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we still need to update this file every year when we increase the max language version, then what do we actually save by making this change over the current system? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current system requires two updates each year: one when a new framework version is released (around October/November, managed by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Thanks for clarifying for me. I'll let Julien be the second sign-off here though, since he does the roslyn-side of the process usually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@kasperk81 Would you mind sharing a link to one of those previous dotnet/sdk changes? That'll help provide more context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcouv it happens in the sdk each year when templates are updated. e.g. since dotnet/sdk#44349, if we use the daily build (net10.0) and do something like: $ dotnet new record -n record1 it issues warnings:
these type of warnings will go away when 14.0 will be introduced around july 2025 but then they will reappear around october 2025 until july 2026. pr is basically decoupling this sdkVersion + 1 to compilerLatestVersion binding so things keep working smoothly throughout the year. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment on the C# test named |
||
<_MaxSupportedLangVersion Condition="'$(_MaxSupportedLangVersion)' != '' AND | ||
'$(_MaxSupportedLangVersion)' > '$(_MaxAvailableLangVersion)'">$(_MaxAvailableLangVersion)</_MaxSupportedLangVersion> | ||
|
||
<MaxSupportedLangVersion>$(_MaxSupportedLangVersion)</MaxSupportedLangVersion> | ||
<LangVersion Condition="'$(LangVersion)' == '' AND '$(_MaxSupportedLangVersion)' != ''">$(_MaxSupportedLangVersion)</LangVersion> | ||
|
Uh oh!
There was an error while loading. Please reload this page.