Skip to content

Lambda expressions with attributes are formatted incorrectly #56543

@PathogenDavid

Description

@PathogenDavid

Version Used: Visual Studio 2022 Preview 4, Compiler version: '4.0.0-4.21458.2 (2bfff7b)'. Language version: 10.0.

Steps to Reproduce:

  1. In a new .NET 6 console project, populate Program.cs with the following:
var a = [A] short () => 100;
var b = [A] () => 100;
var c = short () => 100;

public sealed class AAttribute : Attribute { }
  1. Format the document using Edit -> Advanced -> Format Document or run Code Cleanup

Expected Behavior:

No changes, the code is well-formatted.

Actual Behavior:

The space between the assignment operator and the attribute is removed:

var a =[A] short () => 100;
var b =[A] () => 100;
var c = short () => 100;

public sealed class AAttribute : Attribute { }

As far as I know there is not an editorconfig setting for the spaces around the assignment operator, but to remove any doubt I also reproduced this with with Roslyn's .editorconfig.

Relates to test plan #52192

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Active/Investigating

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions