Skip to content

Commit cf648d8

Browse files
authored
Added support for AutoMapper v11 (#12)
* Added tests for AutoMapper 11.0.0 * Added netstandard2.1 target framework
1 parent 513d38c commit cf648d8

File tree

13 files changed

+121
-71
lines changed

13 files changed

+121
-71
lines changed

.github/workflows/continuous.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ jobs:
3333
- uses: actions/checkout@v2
3434
with:
3535
fetch-depth: 0
36+
- uses: actions/setup-dotnet@v1
37+
with:
38+
dotnet-version: |
39+
2.1.x
40+
3.1.x
41+
5.0.x
3642
- name: Cache .nuke/temp, ~/.nuget/packages
3743
uses: actions/cache@v2
3844
with:

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
- uses: actions/checkout@v2
3131
with:
3232
fetch-depth: 0
33+
- uses: actions/setup-dotnet@v1
34+
with:
35+
dotnet-version: |
36+
2.1.x
37+
3.1.x
38+
5.0.x
3339
- name: Cache .nuke/temp, ~/.nuget/packages
3440
uses: actions/cache@v2
3541
with:

AutoFixture.Community.AutoMapper.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoFixture.Community.AutoM
2626
EndProject
2727
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}"
2828
EndProject
29+
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}"
30+
EndProject
2931
Global
3032
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3133
Debug|Any CPU = Debug|Any CPU
@@ -50,6 +52,10 @@ Global
5052
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
5153
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
5254
{3C33293F-F6C1-4794-B13E-C991A46B3D9E}.Release|Any CPU.Build.0 = Release|Any CPU
55+
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
56+
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
57+
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
58+
{6A817919-5378-4CE3-B237-4989D5BD72C9}.Release|Any CPU.Build.0 = Release|Any CPU
5359
EndGlobalSection
5460
GlobalSection(SolutionProperties) = preSolution
5561
HideSolutionNode = FALSE
@@ -58,6 +64,7 @@ Global
5864
{821E5F93-5AC8-4B72-B218-06031E5324BC} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
5965
{8AF7A561-C7A4-4871-84AE-C41F86ABA0A8} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
6066
{3C33293F-F6C1-4794-B13E-C991A46B3D9E} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
67+
{6A817919-5378-4CE3-B237-4989D5BD72C9} = {1F01EA94-AA4F-4D1E-B9E7-47D0061430AC}
6168
EndGlobalSection
6269
GlobalSection(ExtensibilityGlobals) = postSolution
6370
SolutionGuid = {F55E1A48-F5F2-401F-9BEF-F15527CE66DD}

Common.Tests.props

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>
19-
20-
<PackageReference Include="coverlet.msbuild" Version="3.1.0" Condition="$(TargetFramework.StartsWith('net4'))">
21-
<PrivateAssets>all</PrivateAssets>
22-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
23-
</PackageReference>
24-
<PackageReference Include="coverlet.collector" Version="3.1.0" Condition="$(TargetFramework.StartsWith('net5.'))">
19+
<PackageReference Include="coverlet.collector" Version="3.1.0">
2520
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2621
<PrivateAssets>all</PrivateAssets>
2722
</PackageReference>

Common.props

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Description>A library that integrates AutoFixture with AutoMapper.</Description>
88
<PackageTags>AutoFixture;AutoMapper;Unit Testing;Tests</PackageTags>
99
<PackageProjectUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper</PackageProjectUrl>
10-
<RepositoryUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper</RepositoryUrl>
10+
<RepositoryUrl>https://github.com/aivascu/AutoFixture.Community.AutoMapper.git</RepositoryUrl>
1111
<RepositoryType>git</RepositoryType>
1212

1313
<PackageIcon>icon.png</PackageIcon>
@@ -18,6 +18,9 @@
1818

1919
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
2020
<EmbedUntrackedSources>true</EmbedUntrackedSources>
21+
22+
<!-- Set the CheckEolTargetFramework property to false to fix the NETSDK1138 warning -->
23+
<CheckEolTargetFramework>false</CheckEolTargetFramework>
2124
</PropertyGroup>
2225

2326
<ItemGroup>

build/Build.cs

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Diagnostics;
4-
using System.IO;
5-
using System.Linq;
63
using Nuke.Common;
74
using Nuke.Common.CI;
85
using Nuke.Common.Execution;
@@ -31,7 +28,7 @@ partial class Build : NukeBuild
3128
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
3229

3330
[GitRepository] readonly GitRepository GitRepository;
34-
[GitVersion(Framework = "netcoreapp3.0")] readonly GitVersion GitVersion;
31+
[GitVersion] readonly GitVersion GitVersion;
3532

