Skip to content
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ indent_size = 2
indent_size = 2

[*.csproj]
indent_size = 2

[*.yml]
indent_size = 2
68 changes: 31 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-windows:
strategy:
fail-fast: false
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: |
dotnet build --configuration Release

dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\UnitTests

dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\AutoMapper.DI.Tests

shell: pwsh
build:
needs: build-windows
strategy:
fail-fast: false
runs-on: ubuntu-latest
Expand All @@ -58,15 +33,34 @@ jobs:
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
if: github.ref == 'refs/heads/master'
env:
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts/**/*
build-windows:
needs: build
strategy:
fail-fast: false
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
if: github.ref == 'refs/heads/master'
env:
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts/**/*
106 changes: 49 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,62 @@
name: Release

on:
push:
tags:
- '*.*.*'
- "*.*.*"
permissions:
contents: read

jobs:
build-windows:
build:
strategy:
fail-fast: false
runs-on: windows-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: |
dotnet build --configuration Release

dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\UnitTests

dotnet test --configuration Release --no-build --results-directory ".\artifacts" -l trx .\src\AutoMapper.DI.Tests

shell: pwsh
build:
needs: build-windows
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: ./Build.ps1
shell: pwsh
build-windows:
needs: build
strategy:
fail-fast: false
runs-on: ubuntu-latest
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
env:
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
run: ./Push.ps1
shell: pwsh
- name: Push to NuGet
env:
NUGET_URL: https://api.nuget.org/v3/index.json
NUGET_API_KEY: ${{ secrets.AUTOMAPPER_NUGET_API_KEY }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts/**/*
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
- name: Build and Test
run: ./Build.ps1
shell: pwsh
- name: Push to MyGet
env:
NUGET_URL: https://f.feedz.io/lucky-penny-software/automapper/nuget/index.json
NUGET_API_KEY: ${{ secrets.FEEDZIO_ACCESS_TOKEN }}
run: ./Push.ps1
shell: pwsh
- name: Push to NuGet
env:
NUGET_URL: https://api.nuget.org/v3/index.json
NUGET_API_KEY: ${{ secrets.AUTOMAPPER_NUGET_API_KEY }}
run: ./Push.ps1
shell: pwsh
- name: Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts/**/*
10 changes: 10 additions & 0 deletions AutoMapper.WindowsCI.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"solution": {
"path": "AutoMapper.sln",
"projects": [
"src\\AutoMapper\\AutoMapper.csproj",
"src\\AutoMapper.DI.Tests\\AutoMapper.DI.Tests.csproj",
"src\\UnitTests\\AutoMapper.UnitTests.csproj"
]
}
}
16 changes: 14 additions & 2 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ $artifacts = ".\artifacts"

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

exec { & dotnet test -c Release --results-directory $artifacts -l trx }
if ($env:GITHUB_ACTIONS -eq 'true' -and $env:RUNNER_OS -eq 'Windows') {
Write-Host "✅ Running inside GitHub Actions on a Windows runner"
$solution = "./AutoMapper.WindowsCI.slnf"
}
else {
Write-Host "🖥️ Running locally or on a different platform"
$solution = "./AutoMapper.sln"
}

exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj -c Release -o $artifacts --no-build }
exec { & dotnet test $solution --configuration Release --results-directory $artifacts --logger trx }

# Only pack AutoMapper project on Windows runners in GitHub Actions
if ($env:GITHUB_ACTIONS -eq 'true' -and $env:RUNNER_OS -eq 'Windows') {
exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj --configuration Release --output $artifacts --no-build }
}
9 changes: 9 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup>
<IsMac>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_OSX())))</IsMac>
<IsWindows>$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows())))</IsWindows>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net471' Or '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);FULL_OR_STANDARD</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Using Include="System.Reflection"/>
<Using Include="System.Diagnostics"/>
Expand Down
6 changes: 3 additions & 3 deletions src/AutoMapper/AutoMapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(IsWindows)' == 'true' ">
<TargetFrameworks>$(TargetFrameworks);net462</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks);net471</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -47,9 +47,9 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="[8.0.0, )"/>
<PackageReference Include="Microsoft.Extensions.Options" Version="[8.0.0, )"/>
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="[8.14.0, )"/>
<PackageReference Include="Microsoft.Bcl.HashCode" Version="[6.0.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="[6.0.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'net471'" />
<PackageReference Include="System.Reflection.Emit" Version="[4.7.0, )" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
<PackageReference Include="PolySharp" Version="1.15.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" PrivateAssets="All" />
<PackageReference Include="PolySharp" Version="1.15.0" Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'net471'" PrivateAssets="All" />

<PackageReference Include="MinVer" Version="6.0.0" PrivateAssets="All"/>
<!-- <PackageReference Include="Microsoft.DotNet.ApiCompat" Version="7.0.0-beta.22074.1" PrivateAssets="All" /> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static IPropertyMapConfiguration Create(LambdaExpression destination, L
public LambdaExpression SourceExpression => _sourceExpression;
public LambdaExpression GetDestinationExpression() => _destinationExpression;
public IPropertyMapConfiguration Reverse() => Create(_sourceExpression, _destinationExpression);
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public bool Ignored => false;
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/AutoMapper/Execution/TypeMapPlanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ public IValueResolver CloseGenerics(TypeMap typeMap) => _members[0].DeclaringTyp
Array.ConvertAll(_members, m => m.Name), typeMap))
: this;

