Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linq query is not indented? #811

Closed
jods4 opened this issue Jan 30, 2023 · 0 comments · Fixed by #816
Closed

Linq query is not indented? #811

jods4 opened this issue Jan 30, 2023 · 0 comments · Fixed by #816
Milestone

Comments

@jods4
Copy link

jods4 commented Jan 30, 2023

Source:

public class ClassName
{
    public object LongUglyMethod()
    {
        return from i in Enumerable.Range(0, 10) let i2 = i * i where i2 < 100 select new { Square = i2, Root = i };
    }
}

Result on 0.22.0:

public class ClassName
{
    public object LongUglyMethod()
    {
        return from i in Enumerable.Range(0, 10)
        let i2 = i * i
        where i2 < 100
        select new { Square = i2, Root = i };
    }
}

There is a lack of indentation in LINQ after return.
I think any one of those would be better:

public class ClassName
{
    public object LongUglyMethod()
    {
        // One indent after line break:
        return from i in Enumerable.Range(0, 10)
            let i2 = i * i
            where i2 < 100
            select new { Square = i2, Root = i };
    }
}

public class ClassName
{
    public object LongUglyMethod()
    {
        // Ident + wrap `from` so that it's aligned with rest of query
        return 
            from i in Enumerable.Range(0, 10)
            let i2 = i * i
            where i2 < 100
            select new { Square = i2, Root = i };
    }
}

public class ClassName
{
    public object LongUglyMethod()
    {
        // Align everything on `from`, VS-style.
        return from i in Enumerable.Range(0, 10)
               let i2 = i * i
               where i2 < 100
               select new { Square = i2, Root = i };
    }
}
@belav belav added this to the 0.23.0 milestone Jan 30, 2023
belav added a commit that referenced this issue Jan 30, 2023

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
closes #811
belav added a commit that referenced this issue Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants