Skip to content

Fix xunit analyzers to run on library test projects #43459

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

Merged
merged 1 commit into from
Oct 17, 2020
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
958 changes: 489 additions & 469 deletions eng/CodeAnalysis.ruleset

Large diffs are not rendered by default.

546 changes: 546 additions & 0 deletions eng/CodeAnalysis.test.ruleset

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/libraries/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
<GenFacadesIgnoreBuildAndRevisionMismatch>true</GenFacadesIgnoreBuildAndRevisionMismatch>
<!-- Disable analyzers for tests and unsupported projects -->
<RunAnalyzers Condition="'$(IsSourceProject)' != 'true' or '$(MSBuildProjectExtension)' == '.ilproj'">false</RunAnalyzers>
<RunAnalyzers Condition="'$(IsTestProject)' != 'true' and '$(IsSourceProject)' != 'true'">false</RunAnalyzers>
<CodeAnalysisRuleset Condition="'$(IsTestProject)' == 'true'">$(RepositoryEngineeringDir)CodeAnalysis.test.ruleset</CodeAnalysisRuleset>
</PropertyGroup>

<!-- Set up common paths -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ public void CanBindByteArrayWhenValueIsNull()
var config = configurationBuilder.Build();

var options = config.Get<ByteArrayOptions>();
Assert.Equal(null, options.MyByteArray);
Assert.Null(options.MyByteArray);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ public void ScopeDispose_PreventsServiceResolution()
Assert.NotNull(provider.CreateScope());
}

[Theory(Skip = "https://github.com/dotnet/runtime/issues/42160 - We don't support value task services currently")]
[ActiveIssue("https://github.com/dotnet/runtime/issues/42160")] // We don't support value task services currently
[Theory]
[InlineData(ServiceLifetime.Transient)]
[InlineData(ServiceLifetime.Scoped)]
[InlineData(ServiceLifetime.Singleton)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace System.Security.Cryptography.Csp.Tests
{
public static class CspParametersTests
{
public static bool ManualTestsEnabled => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("MANUAL_TESTS"));

const int PROV_RSA_FULL = 1;
const int PROV_RSA_AES = 24;

Expand Down Expand Up @@ -45,7 +47,7 @@ public static void KeyPassword_SetGet()
}
}

[Theory(Skip = "Manual test - requires Smart Card - read instructions")]
[ConditionalTheory(nameof(ManualTestsEnabled))] // requires Smart Card - read instructions
[InlineData(true)]
[InlineData(false)]
public static void KeyPassword_SmartCard_Manual_Test(bool correctPassword)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,11 @@ static void PerformFloatingPointSerialization(string testString)
[InlineData("NaNa")]
[InlineData("Infinitya")]
[InlineData("-Infinitya")]
#pragma warning disable xUnit1025 // Theory method 'FloatingPointConstants_Fail' on test class 'NumberHandlingTests' has InlineData duplicate(s)
[InlineData("\u006EaN")] // "naN"
[InlineData("\u0020Inf\u0069ni\u0074y")] // " Infinity"
[InlineData("\u002BInf\u0069nity")] // "+Infinity"
#pragma warning restore xUnit1025
public static void FloatingPointConstants_Fail(string testString)
{
string testStringAsJson = $@"""{testString}""";
Expand Down