Skip to content

SA1206 does not correctly handle the required keyword ordering #3928

Open
@ThiagoDSMarcelino

Description

@ThiagoDSMarcelino

According to the SA1206 documentation, keywords should appear in the following order:

  1. Access modifiers
  2. static
  3. All other keywords

However, when using the required keyword, the analyzer incorrectly reports a warning:

public sealed class Foo
{
    public required string Bar { get; set; }
}

// Warning: "The 'required' modifier should appear before 'public'"

This behavior seems inconsistent with the documented ordering rules. The required keyword should fall under "All other keywords," appearing after the access modifier.

Could you please clarify whether this is an issue in the analyzer or a documentation gap regarding the ordering of required?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions