Skip to content

Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"#54559

Merged
sharwell merged 19 commits intodotnet:mainfrom
paul1956:IssueFormatter36891
Nov 8, 2021
Merged

Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"#54559
sharwell merged 19 commits intodotnet:mainfrom
paul1956:IssueFormatter36891

Conversation

@paul1956
Copy link
Contributor

@paul1956 paul1956 commented Jul 2, 2021

Issue #36891 There are some VB constants in C# Abstract function that needs to be addressed and C# code needs to be cleaned up and not look like it was written by VB programmer. All "Line Continuation" Tests pass. I await all tests to run.

… function that needs to be addressed and C# code needs to be cleaned up and not look like it was written by VB programmer.
@paul1956 paul1956 requested a review from a team as a code owner July 2, 2021 03:52
@ghost ghost added the Area-IDE label Jul 2, 2021
Private _
Shared _
_
_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😕 It seems like this one should have been removed altogether

Suggested change
_

Copy link
Contributor Author

@paul1956 paul1956 Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell They were not in the original design even before I added "comments" after Line Continuation all I did was move the underscore to a more appropriate place. Many of the tests expect the same results with and without the comments. You can see the original behavior on line 724 before my change.

        <Theory, Trait(Traits.Feature, Traits.Features.Formatting)>
        <InlineData("_")>
        <InlineData("_ ' Comment")>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. We should file a follow-up issue to prevent the extraneous continuation as a separate change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell Agreed, I think it is rare someone would actually do it without a comment but I can enter an issue. It will require duplicating all the tests which today use InlineData.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell This might be better handled by IDE2000 and/or RS0101 and the code fixes for them as a separate PR. Today I can type lots of blank lines and nothing stops me but I do get the two warmings above.

@sharwell sharwell added the Need Design Review The end user experience design needs to be reviewed and approved. label Jul 2, 2021
paul1956 and others added 11 commits July 1, 2021 23:54
…/InlineTemporaryTests.vb

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
…orsTests.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
…nuationTests.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
…nuationTests.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
…nuationTests.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
… and in C# return false for first and correct value for second but its not used.

var list = new TriviaList(this.Token1.TrailingTrivia, this.Token2.LeadingTrivia);
var i = -1;
var previousLineColumn = new LineColumn();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you doc what this is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 It feels like this local variable is hard-coding logic that is designed to be provided by implementations of GetLineColumnRuleBetween and/or GetAdjustSpacesOperation (which are called by FormatFirstTriviaAndWhitespaceAfter below). If GetLineColumnRuleBetween/GetAdjustSpacesOperation return the correct value, then FormatFirstTriviaAndWhitespaceAfter will also return the correct value and it looks like all of the changes in this file become unnecessary (some of the logic would move into the space adjustment rule, but would no longer be applied in such a general location).

@paul1956
Copy link
Contributor Author

paul1956 commented Jul 25, 2021

@jinujoseph Ping

@sharwell
Copy link
Contributor

Design review conclusion: the formatting of continuation characters demonstrated by this PR is acceptable.

Comment on lines +79 to +82
result.HasTabAfterSpace = False
result.Space = 0
result.Tab = 0
result.TreatAsElastic = result.TreatAsElastic Or trivia.IsElastic()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ What happens if these three lines are left in their original location?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharwell 4 tests fail for example ColonToken_If with whitepace NOT removed

Expected: ···        If True Then\r\n        End If\r\n    End Sub\r\nEnd Class
   Actual:   ···        If True Then \r\n        End If\r\n    End Sub\r\nEnd Class


var list = new TriviaList(this.Token1.TrailingTrivia, this.Token2.LeadingTrivia);
var i = -1;
var previousLineColumn = new LineColumn();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 It feels like this local variable is hard-coding logic that is designed to be provided by implementations of GetLineColumnRuleBetween and/or GetAdjustSpacesOperation (which are called by FormatFirstTriviaAndWhitespaceAfter below). If GetLineColumnRuleBetween/GetAdjustSpacesOperation return the correct value, then FormatFirstTriviaAndWhitespaceAfter will also return the correct value and it looks like all of the changes in this file become unnecessary (some of the logic would move into the space adjustment rule, but would no longer be applied in such a general location).

@paul1956
Copy link
Contributor Author

@sharwell Regarding "local variable is hard-coding", I don't see how those 2 functions have to context to understand that " _ ' comment" has special meaning. The way they are written forces 2 extra spaces on every line. They only look at 2 trivia and I need to look at 4 or more.

@paul1956
Copy link
Contributor Author

ping

@paul1956
Copy link
Contributor Author

Ping @sharwell @CyrusNajmabadi

@sharwell sharwell removed the Need Design Review The end user experience design needs to be reviewed and approved. label Sep 7, 2021
@paul1956
Copy link
Contributor Author

@sharwell Is there anything else I need to do to move this forward?

@paul1956
Copy link
Contributor Author

Ping
anything else needed to move forward?

@paul1956
Copy link
Contributor Author

paul1956 commented Nov 8, 2021

Ping @sharwell @CyrusNajmabadi what is needed to finish this?

@dotnet dotnet deleted a comment from azure-pipelines bot Nov 8, 2021
@sharwell
Copy link
Contributor

sharwell commented Nov 8, 2021

@paul1956 it looks like a few unit tests are failing. The integration test failures have been resolved separately and should not affect future builds from this branch.

Edit: I pushed e628e3b to fix these issues.

image

@sharwell

This comment has been minimized.

@sharwell sharwell enabled auto-merge November 8, 2021 16:45
@paul1956
Copy link
Contributor Author

paul1956 commented Nov 8, 2021

@sharwell thanks

@sharwell sharwell merged commit 04e4e5e into dotnet:main Nov 8, 2021
@ghost ghost added this to the Next milestone Nov 8, 2021
@sharwell
Copy link
Contributor

sharwell commented Nov 8, 2021

🎉 I'm so happy this finally passed/merged

Thanks @paul1956 !

@paul1956
Copy link
Contributor Author

paul1956 commented Nov 8, 2021

Thanks for all your help. Any idea when I might see it in VS?

@sharwell
Copy link
Contributor

sharwell commented Nov 8, 2021

Visual Studio 2022 version 17.1 Preview 2

allisonchou pushed a commit to allisonchou/roslyn that referenced this pull request Nov 11, 2021
Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"
@allisonchou allisonchou modified the milestones: Next, 17.1.P2 Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants