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

Confusing use of "default" for langversion #30860

Closed
elezar42 opened this issue Aug 25, 2022 · 3 comments · Fixed by #37802
Closed

Confusing use of "default" for langversion #30860

elezar42 opened this issue Aug 25, 2022 · 3 comments · Fixed by #37802
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc help wanted Good for community contributors to help [up-for-grabs] lang-reference/subsvc mvp-docs-sprint For tracking purposes (used for the MVP summit docs sprint hack). Pri1 High priority, do before Pri2 and Pri3

Comments

@elezar42
Copy link

This document and this one are both extremely confusing, because they use the term "default" to mean 2 different things for the langversion. There's the default that is used if no langversion is specified, and then there's a specific value named default that is a synonym for latestmajor. At least, I think that's how it's supposed to work. I'm making an educated guess here because it's not clearly documented. I understand that removing the value of default may not be an option because it would be a breaking change, but the document needs to be very clear about the difference between this value and the actual defaults that are used when no value is specified.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@issues-automation issues-automation bot added lang-reference/subsvc dotnet-csharp/svc Pri1 High priority, do before Pri2 and Pri3 labels Aug 25, 2022
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Aug 25, 2022
@BillWagner BillWagner added doc-enhancement Improve the current content [org][type][category] help wanted Good for community contributors to help [up-for-grabs] labels Aug 26, 2022
@dotnet-bot dotnet-bot removed ⌚ Not Triaged Not triaged labels Aug 26, 2022
@BillWagner
Copy link
Member

Your analysis is correct @elezar42

I've added this to our backlog to address when we next update this article.

@luizhlelis
Copy link
Contributor

Hello everyone!
Maybe I am mistaken, but I understood from the text that if no override is made, the compiler will use the latest language version compatible with your target framework. So, the default that is used if no langversion is specified and the specific value named default that is a synonym for latestmajor are exactly the same thing.

What are you expecting as a solution to this issue?

@elezar42
Copy link
Author

@luizhlelis From my testing, using the specific value of default (or latestmajor) uses the latest version of the language supported by the compiler, without taking into account the target framework. So building a project that targets .NET 6 from the current version of VS2022 will use C# 10 if no LangVersion is specified, but will use C# 11 if LangVersion is set to default o latestmajor.

@IEvangelist IEvangelist added the mvp-docs-sprint For tracking purposes (used for the MVP summit docs sprint hack). label Apr 4, 2023
@ghost ghost added in-pr This issue will be closed (fixed) by an active pull request. and removed in-pr This issue will be closed (fixed) by an active pull request. labels Oct 30, 2023
BillWagner added a commit that referenced this issue Oct 31, 2023
#37802)

* edits

* fix

* edits

* fix

* Update docs/csharp/language-reference/compiler-options/language.md

---------

Co-authored-by: Bill Wagner <wiwagn@microsoft.com>
@ghost ghost removed the in-pr This issue will be closed (fixed) by an active pull request. label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc help wanted Good for community contributors to help [up-for-grabs] lang-reference/subsvc mvp-docs-sprint For tracking purposes (used for the MVP summit docs sprint hack). Pri1 High priority, do before Pri2 and Pri3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants