Skip to content

AV2400: Formatting of expression bodied members and dictionary initializers #109

@bkoelman

Description

@bkoelman

Existing rule:

Use a common layout (AV2400)
Then follows a bulleted list for formatting rules...

New language features to consider:

  • dictionary initializers
    We can update the existing example for object/collection initializers to:
var dto = new ConsumerDto
{
    Id = 123,
    Name = "Microsoft",
    PartnerShip = PartnerShip.Gold,
    ShoppingCart =
    {
        ["VisualStudio"] = 1
    }
};

Changes: remove () on first line; add dictionary initializer; add missing semicolon at end; correct casing of "object Initializers" in bullet text

  • expression bodied members
    The default settings of Resharper (current version at the time of writing is v2017.2.2) break long lines after the arrow. Example:
private string GetLongText =>
    "ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC ABC";

I propose to add an extra bullet for that formatting.

Additional notes:

  • "Don't indent lambda statements..." should be: "Don't indent lambda statement blocks..."

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