Skip to content

Conversation

Also, add new C# 15 errors to catch-all file
Focus on fixing the error, not describing it.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds documentation for several C# 11 compiler diagnostics by moving them from the generic error page to appropriate thematic documentation files, and enhances the source generator documentation with actionable guidance.

Changes:

  • Removed CS9027, CS9041, CS9049, and CS9067 from the generic "sorry we don't have specifics" error file
  • Added CS9049 (ref field in fixed-size buffer) to unsafe code errors documentation
  • Added CS9027 (unexpected unchecked keyword) to operator errors documentation
  • Added CS9041 (unsupported compiler feature) to feature version errors documentation
  • Added CS9057 (analyzer version compatibility) and CS9067 (duplicate analyzer reference) to source generator errors documentation with detailed resolution guidance
  • Updated table of contents to reflect the new error code locations

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md Removed CS9027, CS9041, CS9049, and CS9067 from the generic error list; added C# 15 diagnostics placeholder
docs/csharp/language-reference/toc.yml Added error codes to appropriate category display names in table of contents
docs/csharp/language-reference/compiler-messages/unsafe-code-errors.md Added CS9049 documentation explaining that fixed fields cannot be ref fields
docs/csharp/language-reference/compiler-messages/source-generator-errors.md Added CS9057 and CS9067 with new "Analyzer compatibility" section providing detailed resolution guidance
docs/csharp/language-reference/compiler-messages/overloaded-operator-errors.md Added CS9027 documentation for unexpected unchecked keyword in operator declarations
docs/csharp/language-reference/compiler-messages/feature-version-errors.md Added CS9041 to the list of compiler feature/version errors

Co-authored-by: Meaghan Osagie (Lewis) <[email protected]>
@BillWagner BillWagner enabled auto-merge (squash) January 28, 2026 18:20
@BillWagner BillWagner merged commit dad2c84 into dotnet:main Jan 28, 2026
9 checks passed
@BillWagner BillWagner deleted the version11-diagnostics branch January 28, 2026 18:53
Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry a bit late but putting these comments here just in case they're helpful.

- **CS8929**: *Method cannot implement interface member in type because the target runtime doesn't support static abstract members in interfaces.*
- **CS8957**: *Conditional expression is not valid in language version because a common type was not found between types.*
- **CS8967**: *Newlines inside a non-verbatim interpolated string are not supported in C#*
- **CS9041**: *Requires compiler feature, which is not supported by this version of the C# compiler.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **CS9041**: *Requires compiler feature, which is not supported by this version of the C# compiler.*
- **CS9041**: *Requires a compiler feature that is not supported by this version of the C# compiler.*

In C# 12, interceptors are experimental. Interceptors are subject to breaking changes or removal in a future release. Therefore, it is not recommended for production or released applications.

In order to use interceptors, you must set the `<Features>InterceptorsPreview</Features>` element in your project file. Without this flag, interceptors are disabled, even when other C# 12 features are enabled.
To use interceptors, add the `<Features>InterceptorsPreview</Features>` element to your project file within a `<PropertyGroup>` section (**CS9137**), because interceptors are an experimental feature that isn't enabled by default. This explicit opt-in is required because interceptors are subject to breaking changes or removal in future releases, and the compiler needs confirmation that you understand the risks before allowing their use. For more information about interceptors and their capabilities, see [Interceptors](../../whats-new/csharp-12.md#interceptors) in the C# 12 features documentation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To use interceptors, add the `<Features>InterceptorsPreview</Features>` element to your project file within a `<PropertyGroup>` section (**CS9137**), because interceptors are an experimental feature that isn't enabled by default. This explicit opt-in is required because interceptors are subject to breaking changes or removal in future releases, and the compiler needs confirmation that you understand the risks before allowing their use. For more information about interceptors and their capabilities, see [Interceptors](../../whats-new/csharp-12.md#interceptors) in the C# 12 features documentation.
To use interceptors, add the `<Features>InterceptorsPreview</Features>` element to your project file within a `<PropertyGroup>` section (**CS9137**), because interceptors is an experimental feature that isn't enabled by default. This explicit opt-in is required because the interceptors feature is subject to breaking changes or removal in future releases, and the compiler needs confirmation that you understand the risks before allowing its use. For more information about interceptors and their capabilities, see [Interceptors](../../whats-new/csharp-12.md#interceptors) in the C# 12 features documentation.

- **CS9161** prevents interceptors from being marked with `UnmanagedCallersOnlyAttribute`.
- **CS9206** requires interceptors to be contained in a namespace (not global).
- **CS9207** requires interceptable methods to be ordinary member invocations.
- **CS9057** is generated when an analyzer assembly references a version of the Roslyn compiler that is newer than the one currently running. This prevents the analyzer from loading because it may depend on APIs or behaviors not available in the current compiler version. To resolve this, either upgrade your compiler/SDK to match the analyzer's requirements or use a version of the analyzer compatible with your current compiler version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **CS9057** is generated when an analyzer assembly references a version of the Roslyn compiler that is newer than the one currently running. This prevents the analyzer from loading because it may depend on APIs or behaviors not available in the current compiler version. To resolve this, either upgrade your compiler/SDK to match the analyzer's requirements or use a version of the analyzer compatible with your current compiler version.
- **CS9057** is generated when an analyzer assembly references a version of the Roslyn compiler that is newer than the one currently running. This prevents the analyzer from loading because it might depend on APIs or behaviors not available in the current compiler version. To resolve this, either upgrade your compiler/SDK to match the analyzer's requirements or use a version of the analyzer compatible with your current compiler version.

- **CS9206** requires interceptors to be contained in a namespace (not global).
- **CS9207** requires interceptable methods to be ordinary member invocations.
- **CS9057** is generated when an analyzer assembly references a version of the Roslyn compiler that is newer than the one currently running. This prevents the analyzer from loading because it may depend on APIs or behaviors not available in the current compiler version. To resolve this, either upgrade your compiler/SDK to match the analyzer's requirements or use a version of the analyzer compatible with your current compiler version.
- **CS9067** warns when the same analyzer assembly is referenced multiple times in your project. This typically happens when an analyzer is included through multiple paths or package references. While not an error, duplicate references can impact build performance and may cause unexpected behavior. Remove the duplicate references to resolve this warning.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **CS9067** warns when the same analyzer assembly is referenced multiple times in your project. This typically happens when an analyzer is included through multiple paths or package references. While not an error, duplicate references can impact build performance and may cause unexpected behavior. Remove the duplicate references to resolve this warning.
- **CS9067** warns when the same analyzer assembly is referenced multiple times in your project. This typically happens when an analyzer is included through multiple paths or package references. While not an error, duplicate references can impact build performance and might cause unexpected behavior. Remove the duplicate references to resolve this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unrelated C# 11 issues

3 participants