3633
[Parameter] readonly bool Deterministic;
3734

@@ -44,11 +41,9 @@ partial class Build : NukeBuild
4441
AbsolutePath TestsDirectory => RootDirectory / "tests";
4542
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
4643
AbsolutePath TestResultsDirectory => ArtifactsDirectory / "testresults";
47-
AbsolutePath CoverageDirectory => ArtifactsDirectory / "coverage";
4844
AbsolutePath ReportsDirectory => ArtifactsDirectory / "reports";
4945
AbsolutePath PackagesDirectory => ArtifactsDirectory / "packages";
5046

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

5449
Target Clean => _ => _
@@ -65,7 +60,9 @@ partial class Build : NukeBuild
6560
.Executes(() =>
6661
{
6762
DotNetRestore(s => s
68-
.SetProjectFile(Solution));
63+
.SetProjectFile(Solution)
64+
.SetProcessArgumentConfigurator(a => a
65+
.Add("/p:CheckEolTargetFramework=false")));
6966
});
7067

7168
Target Compile => _ => _
@@ -80,71 +77,43 @@ partial class Build : NukeBuild
8077
.SetInformationalVersion(GitVersion.InformationalVersion)
8178
.SetNoRestore(FinishedTargets.Contains(Restore))
8279
.SetContinuousIntegrationBuild(IsServerBuild || Deterministic)
83-
.SetDeterministic(IsServerBuild || Deterministic));
80+
.SetDeterministic(IsServerBuild || Deterministic)
81+
.SetProcessArgumentConfigurator(a => a
82+
.Add("/p:CheckEolTargetFramework=false")));
8483
});
8584

8685
Target Test => _ => _
8786
.DependsOn(Compile)
8887
.Produces(TestResultsDirectory / "*.trx")
89-
.Produces(CoverageDirectory / "*.xml")
9088
.Executes(() =>
9189
{
9290
DotNetTest(s => s
93-
.SetFramework("net461")
94-
.SetConfiguration(Configuration)
95-
.SetNoBuild(FinishedTargets.Contains(Compile))
96-
.ResetVerbosity()
97-
.SetLogger("trx")
98-
.SetUseSourceLink(IsServerBuild)
99-
.SetResultsDirectory(TestResultsDirectory)
100-
.SetProcessArgumentConfigurator(a => a
101-
.Add("-- RunConfiguration.DisableAppDomain=true")
102-
.Add("-- RunConfiguration.NoAutoReporters=true"))
103-
.When(InvokedTargets.Contains(Cover), _ => _
104-
.EnableCollectCoverage()
105-
.SetCoverletOutputFormat(CoverletOutputFormat.cobertura)
106-
.When(IsServerBuild || Deterministic, _ => _
107-
.SetProcessArgumentConfigurator(a => a
108-
.Add("/p:DeterministicReport=true"))))
109-
.CombineWith(TestProjects, (_, v) => _
110-
.SetProjectFile(v)
111-
.When(InvokedTargets.Contains(Cover), _ => _
112-
.SetCoverletOutput(CoverageDirectory / $"{v.Name}.xml"))));
113-
114-
DotNetTest(s => s
115-
.SetFramework("net5.0")
91+
.SetProjectFile(Solution)
11692
.SetConfiguration(Configuration)
11793
.SetNoBuild(FinishedTargets.Contains(Compile))
11894
.ResetVerbosity()
11995
.SetResultsDirectory(TestResultsDirectory)
120-
.SetLogger("trx")
96+
.SetLoggers("trx")
12197
.SetUseSourceLink(IsServerBuild)
12298
.SetProcessArgumentConfigurator(a => a
99+
.Add("/p:CheckEolTargetFramework=false")
123100
.Add("-- RunConfiguration.DisableAppDomain=true")
124101
.Add("-- RunConfiguration.NoAutoReporters=true"))
125102
.When(InvokedTargets.Contains(Cover), _ => _
126103
.SetDataCollector("XPlat Code Coverage")
127-
.When(IsServerBuild || Deterministic, _ => _
128-
.SetProcessArgumentConfigurator(a => a
129-
.Add("/p:DeterministicReport=true"))))
130-
.CombineWith(TestProjects, (_, p) => _
131-
.SetProjectFile(p)
132-
.When(InvokedTargets.Contains(Cover), _ => _
133-
.SetResultsDirectory(TestResultsDirectory / $"{p.Name}.{_.Framework}"))));
104+
.When(IsServerBuild || Deterministic, _ => _
105+
.SetProcessArgumentConfigurator(a => a
106+
.Add("/p:DeterministicReport=true")))));
134107

