Skip to content

Incorrect formatting for simple lambda expression with comment #1147

Closed

Description

@Rudomitori

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

Activity

  1. added this to the Planned milestone on Jan 31, 2024
  2. belav commented on Jan 31, 2024

    @belav
    Owner

    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.

  3. modified the milestones: Planned, 1.3.0 on Mar 15, 2026
  4. added a commit that references this issue on Mar 15, 2026
    c70b664
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

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions