Report when an abstract class declares a member marked with [ClassInitialize] without specifying the inheritance behavior.
Background and Motivation
When an abstract class is declaring a ClassInitialize member without specifying the inheritance behavior, then this member will simply be ignored so we should flag the case.
Proposed Feature
Scenarios to flag:
[TestClass]
public abstract class BaseClass
{
[ClassInitialize]
public static void ClassInit(TestContext context)
{
}
}
public abstract class BaseClass
{
[ClassInitialize]
public static void ClassInit(TestContext context)
{
}
}
Valid scenario:
[TestClass]
public abstract class BaseClass
{
[ClassInitialize(Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior.BeforeEachDerivedClass)]
public static void ClassInit(TestContext context)
{
}
}
or
public abstract class BaseClass
{
[ClassInitialize(Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior.BeforeEachDerivedClass)]
public static void ClassInit(TestContext context)
{
}
}
Summary
Report when an
abstract
class declares a member marked with[ClassInitialize]
without specifying the inheritance behavior.Background and Motivation
When an
abstract
class is declaring aClassInitialize
member without specifying the inheritance behavior, then this member will simply be ignored so we should flag the case.Proposed Feature
Scenarios to flag:
Valid scenario:
or