135108
Debug.Assert(
136-
TestResultsDirectory.GlobFiles("**\\*.trx").Count > 0,
109+
TestResultsDirectory.GlobFiles("**/*.trx").Count > 0,
137110
"No trx files were generated.");
138111

139-
TestResultsDirectory.GlobFiles("**\\*.xml")
140-
.Where(x => Guid.TryParse(x.GetParentDirectoryName(), out var _))
141-
.ForEach(x => File.Copy(x, CoverageDirectory / $"{x.Parent.GetParentDirectoryName()}.xml", true));
142-
143112
if (InvokedTargets.Contains(Cover))
144113
{
145114
Debug.Assert(
146-
CoverageDirectory.GlobFiles("**\\*.xml").Count > 0,
147-
"No xml coverage files were generated.");
115+
TestResultsDirectory.GlobFiles("**/coverage.cobertura.xml").Count > 0,
116+
"No cobertura files generated.");
148117
}
149118
});
150119

@@ -156,7 +125,7 @@ partial class Build : NukeBuild
156125
{
157126
ReportGenerator(_ => _
158127
.SetFramework("net5.0")
159-
.SetReports(CoverageDirectory / "*.xml")
128+
.SetReports(TestResultsDirectory / "**" / "coverage.cobertura.xml")
160129
.SetTargetDirectory(ReportsDirectory)
161130
.SetReportTypes("lcov", ReportTypes.HtmlInline));
162131
});

build/_build.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Nuke.Common" Version="5.2.1" />
15-
<PackageDownload Include="coveralls.net" Version="[1.0.0]" />
16-
<PackageDownload Include="coverlet.console" Version="[1.7.2]" />
17-
<PackageDownload Include="GitVersion.Tool" Version="[5.1.1]" />
18-
<PackageDownload Include="JetBrains.ReSharper.CommandLineTools" Version="[2020.1.3]" />
19-
<PackageDownload Include="ReportGenerator" Version="[4.8.11]" />
14+
<PackageReference Include="Nuke.Common" Version="5.3.0" />
15+
<PackageDownload Include="coveralls.net" Version="[3.0.0]" />
16+
<PackageDownload Include="coverlet.console" Version="[3.1.0]" />
17+
<PackageDownload Include="GitVersion.Tool" Version="[5.8.1]" />
18+
<PackageDownload Include="JetBrains.ReSharper.CommandLineTools" Version="[2021.3.2]" />
19+
<PackageDownload Include="ReportGenerator" Version="[5.0.2]" />
2020
<PackageDownload Include="xunit.runner.console" Version="[2.4.1]" />
2121
</ItemGroup>
2222

src/AutoFixture.Community.AutoMapper/AutoFixture.Community.AutoMapper.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
<Import Project="../../Common.props" />
33

44
<PropertyGroup>
5-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
5+
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="AutoFixture" Version="4.5.0" />
10-
<PackageReference Include="AutoMapper" Version="8.0.0" />
10+
<PackageReference Include="AutoMapper" Version="11.0.0" Condition="'$(TargetFramework)'=='netstandard2.1'" />
11+
</ItemGroup>
12+
13+
<ItemGroup Condition="'$(TargetFramework)'=='net461' OR '$(TargetFramework)'=='netstandard2.0' ">
14+
<PackageReference Include="AutoMapper" Version="[8.0.0,11.0.0)" />
15+
</ItemGroup>
16+
17+
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
18+
<PackageReference Include="AutoMapper" Version="11.0.0" />
1119
</ItemGroup>
1220

1321
</Project>

src/AutoFixture.Community.AutoMapper/AutoMapperCustomization.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
using System;
22
using AutoFixture.Kernel;
33
using AutoMapper;
4+
5+
#if !(NETSTANDARD2_1_OR_GREATER)
46
using AutoMapper.Configuration;
7+
#endif
58

69
namespace AutoFixture.Community.AutoMapper
710
{

tests/AutoFixture.Community.AutoMapper.Tests/AutoFixture.Community.AutoMapper.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<Import Project="..\..\Common.Tests.props" />
33

44
<PropertyGroup>
5-
<TargetFrameworks>net461;net5.0</TargetFrameworks>
5+
<TargetFrameworks>net5.0</TargetFrameworks>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="AutoMapper" Version="10.0.0" />
9+
<PackageReference Include="AutoMapper" Version="11.0.0" />
1010

1111
<PackageReference Include="AutoFixture" Version="4.17.0" />
1212
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />

0 commit comments

Comments
 (0)