Skip to content

Update CS1617 documentation to clarify how to list supported C# language versions #47377

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

Merged
merged 3 commits into from
Jul 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion docs/csharp/misc/cs1617.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,49 @@ ms.assetid: fd3371ed-39eb-4d3d-b8f5-d96ac0c79398
---
# Compiler Error CS1617

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

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.

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

## How to list supported language versions

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.

### Use the reference table (recommended)

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.

### Use the C# compiler directly

Use the `-langversion:?` option with the C# compiler. You need to find the path to `csc.dll` in your .NET SDK installation:

```console
dotnet exec "/path/to/dotnet/sdk/version/Roslyn/bincore/csc.dll" -langversion:?
```

For example, on Linux with .NET 8 SDK:

```console
dotnet exec "/usr/lib/dotnet/sdk/8.0.117/Roslyn/bincore/csc.dll" -langversion:?
```

The exact path varies based on your operating system and .NET SDK version.

### Use a project file with diagnostic output (not recommended)

You can temporarily set `<LangVersion>?</LangVersion>` in your project file and build with diagnostic verbosity:

```console
dotnet build -v diagnostic
```

Look for the "Supported language versions:" line in the output.

> [!WARNING]
> 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.

## Valid values for -langversion

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.
Expand Down