#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public string SourceMemberName => null;
#endif
}
Expand All @@ -607,7 +607,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me
configuration.ConvertReplaceParameters(Lambda, [source, destination, destinationMember, ContextParameter]);

public MemberInfo GetSourceMember(MemberMap _) => null;
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public string SourceMemberName => null;
public LambdaExpression ProjectToExpression => null;
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
Expand All @@ -634,7 +634,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me
public MemberInfo GetSourceMember(MemberMap _) => Lambda.GetMember();
public LambdaExpression ProjectToExpression => Lambda;

#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public string SourceMemberName => null;
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
#endif
Expand Down Expand Up @@ -701,7 +701,7 @@ AutoMapperConfigurationException BuildExceptionMessage()
_ => memberMap.SourceMembers.Length == 1 ? memberMap.SourceMembers[0] : null
};

#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public LambdaExpression ProjectToExpression => null;
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
#endif
Expand Down Expand Up @@ -760,7 +760,7 @@ public Expression GetExpression(IGlobalConfiguration configuration, MemberMap me

public MemberInfo GetSourceMember(MemberMap _) => SourceMemberLambda?.GetMember();

#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public LambdaExpression ProjectToExpression => null;
public IValueResolver CloseGenerics(TypeMap typeMap) => this;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/AutoMapper/Internal/Polyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;

#if NETSTANDARD2_0
#if FULL_OR_STANDARD
namespace AutoMapper;

internal static class Polyfill
Expand Down
2 changes: 1 addition & 1 deletion src/AutoMapper/Mappers/AssignableMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public sealed class AssignableMapper : IObjectMapper
public bool IsMatch(TypePair context) => context.DestinationType.IsAssignableFrom(context.SourceType);
public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap,
MemberMap memberMap, Expression sourceExpression, Expression destExpression) => sourceExpression;
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public TypePair? GetAssociatedTypes(TypePair initialTypes) => null;
#endif
}
2 changes: 1 addition & 1 deletion src/AutoMapper/Mappers/CollectionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void GetDestinationType()
return;
}
destinationElementType = GetEnumerableElementType(destinationType);
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
destinationCollectionType = destinationType.IsGenericType(typeof(ISet<>)) ? typeof(HashSet<>) : typeof(ICollection<>);
#else
destinationCollectionType = destinationType.IsGenericType(typeof(IReadOnlySet<>)) ? typeof(HashSet<>) : typeof(ICollection<>);
Expand Down
2 changes: 1 addition & 1 deletion src/AutoMapper/Mappers/ConstructorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p
var constructor = GetConstructor(sourceExpression.Type, destExpression.Type);
return New(constructor, ToType(sourceExpression, constructor.FirstParameterType()));
}
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public TypePair? GetAssociatedTypes(TypePair initialTypes) => null;
#endif
}
2 changes: 1 addition & 1 deletion src/AutoMapper/Mappers/ConversionOperatorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p
var conversionOperator = GetConversionOperator(sourceExpression.Type, destExpression.Type);
return Call(conversionOperator, ToType(sourceExpression, conversionOperator.FirstParameterType()));
}
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public TypePair? GetAssociatedTypes(TypePair initialTypes) => null;
#endif
}
2 changes: 1 addition & 1 deletion src/AutoMapper/Mappers/ConvertMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p
var convertMethod = typeof(Convert).GetMethod("To" + destExpression.Type.Name, [sourceExpression.Type]);
return Call(convertMethod, sourceExpression);
}
#if NETSTANDARD2_0
#if FULL_OR_STANDARD
public TypePair? GetAssociatedTypes(TypePair initialTypes) => null;
#endif
}
Loading