dotnet/roslyn

Unexpected formatting when attribute is on same line as property with default value

Open

#50,017 opened on Dec 16, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)C# (4,257 forks)batch import
Area-IDEBugIDE-Formatterhelp wanted

Repository metrics

Stars
 (20,414 stars)
PR merge metrics
 (Avg merge 6d 17h) (256 merged PRs in 30d)

Description

The code

namespace Foo
{
    public class Bar
    {
        [Parameter] public DelegateType Value { get; set; } = (value, second) => (builder) =>
        {
            builder.Baz();
        };
    }
}

reformats to

namespace Foo
{
    public class Bar
    {
        [Parameter]
        public DelegateType Value { get; set; } = (value, second) => (builder) =>
{
builder.Baz();
};
    }
}

I would expect

namespace Foo
{
    public class Bar
    {
        [Parameter]
        public DelegateType Value { get; set; } = (value, second) => (builder) =>
        {
            builder.Baz();
        };
    }
}

or actually to do nothing at all.


dotnet format version is 4.1.131201

Contributor guide