Skip to content

Commit

Permalink
Added support for AutoMapper v11 (#12)
Browse files Browse the repository at this point in the history
* Added tests for AutoMapper 11.0.0
* Added netstandard2.1 target framework
  • Loading branch information
aivascu authored Jan 12, 2022
1 parent 513d38c commit cf648d8
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 71 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- 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
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- 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
with:
Expand Down
7 changes: 7 additions & 0 deletions AutoFixture.Community.AutoMapper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFixture.Community.AutoM
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoFixture.Community.AutoMapper10.Tests", "tests\AutoFixture.Community.AutoMapper10.Tests\AutoFixture.Community.AutoMapper10.Tests.csproj", "{6A817919-5378-4CE3-B237-4989D5BD72C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -50,6 +52,10 @@ Global
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Release|Any CPU.Build.0 = Release|Any CPU
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -58,6 +64,7 @@ Global
{821E5F93-5AC8-4B72-B218-06031E5324BC} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
{8AF7A561-C7A4-4871-84AE-C41F86ABA0A8} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
{3C33293F-F6C1-4794-B13E-C991A46B3D9E} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
{6A817919-5378-4CE3-B237-4989D5BD72C9} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F55E1A48-F5F2-401F-9BEF-F15527CE66DD}
Expand Down
7 changes: 1 addition & 6 deletions Common.Tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

<PackageReference Include="coverlet.msbuild" Version="3.1.0" Condition="$(TargetFramework.StartsWith('net4'))">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0" Condition="$(TargetFramework.StartsWith('net5.'))">
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
5 changes: 4 additions & 1 deletion Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Description>A library that integrates AutoFixture with AutoMapper.</Description>
<PackageTags>AutoFixture;AutoMapper;Unit Testing;Tests</PackageTags>
<PackageProjectUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper</PackageProjectUrl>
<RepositoryUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper</RepositoryUrl>
<RepositoryUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>

<PackageIcon>icon.png</PackageIcon>
Expand All @@ -18,6 +18,9 @@

<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Set the CheckEolTargetFramework property to false to fix the NETSDK1138 warning -->
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
65 changes: 17 additions & 48 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.Execution;
Expand Down Expand Up @@ -31,7 +28,7 @@ partial class Build : NukeBuild
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

[GitRepository] readonly GitRepository GitRepository;
[GitVersion(Framework = "netcoreapp3.0")] readonly GitVersion GitVersion;
[GitVersion] readonly GitVersion GitVersion;

[Parameter] readonly bool Deterministic;

Expand All @@ -44,11 +41,9 @@ partial class Build : NukeBuild
AbsolutePath TestsDirectory => RootDirectory / "tests";
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
AbsolutePath TestResultsDirectory => ArtifactsDirectory / "testresults";
AbsolutePath CoverageDirectory => ArtifactsDirectory / "coverage";
AbsolutePath ReportsDirectory => ArtifactsDirectory / "reports";
AbsolutePath PackagesDirectory => ArtifactsDirectory / "packages";

IEnumerable<Project> TestProjects => Solution.GetProjects("*Tests");
IReadOnlyCollection<AbsolutePath> Packages => PackagesDirectory.GlobFiles("*.nupkg");

Target Clean => _ => _
Expand All @@ -65,7 +60,9 @@ partial class Build : NukeBuild
.Executes(() =>
{
DotNetRestore(s => s
.SetProjectFile(Solution));
.SetProjectFile(Solution)
.SetProcessArgumentConfigurator(a => a
.Add("/p:CheckEolTargetFramework=false")));
});

Target Compile => _ => _
Expand All @@ -80,71 +77,43 @@ partial class Build : NukeBuild
.SetInformationalVersion(GitVersion.InformationalVersion)
.SetNoRestore(FinishedTargets.Contains(Restore))
.SetContinuousIntegrationBuild(IsServerBuild || Deterministic)
.SetDeterministic(IsServerBuild || Deterministic));
.SetDeterministic(IsServerBuild || Deterministic)
.SetProcessArgumentConfigurator(a => a
.Add("/p:CheckEolTargetFramework=false")));
});

