Skip to content

Commit

Permalink
Added .NET 5 target runtime (#1443)
Browse files Browse the repository at this point in the history
* Upgraded minimum .NET Framework to net462

* Added net5.0 target framework to AutoFixture

* Added net5.0 to AutoFakeItEasy

* Updated NUnit 3 test project

* Updated runtime for seed extensions test project

* Updated runtime for xunit 2 test project

* Updated runtime for documentation test project

* Updated runtime for Foq test project

* Updated runtime for Moq test project

* Updated runtime for NSubstitute test projects

* Updated runtime for FsCheck idioms test projects

* Added ignore rule for Rider

* Updated runtime for Idioms test project

* Fixed ConfigureAwait warnings

* Refactored hash code implementation to use HashCode BCL type

* Ignored warnings on assertions on literal values

* Refactored test arguments to match test data

* Resolved all async code warnings

* Resolved missing documentation warning

* Marked binary serializer tests as obsolete

* Removed .NET Core 2 and .NET Core 3 SDKs from pipelines

* Updated build script to not target .NET Core 3

* Raised minimum NUnit version to 3.7.0 for all target frameworks

* Added net5.0 target to seed extensions

* Raised minimum xunit 2 extensibility core version to 2.2.0 and added net5.0 target

* Added net5.0 target to AutoFoq

* Added net5.0 target to AutoMoq

* Added net5.0 target to AutoNSubstitute

* Removed duplicate AutoNSubstitute test project

* Added net5.0 target for Idioms

* Added net5.0 runtime to FsCheck idioms

* Fixed validation warnings

* Removed obsolete attribute from build script

* Added packages fixing transitive vulnerabilities
  • Loading branch information
aivascu committed Feb 18, 2024
1 parent 93c9fae commit b864999
Show file tree
Hide file tree
Showing 63 changed files with 423 additions and 276 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/continuous.yml
Expand Up @@ -33,8 +33,6 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Expand Up @@ -32,8 +32,6 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -395,4 +395,5 @@ FodyWeavers.xsd
*.msp

# JetBrains Rider
*.sln.iml
*.sln.iml
.idea/
14 changes: 11 additions & 3 deletions .nuke/build.schema.json
Expand Up @@ -26,7 +26,7 @@
"github-token": {
"type": "string",
"description": "GitHub auth token",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Help": {
"type": "boolean",
Expand All @@ -39,14 +39,18 @@
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI"
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"NoLogo": {
Expand All @@ -56,7 +60,11 @@
"NUGET_API_KEY": {
"type": "string",
"description": "NuGet API Key (secret)",
"default": "Secrets must be entered via 'nuke :secret [profile]'"
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
Expand Down
8 changes: 0 additions & 8 deletions Src/All.sln
Expand Up @@ -70,8 +70,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFixture.SeedExtensions"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFixture.SeedExtensions.UnitTest", "AutoFixture.SeedExtensions.UnitTest\AutoFixture.SeedExtensions.UnitTest.csproj", "{0F3C467A-ED89-4348-9210-FC2D358E20C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoNSubstitute.NSubstitute4UnitTest", "AutoNSubstitute.NSubstitute4UnitTest\AutoNSubstitute.NSubstitute4UnitTest.csproj", "{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFakeItEasy.FakeItEasy7UnitTest", "AutoFakeItEasy.FakeItEasy7UnitTest\AutoFakeItEasy.FakeItEasy7UnitTest.csproj", "{1B42519B-24C2-4141-83A3-AB68AB09EE28}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoNSubstitute.NSubstitute5UnitTest", "AutoNSubstitute.NSubstitute5UnitTest\AutoNSubstitute.NSubstitute5UnitTest.csproj", "{DCFA3909-031E-40CB-8A1D-D3AED666C24B}"
Expand Down Expand Up @@ -255,12 +253,6 @@ Global
{0F3C467A-ED89-4348-9210-FC2D358E20C5}.Release|Any CPU.Build.0 = Release|Any CPU
{0F3C467A-ED89-4348-9210-FC2D358E20C5}.Verify|Any CPU.ActiveCfg = Verify|Any CPU
{0F3C467A-ED89-4348-9210-FC2D358E20C5}.Verify|Any CPU.Build.0 = Verify|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Release|Any CPU.Build.0 = Release|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Verify|Any CPU.ActiveCfg = Verify|Any CPU
{4BDBE8A1-CF75-4049-9B3D-B194B1F45369}.Verify|Any CPU.Build.0 = Verify|Any CPU
{1B42519B-24C2-4141-83A3-AB68AB09EE28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B42519B-24C2-4141-83A3-AB68AB09EE28}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B42519B-24C2-4141-83A3-AB68AB09EE28}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
Expand Up @@ -4,26 +4,37 @@
<Import Project="..\Common.Test.xUnit.props" />

<PropertyGroup>
<TargetFrameworks>net461;net5.0</TargetFrameworks>
<TargetFrameworks>net462;net48;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFakeItEasy.FakeItEasy7.UnitTest</AssemblyTitle>
<AssemblyName>AutoFixture.AutoFakeItEasy.FakeItEasy7UnitTest</AssemblyName>
<RootNamespace>AutoFixture.AutoFakeItEasy.UnitTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[7.0.1]" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\AutoFakeItEasyUnitTest\**\*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Remove="..\AutoFakeItEasyUnitTest\obj\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
<Choose>
<When Condition="'$(TargetFramework)'=='net48'">
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[7.4.0]" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0"/>

<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[7.4.0]" />

<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
Expand Up @@ -4,26 +4,37 @@
<Import Project="..\Common.Test.xUnit.props" />

<PropertyGroup>
<TargetFrameworks>net462;net5.0</TargetFrameworks>
<TargetFrameworks>net462;net48;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFakeItEasy.FakeItEasy8.UnitTest</AssemblyTitle>
<AssemblyName>AutoFixture.AutoFakeItEasy.FakeItEasy8UnitTest</AssemblyName>
<RootNamespace>AutoFixture.AutoFakeItEasy.UnitTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[8.0.0]" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\AutoFakeItEasyUnitTest\**\*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Remove="..\AutoFakeItEasyUnitTest\obj\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
<Choose>
<When Condition="'$(TargetFramework)'=='net48'">
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[8.1.0]" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0"/>

<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[8.1.0]" />

<ProjectReference Include="..\AutoFakeItEasy\AutoFakeItEasy.csproj" />
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
13 changes: 11 additions & 2 deletions Src/AutoFakeItEasy/AutoFakeItEasy.csproj
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\Common.props" />

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFakeItEasy</AssemblyTitle>
<AssemblyName>AutoFixture.AutoFakeItEasy</AssemblyName>
<RootNamespace>AutoFixture.AutoFakeItEasy</RootNamespace>
Expand All @@ -21,7 +21,16 @@

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="[6.0.0,9.0.0)" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" Condition=" '$(TargetFramework)'=='netstandard2.0' " />
</ItemGroup>

<!-- Dependencies added due to transitive vulnerabilities in FakeItEasy -->
<ItemGroup Condition=" '$(TargetFramework)'=='netstandard2.0' ">
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
23 changes: 10 additions & 13 deletions Src/AutoFakeItEasy/MethodCall.cs
Expand Up @@ -33,21 +33,18 @@ public override bool Equals(object obj)

public override int GetHashCode()
{
unchecked
var hashCode = default(HashCode);
hashCode.Add(this.declaringType);
hashCode.Add(this.methodName);
foreach (var argument in this.arguments)
{
var hashCode = -712421553;
hashCode = (hashCode * -1521134295) + this.declaringType.GetHashCode();
hashCode = (hashCode * -1521134295) + this.methodName.GetHashCode();
foreach (var argument in this.arguments)
{
hashCode = (hashCode * -1521134295) + EqualityComparer<object>.Default.GetHashCode(argument);
}
foreach (var argumentType in this.parameterTypes)
{
hashCode = (hashCode * -1521134295) + argumentType.GetHashCode();
}
return hashCode;
hashCode.Add(argument);
}
foreach (var argumentType in this.parameterTypes)
{
hashCode.Add(argumentType);
}
return hashCode.ToHashCode();
}

private static IEnumerable<object> ExpandParamsArgument(IList<ParameterInfo> parameters, IEnumerable<object> arguments)
Expand Down
2 changes: 1 addition & 1 deletion Src/AutoFakeItEasyUnitTest/AutoFakeItEasyUnitTest.csproj
Expand Up @@ -4,7 +4,7 @@
<Import Project="..\Common.Test.xUnit.props" />

<PropertyGroup>
<TargetFrameworks>net461;net5.0</TargetFrameworks>
<TargetFrameworks>net462;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFakeItEasyUnitTest</AssemblyTitle>
<AssemblyName>AutoFixture.AutoFakeItEasy.UnitTest</AssemblyName>
<RootNamespace>AutoFixture.AutoFakeItEasy.UnitTest</RootNamespace>
Expand Down
2 changes: 2 additions & 0 deletions Src/AutoFakeItEasyUnitTest/FixtureIntegrationTest.cs
Expand Up @@ -594,7 +594,9 @@ public void WithConfigureMembers_LiteralFieldsAreIgnored()
// Act
fixture.Create<Fake<TypeWithConstField>>();
// Assert
#pragma warning disable xUnit2000 // This test asserts the value of a literal or constant
Assert.NotEqual(frozenString, TypeWithConstField.ConstField);
#pragma warning restore xUnit2000
}

[Fact]
Expand Down
Expand Up @@ -3,7 +3,7 @@
<Import Project="..\Common.Test.props" />

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net462</TargetFramework>
<AssemblyTitle>AutoFixture.NUnit2.UnitTest</AssemblyTitle>
<AssemblyName>AutoFixture.NUnit2.UnitTest</AssemblyName>
<RootNamespace>AutoFixture.NUnit2.UnitTest</RootNamespace>
Expand Down
2 changes: 1 addition & 1 deletion Src/AutoFixture.NUnit2/AutoFixture.NUnit2.csproj
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\Common.props" />

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net462</TargetFramework>
<AssemblyTitle>AutoFixture.NUnit2</AssemblyTitle>
<AssemblyName>AutoFixture.NUnit2</AssemblyName>
<RootNamespace>AutoFixture.NUnit2</RootNamespace>
Expand Down
31 changes: 22 additions & 9 deletions Src/AutoFixture.NUnit3.UnitTest/AutoFixture.NUnit3.UnitTest.csproj
Expand Up @@ -3,23 +3,36 @@
<Import Project="..\Common.Test.props" />

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>net462;net48;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFixture.NUnit3.UnitTest</AssemblyTitle>
<AssemblyName>AutoFixture.NUnit3.UnitTest</AssemblyName>
<RootNamespace>AutoFixture.NUnit3.UnitTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnit" Version="[3.0.1]" Condition=" '$(TargetFramework)'=='net461' " />
<PackageReference Include="NUnit" Version="[3.10.1]" Condition=" '$(TargetFramework)'=='netcoreapp2.1' " />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0"/>
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\AutoFixture.NUnit3\AutoFixture.NUnit3.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
<Choose>
<When Condition="'$(TargetFramework)'=='net48'">
<ItemGroup>
<PackageReference Include="NUnit" Version="[3.14.0]" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />

<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\AutoFixture.NUnit3\AutoFixture.NUnit3.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" SkipGetTargetFrameworkProperties="true" SetTargetFramework="TargetFramework=netstandard2.0" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="NUnit" Version="[3.14.0]" />

<ProjectReference Include="..\AutoFixture\AutoFixture.csproj" />
<ProjectReference Include="..\AutoFixture.NUnit3\AutoFixture.NUnit3.csproj" />
<ProjectReference Include="..\TestTypeFoundation\TestTypeFoundation.csproj" />
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
Expand Up @@ -14,10 +14,13 @@ public void FixedNameTestMethodBuilderIsResilientToParameterEnumeratingException
var dummyMethod = new MethodWrapper(typeof(TestNameStrategiesFixture), nameof(TestNameStrategiesFixture.FixedNameDecoratedMethod));
var sut = new FixedNameTestMethodBuilder();
var throwingParameters = Enumerable.Range(0, 1).Select<int, object>(_ => throw new Exception());
var expected = nameof(TestNameStrategiesFixture.FixedNameDecoratedMethod) + "()";

// Act
var testMethod = sut.Build(dummyMethod, null, throwingParameters, 0);

// Assert
Assert.That(testMethod.Name, Is.EqualTo(nameof(TestNameStrategiesFixture.FixedNameDecoratedMethod)));
Assert.AreEqual(expected, testMethod.Name);
}
}
}
Expand Up @@ -11,14 +11,17 @@ public class VolatileNameTestMethodBuilderTest
public void VolatileNameTestMethodBuilderIsResilientToParameterEnumerationException()
{
// Arrange
var anyMethod = new MethodWrapper(typeof(TestNameStrategiesFixture), nameof(TestNameStrategiesFixture.VolatileNameDecoratedMethod));
const string methodName = nameof(TestNameStrategiesFixture.VolatileNameDecoratedMethod);
var anyMethod = new MethodWrapper(typeof(TestNameStrategiesFixture), methodName);
var sut = new VolatileNameTestMethodBuilder();
var throwingParameters = Enumerable.Range(0, 1).Select<int, object>(_ => throw new Exception());
const string expected = methodName + "()";

// Act
var testMethod = sut.Build(anyMethod, null, throwingParameters, 0);

// Assert
Assert.That(testMethod.Name, Is.EqualTo(nameof(TestNameStrategiesFixture.VolatileNameDecoratedMethod)));
Assert.AreEqual(expected, testMethod.Name);
}
}
}
11 changes: 8 additions & 3 deletions Src/AutoFixture.NUnit3/AutoFixture.NUnit3.csproj
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\Common.props" />

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;net5.0</TargetFrameworks>
<AssemblyTitle>AutoFixture.NUnit3</AssemblyTitle>
<AssemblyName>AutoFixture.NUnit3</AssemblyName>
<RootNamespace>AutoFixture.NUnit3</RootNamespace>
Expand All @@ -16,8 +16,13 @@
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="NUnit" Version="[3.0.1,4.0.0)" Condition=" '$(TargetFramework)'=='net461' " />
<PackageReference Include="NUnit" Version="[3.7.0,4.0.0)" Condition=" '$(TargetFramework)'=='netstandard2.0' " />
  <PackageReference Include="NUnit" Version="[3.7.0,4.0.0)" />
</ItemGroup>

<!-- Dependencies added due to transitive vulnerabilities in NUnit -->
<ItemGroup Condition="'$(TargetFramework)'=='net5.0'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Security.Cryptography.X509Certificates" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit b864999

Please sign in to comment.