Skip to content

SA1013 Allow } to start a line in interpolated string #3914

@morsiu

Description

@morsiu
Contributor

Currently, SA1013 interferes in situations where I would like to split very long interpolated strings into multiple lines, or when tooling like Resharper does that when formatting code.
This can be seen in the following example code:

var message =
    $"This a very long message with id {
        id
    }, that is easier to read when split into multiple lines ({
        numberOfLines
    } lines). Some additional expression to make it even longer: {
        (foobarbaz * xyz) / (foobarbaz + xyz)
    }";

Here, SA1013 generates warnings on lines starting with } (i.e. lines 4, 6 and 8).
The warning is that } should not be preceded by whitespace.
My suggestion is to not generate these warning in this case.

Activity

added a commit that references this issue on Feb 6, 2025
4e05ed0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @morsiu

      Issue actions

        SA1013 Allow } to start a line in interpolated string · Issue #3914 · DotNetAnalyzers/StyleCopAnalyzers