Update CS1617 documentation to clarify how to list supported C# language versions #47377
+38
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The CS1617 compiler error documentation previously mentioned using
<LangVersion>?</LangVersion>
to list supported values but didn't explain how to actually see this list, leading to user confusion.Changes Made
Updated
docs/csharp/misc/cs1617.md
to provide clear, practical guidance on how to list supported C# language versions:1. Reference table approach (recommended)
Points users to the existing comprehensive table of language versions as the most reliable method.
2. Direct compiler approach
Shows how to use the C# compiler directly:
dotnet exec "/path/to/dotnet/sdk/version/Roslyn/bincore/csc.dll" -langversion:?
3. Project file approach with proper warnings
Explains the diagnostic output method while clearly warning about build failures:
dotnet build -v diagnostic
Key Improvements
<LangVersion>?</LangVersion>
works but causes build failuresThe updated documentation resolves the issue by explaining that while
<LangVersion>?</LangVersion>
technically works, it causes the compiler to exit after listing versions instead of continuing compilation, which leads to build failures.Fixes #27101.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Internal previews