Skip to content

SA1516: Allow omitting blank lines between property/event accessors #66

@Blaisor

Description

@Blaisor

Currently, SA1516 triggers a violation when a multiline property setter immediately follows a multiline getter without an empty line. While accessors are distinct elements, they are logically part of a single unit. In many professional codebases, including high-profile projects like Newtonsoft.Json, these accessors are kept together without separation to maintain visual cohesion. In fact, I have never seen a codebase where an empty line between a get and set is considered common practice.

public string Description
{
    get
    {
        return _description;
    }
    set // SA1516 triggered here
    {
        _description = value;
    }
}

Proposed change: modify SA1516 to allow (or provide a configuration to allow) omitting blank lines between:

  • get and set accessors
  • add and remove event accessors

Exception: when there is a comment line before the setter/remove.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions