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

LeadingComments affect breaking #149

Closed
belav opened this issue Apr 26, 2021 · 1 comment · Fixed by #164 or #170
Closed

LeadingComments affect breaking #149

belav opened this issue Apr 26, 2021 · 1 comment · Fixed by #164 or #170
Labels
area:formatting type:bug Something isn't working
Milestone

Comments

@belav
Copy link
Owner

belav commented Apr 26, 2021

This affects ConstructorDeclarationSyntax and BaseMethodDeclarationSyntax.
IfStatementSyntax was easy to pull out the LeadingTrivia. This was less obvious. But looking at that may help.

Expected Formatting

namespace SomeNamespace
{
    public class ClassName
    {
        public void Exactly80(IApplicationBuilder app, IWebHostEnvironment env)
        {
            return;
        }

        // this shouldn't affect breaking
        public void Exactly80(IApplicationBuilder app, IWebHostEnvironment env)
        {
            return;
        }
    }
}

Actual Formatting

namespace SomeNamespace
{
    public class ClassName
    {
        public void Exactly80(IApplicationBuilder app, IWebHostEnvironment env)
        {
            return;
        }

        // this shouldn't affect breaking
        public void Exactly80(
            IApplicationBuilder app,
            IWebHostEnvironment env
        ) {
            return;
        }
    }
}
@belav belav added type:bug Something isn't working area:formatting labels Apr 26, 2021
@belav belav closed this as completed Apr 26, 2021
@belav belav reopened this Apr 26, 2021
belav added a commit that referenced this issue May 3, 2021
@belav belav added this to the 0.9.1 milestone May 3, 2021
@belav belav closed this as completed in #164 May 3, 2021
@belav belav reopened this May 3, 2021
@belav
Copy link
Owner Author

belav commented May 3, 2021

There are some more edge cases that need to be handled

public class ClassName
{
    void Method()
    {
        var fileContents = File.ReadAllText(file,
                // leading here should break parameters
                encoding ? GetEncoding(1252) : encoding, cancellationToken);

        var fileContents = File.ReadAllText(
            file,
                // leading here should break parameters and GetEncoding should still group
                encoding ? File.GetEncodinggggggggggggggg(
                        1252
                    ) : encodinggggggggggggggg,
            cancellationToken
        );

        var editorConfig = new Dictionary<string, string>() {
            // should break braces correctly
            ["asdfasdf"] = "none", ["asdf"] = "error", };
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:formatting type:bug Something isn't working
Projects
None yet
1 participant