Document compiler diagnostics related to the default constraing#53839
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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.mdto include additional generic constraint diagnostics (includingdefaultconstraint diagnostics) and related guidance. - Removed multiple
docs/csharp/misc/cs*.mddiagnostic pages (andcs1763.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'.*
gewarren
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #53547
Add the diagnostic codes fro the
defaultconstraint. 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