Skip to content

Commit 0bd7969

Browse files
committed
Simplify build authoring required for nullable annotations
1 parent b4f4ce2 commit 0bd7969

File tree

6 files changed

+7
-37
lines changed

6 files changed

+7
-37
lines changed

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
3030
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.5.0" PrivateAssets="all" />
3131
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
32+
<PackageReference Include="Nullable" Version="1.2.1" PrivateAssets="all" />
3233
</ItemGroup>
3334
<ItemGroup>
3435
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" />

Directory.Build.targets

-27
This file was deleted.

src/Xunit.SkippableFact/Skip.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ public static class Skip
1717
/// <param name="condition">The condition that must evaluate to <c>true</c> for the test to be skipped.</param>
1818
/// <param name="reason">The explanation for why the test is skipped.</param>
1919
public static void If(
20-
[DoesNotReturnIf(true)]
21-
bool condition,
20+
[DoesNotReturnIf(true)] bool condition,
2221
string? reason = null)
2322
{
2423
if (condition)
@@ -33,8 +32,7 @@ public static void If(
3332
/// <param name="condition">The condition that must evaluate to <c>false</c> for the test to be skipped.</param>
3433
/// <param name="reason">The explanation for why the test is skipped.</param>
3534
public static void IfNot(
36-
[DoesNotReturnIf(false)]
37-
bool condition,
35+
[DoesNotReturnIf(false)] bool condition,
3836
string? reason = null)
3937
{
4038
Skip.If(!condition, reason);

src/Xunit.SkippableFact/Xunit.SkippableFact.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;netstandard2.1;net45;net452</TargetFrameworks>
3+
<TargetFrameworks>netstandard2.0;net45;net452</TargetFrameworks>
44
<RootNamespace>Xunit</RootNamespace>
55

66
<Title>Dynamic test skipping for Xunit</Title>
@@ -11,7 +11,7 @@
1111
<None Update="xunit.runner.json">
1212
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1313
</None>
14-
</ItemGroup>
14+
</ItemGroup>
1515
<ItemGroup>
1616
<PackageReference Include="Validation" Version="2.4.18" PrivateAssets="compile;contentfiles;analyzers;build" />
1717
<PackageReference Include="xunit.extensibility.execution" Version="2.1.0" Condition=" '$(TargetFramework)' == 'net45' " />

test/Xunit.SkippableFact.Tests/SkipTests.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void IfNot_WithReason()
4949
}
5050
}
5151

52-
#if NETCOREAPP3_1
5352
[Fact]
5453
public void If_SupportsNullableReferenceTypesPostCondition()
5554
{
@@ -76,11 +75,10 @@ public void IfNot_SupportsNullableReferenceTypesPostCondition()
7675
? "Not null"
7776
: null;
7877

79-
Skip.IfNot(!(value is null));
78+
Skip.IfNot(value is object);
8079

8180
// Does not trigger a nullable reference type warning
8281
_ = value.Substring(0);
8382
}
84-
#endif
8583
}
8684
}

test/Xunit.SkippableFact.Tests/Xunit.SkippableFact.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net45;net461;netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
3+
<TargetFrameworks>net45;net461;netcoreapp2.1</TargetFrameworks>
44
<IsPackable>false</IsPackable>
55
</PropertyGroup>
66
<ItemGroup>

0 commit comments

Comments
 (0)