csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Incorrect formatting for simple lambda expression with comment

Open Rudomitori opened this issue 1 year ago • 1 comments

Input:

services.AddMetricsTrackingMiddleware(
    // Comment
    opts =>
    {
        opts.IgnoredHttpStatusCodes = Enumerable.Range(300, 9).ToArray();
    }
);

Output:

services.AddMetricsTrackingMiddleware(
    // Comment
    opts =>
{
    opts.IgnoredHttpStatusCodes = Enumerable.Range(300, 9).ToArray();
});

Expected behavior:

services.AddMetricsTrackingMiddleware(
    // Comment
    opts =>
    {
        opts.IgnoredHttpStatusCodes = Enumerable.Range(300, 9).ToArray();
    }
);

I sure this bug is caused by my changes in #1066. I totally forgot about cases with comments

Rudomitori avatar Jan 24 '24 08:01 Rudomitori

I've found that comments tend to cause a lot of edge cases like this, and I don't know that there is a good generic fix for it beyond just addressing them as they come up.

belav avatar Jan 31 '24 18:01 belav