Skip to content

Document compiler diagnostics related to the default constraing#53839

Merged
BillWagner merged 7 commits into
dotnet:mainfrom
BillWagner:new-constraints-csharp9
May 13, 2026
Merged

Document compiler diagnostics related to the default constraing#53839
BillWagner merged 7 commits into
dotnet:mainfrom
BillWagner:new-constraints-csharp9

Conversation

@BillWagner
Copy link
Copy Markdown
Member

@BillWagner BillWagner commented May 13, 2026

Fixes #53547

Add the diagnostic codes fro the default constraint. In addition, sweep for other errors and warnings related to generic constraints.

Clean up existing related files, and add other related (but undocumented) diagnostics.

Because this added quite a few errors codes, the main file got a substantial rewrite and reorganization.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/compiler-messages/generic-type-parameters-errors.md Resolve errors and warnings related to generic type parameters and generic type arguments
docs/csharp/language-reference/toc.yml docs/csharp/language-reference/toc
docs/csharp/misc/sorry-we-don-t-have-specifics-on-this-csharp-error.md Coming in C# 15
docs/csharp/programming-guide/generics/generic-methods.md "Generic Methods"

Add more existing error codes related to generic constraints.
Found additional related undocumented errors from earlier versions.
Reorganize the sections of this file in light of the new items that have been added.
Make sure all error messages match the roslyn version.
Copy link
Copy Markdown
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 updates the C# compiler-diagnostics documentation by consolidating many generic-constraint-related diagnostics (including the C# 9 default constraint diagnostics) into the existing “generic type parameters and type arguments” hub page, and removing older per-diagnostic pages in favor of redirects.

Changes:

  • Expanded and reorganized generic-type-parameters-errors.md to include additional generic constraint diagnostics (including default constraint diagnostics) and related guidance.
  • Removed multiple docs/csharp/misc/cs*.md diagnostic pages (and cs1763.md) that are now covered by the consolidated hub page.
  • Updated C# language reference TOC entries and added redirects so old URLs continue to resolve.

Reviewed changes

Copilot reviewed 19 out of 19 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 Removes diagnostics that are now documented elsewhere from the “undocumented errors” keyword list.
docs/csharp/misc/cs3024.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs1948.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs1720.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0718.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0704.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0701.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0699.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0693.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0456.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0453.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0452.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0411.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0409.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/misc/cs0406.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
docs/csharp/language-reference/toc.yml Updates the TOC’s generic diagnostics entry keywords and removes TOC entries for deleted per-diagnostic pages.
docs/csharp/language-reference/compiler-messages/generic-type-parameters-errors.md Major rewrite/reorganization to document additional generic constraints diagnostics (including default constraint).
docs/csharp/language-reference/compiler-messages/cs1763.md Deleted; content is now covered by the consolidated generic diagnostics page (with redirect).
.openpublishing.redirection.csharp.json Adds redirects from removed diagnostic pages to the consolidated generic diagnostics page.
Comments suppressed due to low confidence (1)

docs/csharp/language-reference/compiler-messages/generic-type-parameters-errors.md:166

  • CS0312/CS0313 message text differs between the top diagnostic list and the later section (the summary repeats the 'type1' placeholder in the second sentence, but the detailed section doesn’t). Align the wording so readers (and search engines) see one consistent message form for each diagnostic.
- [**CS0312**](#constraint-satisfaction-and-conversions): *The type 'type1' cannot be used as type parameter in the generic type or method. The nullable type 'type1' does not satisfy the constraint of 'constraint'.*
- [**CS0313**](#constraint-satisfaction-and-conversions): *The type 'type1' cannot be used as type parameter in the generic type or method. The nullable type 'type1' does not satisfy the constraint of 'constraint'. Nullable types can not satisfy any interface constraints.*
- [**CS0314**](#constraint-satisfaction-and-conversions): *The type cannot be used as type parameter in the generic type or method. There is no boxing conversion or type parameter conversion from 'type' to 'constraint'.*

@BillWagner BillWagner marked this pull request as ready for review May 13, 2026 15:36
@BillWagner BillWagner requested a review from a team as a code owner May 13, 2026 15:36
@BillWagner BillWagner merged commit 99a279f into dotnet:main May 13, 2026
9 checks passed
@BillWagner BillWagner deleted the new-constraints-csharp9 branch May 13, 2026 16:33
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.

[C# Diagnostics] - new constraints

3 participants