Skip to content
Permalink
Browse files

Fix violations of xUnit2018

This flags call to Assert.IsType/Assert.IsNotType where the given type
is an abstract type. In those cases IsNotType passes (but doesn't
ever assert anything) and IsType will always fail.
  • Loading branch information...
jasonmalinowski committed Sep 4, 2019
1 parent 24e3fd5 commit 0d225430786d09b45abd7f6828ae541a58590fe0
@@ -35,10 +35,6 @@ indent_size = 2
end_of_line = lf
indent_size = 2

# Dotnet diagnostic settings
[*.{cs,vb}]
dotnet_diagnostic.xUnit2018.severity = none # "do not compare an object's exact type to the abstract class" is a valid assert, but very noisy right now

# Dotnet code style settings:
[*.{cs,vb}]
# Sort using and Import directives with System.* appearing first
@@ -157,7 +157,6 @@
<Rule Id="xUnit2013" Action="None" /> <!-- "do not use Assert.Equal() to check for collection size" is a valid assert, but very noisy right now -->
<Rule Id="xUnit2015" Action="None" /> <!-- "do not use typeof() expression to check the exception type. " is a valid assert, but very noisy right now -->
<Rule Id="xUnit2017" Action="None" /> <!-- "do not use Contains() to check if a value exists in a collection" is a valid assert, but very noisy right now -->
<Rule Id="xUnit2018" Action="None" /> <!-- "do not compare an object's exact type to the abstract class" is a valid assert, but very noisy right now -->
</Rules>
<Rules AnalyzerId="Microsoft.VisualStudio.SDK.Analyzers" RuleNamespace="Microsoft.VisualStudio.SDK.Analyzers">
<!-- https://github.com/Microsoft/VSSDK-Analyzers/blob/master/doc/index.md -->
@@ -4262,13 +4262,13 @@ End Class
var @delegate = outer.GetMembers("D").Single();
var error = outer.GetMembers("Error").Single();

Assert.IsNotType<Symbol>(type);
Assert.IsNotType<Symbol>(method);
Assert.IsNotType<Symbol>(property);
Assert.IsNotType<Symbol>(field);
Assert.IsNotType<Symbol>(@event);
Assert.IsNotType<Symbol>(@delegate);
Assert.IsNotType<Symbol>(error);
Assert.False(type is Symbol);
Assert.False(method is Symbol);
Assert.False(property is Symbol);
Assert.False(field is Symbol);
Assert.False(@event is Symbol);
Assert.False(@delegate is Symbol);
Assert.False(error is Symbol);

// 1) Looks like C#.
// 2) Doesn't blow up.
@@ -165,7 +165,7 @@ private void TestBaseTypeResolutionHelper3(AssemblySymbol[] assemblies)

foreach (var arg in varCorTypes_Derived.BaseType().TypeArguments())
{
Assert.IsType<MissingMetadataTypeSymbol>(arg);
Assert.IsAssignableFrom<MissingMetadataTypeSymbol>(arg);
}
}

@@ -323,7 +323,7 @@ public async Task TestHostAnalyzerErrorNotLeaking()
}

var liveId = (LiveDiagnosticUpdateArgsId)e.Id;
Assert.IsNotType<ProjectDiagnosticAnalyzer>(liveId.Analyzer);
Assert.False(liveId.Analyzer is ProjectDiagnosticAnalyzer);

called = true;
};

0 comments on commit 0d22543

Please sign in to comment.
You can’t perform that action at this time.