Skip to content

Avoid chopping single trailing lambda#1876

Draft
mattwzawislak wants to merge 3 commits into
belav:mainfrom
mattwzawislak:feature/1865-dont-chop-lambda
Draft

Avoid chopping single trailing lambda#1876
mattwzawislak wants to merge 3 commits into
belav:mainfrom
mattwzawislak:feature/1865-dont-chop-lambda

Conversation

@mattwzawislak

@mattwzawislak mattwzawislak commented Jun 13, 2026

Copy link
Copy Markdown

Description

Adds in the ability to avoid chopping single trailing lambdas when the argument list up to and including the "=>" symbol doesn't need to be chopped.

This would take a snippet of code like

logging.AddFile(
    Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "server{0}.log"),
    o =>
    {
        o.MaxRollingFiles = 1;
        // ...
    }
);

And turn it into this (assuming configured line length isn't exceeded):

logging.AddFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "server{0}.log"), o =>
{
    o.MaxRollingFiles = 1;
    // ...
});

Without breaking directives or comments:

logging.AddFile(
#if DEBUG
    Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "server{0}.log"),
#else
    "server{0}.log",
#endif
    o =>
    {
        o.MaxRollingFiles = 1;
        // ...
    }
);

And avoids chopping when the lambda is not the last argument or there are multiple arguments:

logging.AddFile(
    "server{0}.log",
    cfg => cfg.Section("logging"),
    o =>
    {
        o.MaxRollingFiles = 1;
        // ...
    }
);

Related Issue

Closes #1865

Checklist

  • My code follows the project's code style
    • always var
    • follow existing naming conventions
    • always this.
    • no pointless comments
  • I will not force push after a code review of my PR has started
  • I have added tests that cover my changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Avoid chopping single trailing lambda

1 participant