Skip to content

Update CS0449 documentation to include all constraint types #47687

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
Aug 4, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 31, 2025

The CS0449 compiler error documentation was outdated and only mentioned 'class' and 'struct' constraints, but the current compiler error message includes additional constraint types: 'unmanaged', 'notnull', and 'default'.

This PR updates the documentation to:

  1. Match current compiler error message: Updated the error description to include all 5 constraint types that can trigger CS0449
  2. Clarify constraint ordering rules: Expanded explanation of how these "primary constraints" must be specified first and cannot be combined
  3. Add comprehensive examples: Added 4 new example violations showing issues with the additional constraint types:
    • Combining class and notnull (invalid in nullable context since class implies notnull)
    • Combining unmanaged and struct (invalid since unmanaged implies struct)
    • Incorrect ordering of unmanaged constraint
    • Combining notnull and default constraints
  4. Cross-reference documentation: Added link to the comprehensive constraints documentation page
  5. Special case note: Highlighted that class already implies notnull in nullable contexts

The updated documentation now provides developers with complete information about all constraint combinations that can cause CS0449 errors, making it easier to understand and resolve these compilation issues.

Fixes #30785.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/csharp/misc/cs0449.md docs/csharp/misc/cs0449

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Jul 31, 2025
@Copilot Copilot AI changed the title [WIP] CS0449 needs to be updated for 'unmanaged', 'notnull', and 'default' constraints Update CS0449 documentation to include all constraint types Jul 31, 2025
Copilot finished work on behalf of BillWagner July 31, 2025 16:14
@Copilot Copilot AI requested a review from BillWagner July 31, 2025 16:14
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This is ready for final review.

@Copilot Copilot AI requested a review from BillWagner August 1, 2025 18:22
Copilot finished work on behalf of BillWagner August 1, 2025 18:22
@BillWagner BillWagner requested a review from tdykstra August 1, 2025 18:23
@BillWagner BillWagner marked this pull request as ready for review August 1, 2025 18:23
@BillWagner BillWagner requested a review from a team as a code owner August 1, 2025 18:23
@BillWagner BillWagner merged commit 532611d into main Aug 4, 2025
10 checks passed
@BillWagner BillWagner deleted the copilot/fix-30785 branch August 4, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
csharp-errors-warnings/subsvc dotnet-csharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CS0449 needs to be updated for 'unmanaged', 'notnull', and 'default' constraints
3 participants