Skip to content

IDE0063 code fixer deletes comments nearby using statement or curly braces #48586

@Tan90909090

Description

@Tan90909090

Version Used: Visual Studio 2019 Version 16.7.5

Steps to Reproduce:

  1. Write a following code, which has an IDE0063 'using' statement can be simplified:
using System;
using System.IO;

class C
{
    static void Main()
    {
        using (var s = new MemoryStream()) // foo
        { // bar
            Console.WriteLine(s.CanRead); // Only this comment remains.
        } // baz
    }
}
  1. Apply the Use simple 'using' statement

Expected Behavior:
All comments remain like this:

using System;
using System.IO;

class C
{
    static void Main()
    {
        using var s = new MemoryStream(); // foo
        // bar
        Console.WriteLine(s.CanRead); // Only this comment remains.
        // baz
    }
}

Actual Behavior:
"foo", "bar", "baz" comments are deleted:

using System;
using System.IO;

class C
{
    static void Main()
    {
        using var s = new MemoryStream();
        Console.WriteLine(s.CanRead); // Only this comment remains.
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEConcept-Continuous ImprovementIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions