Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"#54559
Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"#54559sharwell merged 19 commits intodotnet:mainfrom paul1956:IssueFormatter36891
Conversation
… function that needs to be addressed and C# code needs to be cleaned up and not look like it was written by VB programmer.
| Private _ | ||
| Shared _ | ||
| _ | ||
| _ |
There was a problem hiding this comment.
😕 It seems like this one should have been removed altogether
| _ |
There was a problem hiding this comment.
@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")>
There was a problem hiding this comment.
Makes sense. We should file a follow-up issue to prevent the extraneous continuation as a separate change.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
@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.
src/EditorFeatures/VisualBasicTest/CodeActions/InlineTemporary/InlineTemporaryTests.vb
Outdated
Show resolved
Hide resolved
src/Workspaces/CoreTest/CodeCleanup/NormalizeModifiersOrOperatorsTests.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CoreTest/CodeCleanup/RemoveUnnecessaryLineContinuationTests.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CoreTest/CodeCleanup/RemoveUnnecessaryLineContinuationTests.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/CoreTest/CodeCleanup/RemoveUnnecessaryLineContinuationTests.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...kspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/LineColumnRule.cs
Outdated
Show resolved
Hide resolved
…/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.
...aredUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...aredUtilitiesAndExtensions/Compiler/CSharp/Formatting/Engine/Trivia/CSharpTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
src/Workspaces/VisualBasic/Portable/Formatting/Engine/Trivia/TriviaDataFactory.Analyzer.vb
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Show resolved
Hide resolved
|
|
||
| var list = new TriviaList(this.Token1.TrailingTrivia, this.Token2.LeadingTrivia); | ||
| var i = -1; | ||
| var previousLineColumn = new LineColumn(); |
There was a problem hiding this comment.
can you doc what this is for?
There was a problem hiding this comment.
💭 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).
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Show resolved
Hide resolved
|
@jinujoseph Ping |
|
Design review conclusion: the formatting of continuation characters demonstrated by this PR is acceptable. |
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...haredUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/AbstractTriviaFormatter.cs
Outdated
Show resolved
Hide resolved
...kspaces/SharedUtilitiesAndExtensions/Compiler/Core/Formatting/TriviaEngine/LineColumnRule.cs
Outdated
Show resolved
Hide resolved
| result.HasTabAfterSpace = False | ||
| result.Space = 0 | ||
| result.Tab = 0 | ||
| result.TreatAsElastic = result.TreatAsElastic Or trivia.IsElastic() |
There was a problem hiding this comment.
❔ What happens if these three lines are left in their original location?
There was a problem hiding this comment.
@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(); |
There was a problem hiding this comment.
💭 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).
|
@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. |
|
ping |
|
Ping @sharwell @CyrusNajmabadi |
|
@sharwell Is there anything else I need to do to move this forward? |
|
Ping |
|
Ping @sharwell @CyrusNajmabadi what is needed to finish this? |
This comment has been minimized.
This comment has been minimized.
|
@sharwell thanks |
|
🎉 I'm so happy this finally passed/merged Thanks @paul1956 ! |
|
Thanks for all your help. Any idea when I might see it in VS? |
|
Visual Studio 2022 version 17.1 Preview 2 |
Initial fix for issue "VB Formatting of LineContinuation Wrong after _ ' Comment"

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.