Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ static TestClass_DualConstructor() { }
[Fact] public void TestMethod() { }
}

public class InheritedTestClass_DefaultConstructor : AbstractTestClass { }

public class {|#1:InheritedTestClass_DualConstructor|} : AbstractTestClass {
public InheritedTestClass_DualConstructor() { }
public InheritedTestClass_DualConstructor(int x) { }
}

// Fixture constructors

public class Fixture_DefaultConstructor { }
Expand Down Expand Up @@ -101,6 +108,7 @@ public class {|#11:CollectionFixtureContainer|} :
""";
var expected = new[] {
Verify.Diagnostic().WithLocation(0).WithArguments("Test class", "TestClass_DualConstructor"),
Verify.Diagnostic().WithLocation(1).WithArguments("Test class", "InheritedTestClass_DualConstructor"),

Verify.Diagnostic().WithLocation(10).WithArguments("Fixture", "Fixture_DualConstructor"),
Verify.Diagnostic().WithLocation(10).WithArguments("Fixture", "Fixture_Abstract"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ [Fact] public void TestMethod() { }
public class {|#1:Theory_TestClass_Suppresses|} {
[Theory] public void TestMethod() { }
}

public abstract class {|#2:BaseTestClass_Suppresses|} {
[Fact] public void TestMethod() { }
}

public class {|#3:InheritedTestClass_Suppresses|} : BaseTestClass_Suppresses { }
""";
var expected = new[] {
new DiagnosticResult("CA1515", DiagnosticSeverity.Warning).WithLocation(0).WithIsSuppressed(true),
new DiagnosticResult("CA1515", DiagnosticSeverity.Warning).WithLocation(1).WithIsSuppressed(true),
new DiagnosticResult("CA1515", DiagnosticSeverity.Warning).WithLocation(2).WithIsSuppressed(true),
new DiagnosticResult("CA1515", DiagnosticSeverity.Warning).WithLocation(3).WithIsSuppressed(true),
};

await Verify.VerifySuppressor(code, CodeAnalysisNetAnalyzers.CA1515(), expected);
Expand Down
2 changes: 1 addition & 1 deletion src/xunit.analyzers/Utility/CodeAnalysisExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static bool IsTestClassNonStrict(

return
type
.GetMembers()
.GetInheritedAndOwnMembers()
.OfType<IMethodSymbol>()
.Any(method =>
method
Expand Down