CSharpEssentials icon indicating copy to clipboard operation
CSharpEssentials copied to clipboard

CSE0003 Multiline comments are truncated

Open NimeshDhruve opened this issue 10 years ago • 2 comments

When a single line return is followed by multiple line comments refactoring removes all but first line.

example

The same doesn't happen if the comments are inside /*.......*/ block.

anotherexample

NimeshDhruve avatar Oct 14 '15 18:10 NimeshDhruve

Could you provide the actual code that fails? I'm having trouble getting that second example from just the preview (since it's truncated :smile:).

DustinCampbell avatar Nov 05 '15 19:11 DustinCampbell

Sure thing, just to be clear it doesn't fail but removes comments.

Original Code

class RefactoringDemo
{
    public int MyProperty { get; set; }
    public override string ToString()
    {
        return $"MyProperty: {MyProperty}"; //  This is demo for multi line comments
                                            //1) This is line 1
                                            //2) This is line 2         
    }


    public string AnotherExample()
    {
        return $"MyProperty: {MyProperty}"; /*  This is demo for multi line comments
                                            //1) This is line 1
                                            //2) This is line 2     
                                            */
    }
}

Refactored code (have a look at comment inside ToString() method)

class RefactoringDemo
{
    public int MyProperty { get; set; }
    public override string ToString() => $"MyProperty: {MyProperty}"; //    This is demo for multi line comments


    public string AnotherExample() => $"MyProperty: {MyProperty}"; /*   This is demo for multi line comments
                                            //1) This is line 1
                                            //2) This is line 2     
                                            */
}

NimeshDhruve avatar Nov 10 '15 14:11 NimeshDhruve