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

Allow blank lines in query syntax #754

Closed
belav opened this issue Nov 11, 2022 · 0 comments · Fixed by #814
Closed

Allow blank lines in query syntax #754

belav opened this issue Nov 11, 2022 · 0 comments · Fixed by #814

Comments

@belav
Copy link
Owner

belav commented Nov 11, 2022

Discussed in https://github.com/belav/csharpier/discussions/750

Originally posted by TwentyFourMinutes November 2, 2022
Currently when you have a linq syntax query it will produce something like the following:

var result = await (
    from post in dbContext.Posts
    where post.Id == 1
    select post
)
    .AsNoTracking()
    .FirstAsync();

which seems fine at first, however, these queries can get quite large fairly quickly. We currently manually format it with empty lines e.g.

var result = await (
    from post in dbContext.Posts
    join blog in dbContext.Blogs on post.BlogId equals blog.Id
    
    let count = dbContext.Posts.Count(p => p.Name == post.Name)
    
    where post.Id == 1
    select new 
    {
         Post = post,
         Blog = blog,
         SamePostNameCount = count
    }
)
    .AsNoTracking()
    .FirstAsync();

Anyhow, csharpier would strip out empty lines which can get very unreadable on even larger queries.

Proposal:
Allow single blank lines between two statements, but truncate more than that down to 1.

Do you have had any thoughts on this yet? Or on this rather small proposal?

@belav belav added this to the 1.0.0 milestone Nov 11, 2022
@belav belav modified the milestones: 0.21.0, 0.22.0 Nov 28, 2022
@belav belav modified the milestones: 0.22.0, 0.23.0 Jan 14, 2023
belav added a commit that referenced this issue Jan 30, 2023
@belav belav closed this as completed in #814 Feb 4, 2023
@belav belav closed this as completed in c32bbfd Feb 4, 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.

1 participant