Skip to content

Support for init-only setter for CA2227: Collection properties should be read only #24971

@madewithsmiles

Description

@madewithsmiles

Hi, there is no mention about the new init-only (init;) setter feature of C# 9 - https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/init.

From my understanding of this rule, there should not be a violation for properties with init-only setters. If that's the case, how to update this doc and the potential (Roslyn?) analyzer? Thank you :)


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions