dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.98k stars 4.03k forks source link

Inline Temp should keep comments #1017

Open brettfo opened 9 years ago

brettfo commented 9 years ago

Ported from TFS WorkItem: 580497

🔗 Also filed as AB#1292137


Repro Steps:

Module Program
    Sub Main()
        Dim a = 1, ' comment
            b = 1
        Dim c = a
    End Sub
End Module

Inline a.

ACTUAL:

Module Program
    Sub Main()
        Dim b = 1
        Dim c = 1
    End Sub
End Module

EXPECTED:

Module Program
    Sub Main()
        ' comment
        Dim b = 1
        Dim c = 1
    End Sub
End Module

Revisions:

1) Created By Vladimir Reshetnikov (1/17/2013 10:43:16 AM)


2) Edited By Collin Deel (Chinasoft) (4/11/2014 12:55:31 PM)

Results are now:

Module Program
    Sub Main()
        Dim
            b = 1
        Dim c = 1
    End Sub
End Module

The comment still disappears, and not removing the line break introduces some errors.


3) Edited By Balaji Krishnan (6/18/2014 10:56:18 AM)

Notes: introducing compilation errors is a bug.

Without breaking compilation, the current code's intent is to preserve/move trivia if the local declaration has more than 1 declarators, with a single or multi-line comment and "delete" them completely if there was only 1 variable declarator.

Check how it actually works though.

This is also related with how the feature handles pre-processor directives (Bug 527376)

Pilchie commented 9 years ago

Moving to 1.1 based on current bug bar.