Skip to content

MT1003 auto-fix doesn't work as expected #7

@superfaz

Description

@superfaz

How to reproduce

Create a test class with documentation like:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        /// <summary>
        /// Tests the <see cref="MyClass.MyClass"/> constructor.
        /// </summary>
        public void Constructor()
        {
        }
    }
}

Use the auto-fix feature for MT1003, result is:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        [TestMethod]
          /// <summary>
                              /// Tests the <see cref="MyClass.MyClass"/> constructor.
                              /// </summary>
        public void Constructor()
        {
        }
    }
}

Expected result

  • The using reference should not be doubled
  • The [TestMethod] should be between the comment and the method signature
  • The method comment should remain untouched

The result of the auto-fix should be:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MyTest
{
    /// <summary>
    /// Tests the <see cref="MyClass"/> class.
    /// </summary>
    [TestClass]
    public class MyClassTest
    {
        /// <summary>
        /// Tests the <see cref="MyClass.MyClass"/> constructor.
        /// </summary>
        [TestMethod]
        public void Constructor()
        {
        }
    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions