Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2699 Reproducer for AssertionMethodAttribute is ignored when assertion method is inherited #6528

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,11 +7,14 @@ namespace CustomTests
using TestFramework.Attributes;

[TestClass]
public class Program
public class BaseTest
{
[AssertionMethod]
protected virtual void CustomAssertionMethod() { }

[TestMethod]
public void TestMethod1() // Noncompliant {{Add at least one assertion to this test case.}}
// ^^^^^^^^^^^
// ^^^^^^^^^^^
{
var x = 42;
}
Expand Down Expand Up @@ -56,6 +59,20 @@ public class Program
var x = 42;
}
}

[TestClass]
public class DerivedTest : BaseTest
{
[TestMethod]
public void Derived() // Noncompliant FP: The overridden method needs to be annotated because Roslyn does not respect AttributeUsage.Inherited in ISymbol.GetAttributes
{
CustomAssertionMethod();
}

protected override void CustomAssertionMethod()
{
}
}
}

namespace TestFramework
Expand Down