Skip to content

Avoid wrapping method arguments including a block-bodied lambda #1186

@jcracknell

Description

@jcracknell

Input:

await SessionManager.Session(cancellationToken, async context =>
{
    var records = await context
        .DbContext.Entity.AsNoTracking()
        .Where(
            context.DbContext.PredicateFor(criteria).TranslatedBy(MkEntityPredicates)
        )
        .ToListAsync(context.CancellationToken);

    var entities = await MarshalEntities(records);

    return entities.ToImmutableDictionary(e => e.Id.Value);
});

Output:

await SessionManager.Session(
    cancellationToken,
    async context =>
    {
        var records = await context
            .DbContext.Entity.AsNoTracking()
            .Where(
                context.DbContext.PredicateFor(criteria).TranslatedBy(MkEntityPredicates)
            )
            .ToListAsync(context.CancellationToken);

        var entities = await MarshalEntities(records);

        return entities.ToImmutableDictionary(e => e.Id.Value);
    }
);

Expected behavior:

It would be nice if the formatter could avoid wrapping arguments to method calls where the call includes a block-bodied lambda on the assumption that the method call represents some form of flow control.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions