Skip to content

Commit f684076

Browse files
CopilotBillWagnergewarren
authored
Update CS1617 documentation to clarify how to list supported C# language versions (#47377)
* Initial plan * Update CS1617 documentation to clarify how to list supported language versions Co-authored-by: BillWagner <[email protected]> * Apply review feedback: improve headings and text clarity per style guide Co-authored-by: gewarren <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BillWagner <[email protected]> Co-authored-by: gewarren <[email protected]>
1 parent badd9fe commit f684076

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

docs/csharp/misc/cs1617.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,49 @@ ms.assetid: fd3371ed-39eb-4d3d-b8f5-d96ac0c79398
1010
---
1111
# Compiler Error CS1617
1212

13-
Invalid option 'option' for **LangVersion**. Use `<LangVersion>?</LangVersion>` to list supported values.
13+
Invalid option 'option' for **LangVersion**. Use `?` to list supported values.
1414

1515
This error occurs if you used the [**LangVersion**](../language-reference/compiler-options/language.md#langversion) command line switch or project setting but didn't specify a valid language option. To resolve this error, check the command line syntax or project setting and change it to one of the listed options.
1616

1717
For example, compiling with `csc -langversion:ISO` will generate error CS1617.
1818

19+
## How to list supported language versions
20+
21+
To see a list of supported language versions, you reference the table in this article, compile with `-langversion:?`, or temporarily set `<LangVersion>?</LangVersion>` in your project file before building.
22+
23+
### Use the reference table (recommended)
24+
25+
The most reliable way to see supported language versions is to consult the reference table at the end of this article, which lists all currently supported language versions.
26+
27+
### Use the C# compiler directly
28+
29+
Use the `-langversion:?` option with the C# compiler. You need to find the path to `csc.dll` in your .NET SDK installation:
30+
31+
```console
32+
dotnet exec "/path/to/dotnet/sdk/version/Roslyn/bincore/csc.dll" -langversion:?
33+
```
34+
35+
For example, on Linux with .NET 8 SDK:
36+
37+
```console
38+
dotnet exec "/usr/lib/dotnet/sdk/8.0.117/Roslyn/bincore/csc.dll" -langversion:?
39+
```
40+
41+
The exact path varies based on your operating system and .NET SDK version.
42+
43+
### Use a project file with diagnostic output (not recommended)
44+
45+
You can temporarily set `<LangVersion>?</LangVersion>` in your project file and build with diagnostic verbosity:
46+
47+
```console
48+
dotnet build -v diagnostic
49+
```
50+
51+
Look for the "Supported language versions:" line in the output.
52+
53+
> [!WARNING]
54+
> Setting `<LangVersion>?</LangVersion>` in a project file will cause the build to fail after displaying the supported versions. This is because the compiler exits after listing the versions instead of continuing to compile your code. Remove this setting after viewing the list.
55+
1956
## Valid values for -langversion
2057

2158
The valid values for the language versions depend on the .NET version you are using. See [the language version rules](../language-reference/language-versioning.md#defaults) for more information on which language version is available with which version of .NET. If you are receiving this error while attempting to use a newer language version, either downgrade to a lower language version or update your .NET SDK to a version that supports the language version.

0 commit comments

Comments
 (0)