Target Test => _ => _
.DependsOn(Compile)
.Produces(TestResultsDirectory / "*.trx")
.Produces(CoverageDirectory / "*.xml")
.Executes(() =>
{
DotNetTest(s => s
.SetFramework("net461")
.SetConfiguration(Configuration)
.SetNoBuild(FinishedTargets.Contains(Compile))
.ResetVerbosity()
.SetLogger("trx")
.SetUseSourceLink(IsServerBuild)
.SetResultsDirectory(TestResultsDirectory)
.SetProcessArgumentConfigurator(a => a
.Add("-- RunConfiguration.DisableAppDomain=true")
.Add("-- RunConfiguration.NoAutoReporters=true"))
.When(InvokedTargets.Contains(Cover), _ => _
.EnableCollectCoverage()
.SetCoverletOutputFormat(CoverletOutputFormat.cobertura)
.When(IsServerBuild || Deterministic, _ => _
.SetProcessArgumentConfigurator(a => a
.Add("/p:DeterministicReport=true"))))
.CombineWith(TestProjects, (_, v) => _
.SetProjectFile(v)
.When(InvokedTargets.Contains(Cover), _ => _
.SetCoverletOutput(CoverageDirectory / $"{v.Name}.xml"))));
DotNetTest(s => s
.SetFramework("net5.0")
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetNoBuild(FinishedTargets.Contains(Compile))
.ResetVerbosity()
.SetResultsDirectory(TestResultsDirectory)
.SetLogger("trx")
.SetLoggers("trx")
.SetUseSourceLink(IsServerBuild)
.SetProcessArgumentConfigurator(a => a
.Add("/p:CheckEolTargetFramework=false")
.Add("-- RunConfiguration.DisableAppDomain=true")
.Add("-- RunConfiguration.NoAutoReporters=true"))
.When(InvokedTargets.Contains(Cover), _ => _
.SetDataCollector("XPlat Code Coverage")
.When(IsServerBuild || Deterministic, _ => _
.SetProcessArgumentConfigurator(a => a
.Add("/p:DeterministicReport=true"))))
.CombineWith(TestProjects, (_, p) => _
.SetProjectFile(p)
.When(InvokedTargets.Contains(Cover), _ => _
.SetResultsDirectory(TestResultsDirectory / $"{p.Name}.{_.Framework}"))));
.When(IsServerBuild || Deterministic, _ => _
.SetProcessArgumentConfigurator(a => a
.Add("/p:DeterministicReport=true")))));
Debug.Assert(
TestResultsDirectory.GlobFiles("**\\*.trx").Count > 0,
TestResultsDirectory.GlobFiles("**/*.trx").Count > 0,
"No trx files were generated.");
TestResultsDirectory.GlobFiles("**\\*.xml")
.Where(x => Guid.TryParse(x.GetParentDirectoryName(), out var _))
.ForEach(x => File.Copy(x, CoverageDirectory / $"{x.Parent.GetParentDirectoryName()}.xml", true));
if (InvokedTargets.Contains(Cover))
{
Debug.Assert(
CoverageDirectory.GlobFiles("**\\*.xml").Count > 0,
"No xml coverage files were generated.");
TestResultsDirectory.GlobFiles("**/coverage.cobertura.xml").Count > 0,
"No cobertura files generated.");
}
});

Expand All @@ -156,7 +125,7 @@ partial class Build : NukeBuild
{
ReportGenerator(_ => _
.SetFramework("net5.0")
.SetReports(CoverageDirectory / "*.xml")
.SetReports(TestResultsDirectory / "**" / "coverage.cobertura.xml")
.SetTargetDirectory(ReportsDirectory)
.SetReportTypes("lcov", ReportTypes.HtmlInline));
});
Expand Down
12 changes: 6 additions & 6 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.2.1" />
<PackageDownload Include="coveralls.net" Version="[1.0.0]" />
<PackageDownload Include="coverlet.console" Version="[1.7.2]" />
<PackageDownload Include="GitVersion.Tool" Version="[5.1.1]" />
<PackageDownload Include="JetBrains.ReSharper.CommandLineTools" Version="[2020.1.3]" />
<PackageDownload Include="ReportGenerator" Version="[4.8.11]" />
<PackageReference Include="Nuke.Common" Version="5.3.0" />
<PackageDownload Include="coveralls.net" Version="[3.0.0]" />
<PackageDownload Include="coverlet.console" Version="[3.1.0]" />
<PackageDownload Include="GitVersion.Tool" Version="[5.8.1]" />
<PackageDownload Include="JetBrains.ReSharper.CommandLineTools" Version="[2021.3.2]" />
<PackageDownload Include="ReportGenerator" Version="[5.0.2]" />
<PackageDownload Include="xunit.runner.console" Version="[2.4.1]" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
<Import Project="../../Common.props" />

<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.5.0" />
<PackageReference Include="AutoMapper" Version="8.0.0" />
<PackageReference Include="AutoMapper" Version="11.0.0" Condition="'$(TargetFramework)'=='netstandard2.1'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net461' OR '$(TargetFramework)'=='netstandard2.0' ">
<PackageReference Include="AutoMapper" Version="[8.0.0,11.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<PackageReference Include="AutoMapper" Version="11.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using AutoFixture.Kernel;
using AutoMapper;

#if !(NETSTANDARD2_1_OR_GREATER)
using AutoMapper.Configuration;
#endif

namespace AutoFixture.Community.AutoMapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<Import Project="..\..\Common.Tests.props" />

<PropertyGroup>
<TargetFrameworks>net461;net5.0</TargetFrameworks>
<TargetFrameworks>net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" />
<PackageReference Include="AutoMapper" Version="11.0.0" />

<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.Tests.props" />

<PropertyGroup>
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.0.0" />

<PackageReference Include="AutoFixture" Version="4.17.0" />
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
<PackageReference Include="AutoFixture.Idioms" Version="4.17.0" />
<PackageReference Include="AutoFixture.Xunit2" Version="4.17.0" />

<PackageReference Include="SemanticComparison" Version="4.1.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Moq" Version="4.16.1" />
</ItemGroup>

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

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
</ProjectReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\Common.Tests.props" />

<PropertyGroup>
<TargetFrameworks>net461;net5.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,8 +23,16 @@
<Compile Remove="..\AutoFixture.Community.AutoMapper.Tests\obj\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj" />
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
</ProjectReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\..\Common.Tests.props" />

<PropertyGroup>
<TargetFrameworks>net461;net5.0</TargetFrameworks>
<TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,8 +23,15 @@
<Compile Remove="..\AutoFixture.Community.AutoMapper.Tests\obj\**" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj" />
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'" >
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework>
</ProjectReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net462'" >
<ProjectReference Include="..\..\src\AutoFixture.Community.AutoMapper\AutoFixture.Community.AutoMapper.csproj">
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
</ProjectReference>
</ItemGroup>
</Project>

0 comments on commit cf648d8

Please sign in to comment.