microsoft / testfx

MSTest framework and adapter
MIT License
738 stars 255 forks source link

MSTEST0008: Invalid signature detection not working in generic class #3475

Closed AliveDevil closed 2 months ago

AliveDevil commented 2 months ago

Describe the bug

When writing generic base-class tests, including TestInitializers/TestCleanups MSTEST0008 is set erroneously.

Steps To Reproduce

[TestClass]
public class ConcreteTest : B<ConcreteTest>
{
    [TestMethod]
    public void Test()
    {
        Assert.IsNotNull(SharedState);
    }
}

//[TestClass] // has no effect
public abstract class B<T> where T : B<T>
{
    protected object SharedState { get; private set; }

    [TestInitialize]
    public void TestSetup() // MSTEST0008
    {
        SharedState = new();
    }
}

Expected behavior

In an abstract generic class, when [TestInitialize] is technically valid, MSTEST0008 shouldn't be warned.

Actual behavior

MSTEST0008 is falsely emitted.

Evangelink commented 2 months ago

Hi @AliveDevil,

Thanks for the report. This is duplicating #3276. I am in the process of releasing a bug fix version.

AliveDevil commented 2 months ago

Ah, didn't see that. Thanks :)

Evangelink commented 2 months ago

No worries! It's easier for me to recall what I have seen :) Also my ticket title kinda sucks :P