Skip to content

StyleCop SA1011 Rule Blocks Nullable Array Declaration #475

@Kalkwst

Description

@Kalkwst

Describe the bug
The StyleCop rule SA1011 ("Closing square brackets must be followed by a space") incorrectly prevents declaring nullable arrays, where the ? operator is used directly after the closing []. The rule currently enforces a space between the closing square bracket ] and the nullable operator ?, which is syntactically incorrect and blocks proper nullable array usage.

To Reproduce

  1. Create a C# file and attempt to declare a nullable array.
int[]? nyNummableArray = null;

Expected behavior
StyleCop should allow the ? operator to be placed immediately after the closing square bracket [] in a nullable array declaration, as this is valid syntax in C#.

Actual behavior
StyleCop reports an SA1011 violation:

SA1011: Closing square bracket must be followed by a space.

This causes an error, suggesting that there should be a space between ] and ?, which is syntactically invalid in C#.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions