From dd1c63a9f00023ef8bd594108aa99d45875e43a5 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Mon, 3 Nov 2025 13:45:52 -0600 Subject: [PATCH 01/15] Fixing releases to go from Windows pipeline --- .editorconfig | 3 + .github/workflows/release.yml | 112 +++++++++++++++++----------------- 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/.editorconfig b/.editorconfig index 848b5c0181..2524b768e6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -97,4 +97,7 @@ indent_size = 2 indent_size = 2 [*.csproj] +indent_size = 2 + +[*.yml] indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 13d67d3c6c..eda71fcc7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,70 +1,68 @@ +--- 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/**/* \ No newline at end of file + - 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 + - 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/**/* From 15e3361d3ab9e84f3aa4a718f4cf54d0184f3152 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Mon, 3 Nov 2025 13:48:38 -0600 Subject: [PATCH 02/15] Fixing both release pipelines --- .github/workflows/ci.yml | 68 ++++++++++++++++------------------- .github/workflows/release.yml | 7 +--- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9acdc59af4..da05b683ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/checkout@v4.2.0 - 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 @@ -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/**/* \ No newline at end of file + build-windows: + needs: build + strategy: + fail-fast: false + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4.2.0 + 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/**/* diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eda71fcc7b..bc4a42a375 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,12 +42,7 @@ jobs: 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 + run: ./Build.ps1 shell: pwsh - name: Push to MyGet env: From 9f749c7a725aa1b2c40698c21d3d23fcd19c7880 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 09:44:10 -0600 Subject: [PATCH 03/15] Updating test container package --- src/IntegrationTests/AutoMapper.IntegrationTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IntegrationTests/AutoMapper.IntegrationTests.csproj b/src/IntegrationTests/AutoMapper.IntegrationTests.csproj index 72b864934f..47c2f84beb 100644 --- a/src/IntegrationTests/AutoMapper.IntegrationTests.csproj +++ b/src/IntegrationTests/AutoMapper.IntegrationTests.csproj @@ -15,7 +15,7 @@ - + From 14b74b2b4d93ed50d9684e2f7e482eaf7c37673c Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 09:55:05 -0600 Subject: [PATCH 04/15] Trying to specify image --- src/IntegrationTests/IntegrationTest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/IntegrationTests/IntegrationTest.cs b/src/IntegrationTests/IntegrationTest.cs index 9885c18c26..6add81c3b4 100644 --- a/src/IntegrationTests/IntegrationTest.cs +++ b/src/IntegrationTests/IntegrationTest.cs @@ -21,7 +21,9 @@ async Task IAsyncLifetime.DisposeAsync() async Task IAsyncLifetime.InitializeAsync() { - _msSqlContainer = new MsSqlBuilder().Build(); + _msSqlContainer = new MsSqlBuilder() + .WithImage("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") + .Build(); await _msSqlContainer.StartAsync(); } From ef911dc3e88d9cac6e9bf8dd1d8163f76270bd91 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 10:02:25 -0600 Subject: [PATCH 05/15] Trying to set up the WSL 2 environment --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da05b683ce..f5764d08cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,10 @@ jobs: dotnet-version: | 8.0.x 9.0.x + - name: Set up WSL 2 + uses: Vampire/setup-wsl@v6 + with: + distribution: Ubuntu-22.04 - name: Build and Test run: ./Build.ps1 shell: pwsh From 0054d0d6bacd219e9a36bc36393418311e84ecd0 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 10:17:08 -0600 Subject: [PATCH 06/15] Trying a different version --- .github/workflows/release.yml | 1 - src/IntegrationTests/IntegrationTest.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc4a42a375..7e434574c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,3 @@ ---- name: Release on: push: diff --git a/src/IntegrationTests/IntegrationTest.cs b/src/IntegrationTests/IntegrationTest.cs index 6add81c3b4..37e2ab1248 100644 --- a/src/IntegrationTests/IntegrationTest.cs +++ b/src/IntegrationTests/IntegrationTest.cs @@ -22,7 +22,7 @@ async Task IAsyncLifetime.DisposeAsync() async Task IAsyncLifetime.InitializeAsync() { _msSqlContainer = new MsSqlBuilder() - .WithImage("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04") + .WithImage("mcr.microsoft.com/mssql/server:2019-CU28-ubuntu-20.04") .Build(); await _msSqlContainer.StartAsync(); From 4972fd44d608705c153059cc22124ca60448a9ac Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 10:42:12 -0600 Subject: [PATCH 07/15] Excluding EF tests because containers don't work great on Windows --- .github/workflows/ci.yml | 4 ---- AutoMapper.WindowsCI.slnf | 10 ++++++++++ Build.ps1 | 13 +++++++++++-- src/IntegrationTests/IntegrationTest.cs | 4 +--- 4 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 AutoMapper.WindowsCI.slnf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5764d08cf..da05b683ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,6 @@ jobs: dotnet-version: | 8.0.x 9.0.x - - name: Set up WSL 2 - uses: Vampire/setup-wsl@v6 - with: - distribution: Ubuntu-22.04 - name: Build and Test run: ./Build.ps1 shell: pwsh diff --git a/AutoMapper.WindowsCI.slnf b/AutoMapper.WindowsCI.slnf new file mode 100644 index 0000000000..902c599723 --- /dev/null +++ b/AutoMapper.WindowsCI.slnf @@ -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" + ] + } +} diff --git a/Build.ps1 b/Build.ps1 index f78e52ab9b..5552b8ae17 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -26,6 +26,15 @@ $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 test --configuration Release --results-directory $artifacts --logger trx } -exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj -c Release -o $artifacts --no-build } +exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj --configuration Release --output $artifacts --no-build } diff --git a/src/IntegrationTests/IntegrationTest.cs b/src/IntegrationTests/IntegrationTest.cs index 37e2ab1248..9885c18c26 100644 --- a/src/IntegrationTests/IntegrationTest.cs +++ b/src/IntegrationTests/IntegrationTest.cs @@ -21,9 +21,7 @@ async Task IAsyncLifetime.DisposeAsync() async Task IAsyncLifetime.InitializeAsync() { - _msSqlContainer = new MsSqlBuilder() - .WithImage("mcr.microsoft.com/mssql/server:2019-CU28-ubuntu-20.04") - .Build(); + _msSqlContainer = new MsSqlBuilder().Build(); await _msSqlContainer.StartAsync(); } From e9f5cefa4321a3235d7aad1921cee1aed11ba4d1 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 10:51:10 -0600 Subject: [PATCH 08/15] Passing in solution file to test command --- Build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build.ps1 b/Build.ps1 index 5552b8ae17..078a26174a 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -35,6 +35,6 @@ else { $solution = "./AutoMapper.sln" } -exec { & dotnet test --configuration Release --results-directory $artifacts --logger trx } +exec { & dotnet test $solution --configuration Release --results-directory $artifacts --logger trx } exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj --configuration Release --output $artifacts --no-build } From fae3113474e6627ef8080ad68dab1c1cc31e214b Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 10:59:08 -0600 Subject: [PATCH 09/15] Fixing slashes hopefully --- AutoMapper.WindowsCI.slnf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AutoMapper.WindowsCI.slnf b/AutoMapper.WindowsCI.slnf index 902c599723..7cf49bf142 100644 --- a/AutoMapper.WindowsCI.slnf +++ b/AutoMapper.WindowsCI.slnf @@ -2,9 +2,9 @@ "solution": { "path": "AutoMapper.sln", "projects": [ - "src/AutoMapper/AutoMapper.csproj", - "src/AutoMapper.DI.Tests/AutoMapper.DI.Tests.csproj", - "src/UnitTests/AutoMapper.UnitTests.csproj" + "src\\AutoMapper\\AutoMapper.csproj", + "src\\AutoMapper.DI.Tests\\AutoMapper.DI.Tests.csproj", + "src\\UnitTests\\AutoMapper.UnitTests.csproj" ] } } From a06fbb85b08c76c5b1ce9e50a7497c0bf7f1b111 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 11:19:43 -0600 Subject: [PATCH 10/15] Adding flags for Windows builds --- .github/workflows/ci.yml | 5 +++++ Directory.Build.props | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da05b683ce..616a563e29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,11 @@ jobs: - name: Build and Test run: ./Build.ps1 shell: pwsh + - name: Test Artifacts + uses: actions/upload-artifact@v4 + with: + name: artifacts + path: artifacts/**/*.trx build-windows: needs: build strategy: diff --git a/Directory.Build.props b/Directory.Build.props index 52fa6c08a1..009e8f1dd7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,6 +9,11 @@ enable + + $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_OSX()))) + $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows()))) + + From 005a706eeecbfee9a961c77f6d25390f4198424c Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 12:21:58 -0600 Subject: [PATCH 11/15] Fixing some full .NET issues --- Directory.Build.props | 4 ++++ src/AutoMapper/AutoMapper.csproj | 6 +++--- .../Configuration/PathConfigurationExpression.cs | 2 +- src/AutoMapper/Execution/TypeMapPlanBuilder.cs | 10 +++++----- src/AutoMapper/Internal/Polyfill.cs | 2 +- src/AutoMapper/Mappers/AssignableMapper.cs | 2 +- src/AutoMapper/Mappers/CollectionMapper.cs | 2 +- src/AutoMapper/Mappers/ConstructorMapper.cs | 2 +- src/AutoMapper/Mappers/ConversionOperatorMapper.cs | 2 +- src/AutoMapper/Mappers/ConvertMapper.cs | 2 +- src/AutoMapper/Mappers/EnumToEnumMapper.cs | 2 +- src/AutoMapper/Mappers/FromDynamicMapper.cs | 2 +- src/AutoMapper/Mappers/FromStringDictionaryMapper.cs | 2 +- src/AutoMapper/Mappers/IObjectMapper.cs | 2 +- src/AutoMapper/Mappers/KeyValueMapper.cs | 2 +- src/AutoMapper/Mappers/ParseStringMapper.cs | 2 +- src/AutoMapper/Mappers/ToDynamicMapper.cs | 2 +- src/AutoMapper/Mappers/ToStringDictionaryMapper.cs | 2 +- src/AutoMapper/Mappers/ToStringMapper.cs | 2 +- src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs | 2 +- src/AutoMapper/MemberMap.cs | 2 +- .../AutoMapper.IntegrationTests.csproj | 5 ----- src/UnitTests/AutoMapper.UnitTests.csproj | 2 +- 23 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 009e8f1dd7..9b4a5ab2dd 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -14,6 +14,10 @@ $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::get_Windows()))) + + $(DefineConstants);FULL_OR_STANDARD + + diff --git a/src/AutoMapper/AutoMapper.csproj b/src/AutoMapper/AutoMapper.csproj index fd7eab49a6..0e183d062c 100644 --- a/src/AutoMapper/AutoMapper.csproj +++ b/src/AutoMapper/AutoMapper.csproj @@ -30,7 +30,7 @@ - $(TargetFrameworks);net462 + $(TargetFrameworks);net471 @@ -47,9 +47,9 @@ - + - + diff --git a/src/AutoMapper/Configuration/PathConfigurationExpression.cs b/src/AutoMapper/Configuration/PathConfigurationExpression.cs index 9a6d4e1ef4..efdd49a9db 100644 --- a/src/AutoMapper/Configuration/PathConfigurationExpression.cs +++ b/src/AutoMapper/Configuration/PathConfigurationExpression.cs @@ -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 diff --git a/src/AutoMapper/Execution/TypeMapPlanBuilder.cs b/src/AutoMapper/Execution/TypeMapPlanBuilder.cs index 5fe693bf8e..06cf1de571 100644 --- a/src/AutoMapper/Execution/TypeMapPlanBuilder.cs +++ b/src/AutoMapper/Execution/TypeMapPlanBuilder.cs @@ -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 } @@ -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; @@ -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 @@ -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 @@ -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 diff --git a/src/AutoMapper/Internal/Polyfill.cs b/src/AutoMapper/Internal/Polyfill.cs index 0c8ce9c07d..48290f321f 100644 --- a/src/AutoMapper/Internal/Polyfill.cs +++ b/src/AutoMapper/Internal/Polyfill.cs @@ -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 diff --git a/src/AutoMapper/Mappers/AssignableMapper.cs b/src/AutoMapper/Mappers/AssignableMapper.cs index 21db7f70a1..fe0f39f6b2 100644 --- a/src/AutoMapper/Mappers/AssignableMapper.cs +++ b/src/AutoMapper/Mappers/AssignableMapper.cs @@ -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 } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/CollectionMapper.cs b/src/AutoMapper/Mappers/CollectionMapper.cs index 955c42e7c9..c7769b20fa 100644 --- a/src/AutoMapper/Mappers/CollectionMapper.cs +++ b/src/AutoMapper/Mappers/CollectionMapper.cs @@ -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<>); diff --git a/src/AutoMapper/Mappers/ConstructorMapper.cs b/src/AutoMapper/Mappers/ConstructorMapper.cs index cabe36aab2..3deac9f68f 100644 --- a/src/AutoMapper/Mappers/ConstructorMapper.cs +++ b/src/AutoMapper/Mappers/ConstructorMapper.cs @@ -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 } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/ConversionOperatorMapper.cs b/src/AutoMapper/Mappers/ConversionOperatorMapper.cs index f59061c9b4..469343015a 100644 --- a/src/AutoMapper/Mappers/ConversionOperatorMapper.cs +++ b/src/AutoMapper/Mappers/ConversionOperatorMapper.cs @@ -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 } diff --git a/src/AutoMapper/Mappers/ConvertMapper.cs b/src/AutoMapper/Mappers/ConvertMapper.cs index 1812c0bdb9..767ec457fd 100644 --- a/src/AutoMapper/Mappers/ConvertMapper.cs +++ b/src/AutoMapper/Mappers/ConvertMapper.cs @@ -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 } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/EnumToEnumMapper.cs b/src/AutoMapper/Mappers/EnumToEnumMapper.cs index 8d8c793706..3a6827214e 100644 --- a/src/AutoMapper/Mappers/EnumToEnumMapper.cs +++ b/src/AutoMapper/Mappers/EnumToEnumMapper.cs @@ -16,7 +16,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p statements.Add(Condition(tryParse, result, Convert(sourceExpression, destinationType))); return Block(variables, statements); } -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/FromDynamicMapper.cs b/src/AutoMapper/Mappers/FromDynamicMapper.cs index f1b1663b01..34928c66ad 100644 --- a/src/AutoMapper/Mappers/FromDynamicMapper.cs +++ b/src/AutoMapper/Mappers/FromDynamicMapper.cs @@ -35,7 +35,7 @@ private static object GetDynamically(string memberName, object target) public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) => Call(MapMethodInfo, sourceExpression, destExpression.ToObject(), Constant(destExpression.Type), ContextParameter, Constant(profileMap)); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/FromStringDictionaryMapper.cs b/src/AutoMapper/Mappers/FromStringDictionaryMapper.cs index 9eb8a20c21..95035d420c 100644 --- a/src/AutoMapper/Mappers/FromStringDictionaryMapper.cs +++ b/src/AutoMapper/Mappers/FromStringDictionaryMapper.cs @@ -81,7 +81,7 @@ object GetInnerDestination() } } } -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/IObjectMapper.cs b/src/AutoMapper/Mappers/IObjectMapper.cs index da78ab9bdc..a0907ccd7d 100644 --- a/src/AutoMapper/Mappers/IObjectMapper.cs +++ b/src/AutoMapper/Mappers/IObjectMapper.cs @@ -68,7 +68,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p Constant(destExpression.Type), ContextParameter); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/KeyValueMapper.cs b/src/AutoMapper/Mappers/KeyValueMapper.cs index 8eacc4c991..aba9503455 100644 --- a/src/AutoMapper/Mappers/KeyValueMapper.cs +++ b/src/AutoMapper/Mappers/KeyValueMapper.cs @@ -14,7 +14,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p var mapValues = configuration.MapExpression(profileMap, values, ExpressionBuilder.Property(sourceExpression, "Value")); return New(destinationType.GetConstructor(destinationArguments), mapKeys, mapValues); } -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/ParseStringMapper.cs b/src/AutoMapper/Mappers/ParseStringMapper.cs index ff8dc4f81d..033926c5cd 100644 --- a/src/AutoMapper/Mappers/ParseStringMapper.cs +++ b/src/AutoMapper/Mappers/ParseStringMapper.cs @@ -6,7 +6,7 @@ public sealed class ParseStringMapper : IObjectMapper static bool HasParse(Type type) => type == typeof(Guid) || type == typeof(TimeSpan) || type == typeof(DateTimeOffset); public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) => Call(destExpression.Type.GetMethod("Parse", [typeof(string)]), sourceExpression); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/ToDynamicMapper.cs b/src/AutoMapper/Mappers/ToDynamicMapper.cs index 236ede8300..7b1e37c021 100644 --- a/src/AutoMapper/Mappers/ToDynamicMapper.cs +++ b/src/AutoMapper/Mappers/ToDynamicMapper.cs @@ -39,7 +39,7 @@ private static void SetDynamically(string memberName, object target, object valu public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) => Call(MapMethodInfo, sourceExpression.ToObject(), destExpression, Constant(destExpression.Type), ContextParameter, Constant(profileMap)); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/ToStringDictionaryMapper.cs b/src/AutoMapper/Mappers/ToStringDictionaryMapper.cs index 5ccf55d4cb..761af30019 100644 --- a/src/AutoMapper/Mappers/ToStringDictionaryMapper.cs +++ b/src/AutoMapper/Mappers/ToStringDictionaryMapper.cs @@ -7,7 +7,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p Call(MembersDictionaryMethodInfo, sourceExpression.ToObject(), Constant(profileMap)); private static Dictionary MembersDictionary(object source, ProfileMap profileMap) => profileMap.CreateTypeDetails(source.GetType()).ReadAccessors.ToDictionary(p => p.Name, p => p.GetMemberValue(source)); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/ToStringMapper.cs b/src/AutoMapper/Mappers/ToStringMapper.cs index b3d4ac9a54..76abc6c00b 100644 --- a/src/AutoMapper/Mappers/ToStringMapper.cs +++ b/src/AutoMapper/Mappers/ToStringMapper.cs @@ -8,7 +8,7 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p var toStringCall = Call(sourceExpression, ObjectToString); return sourceType.IsEnum ? StringToEnumMapper.CheckEnumMember(sourceExpression, sourceType, toStringCall) : toStringCall; } -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } \ No newline at end of file diff --git a/src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs b/src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs index 230c5a8ef9..acca725f54 100644 --- a/src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs +++ b/src/AutoMapper/Mappers/UnderlyingEnumTypeMapper.cs @@ -5,7 +5,7 @@ public sealed class UnderlyingTypeEnumMapper : IObjectMapper public bool IsMatch(TypePair context) => context.IsEnumToUnderlyingType() || context.IsUnderlyingTypeToEnum(); 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 } \ No newline at end of file diff --git a/src/AutoMapper/MemberMap.cs b/src/AutoMapper/MemberMap.cs index 123b5de2c1..2a5805bccc 100644 --- a/src/AutoMapper/MemberMap.cs +++ b/src/AutoMapper/MemberMap.cs @@ -93,7 +93,7 @@ Expression IValueResolver.GetExpression(IGlobalConfiguration configuration, Memb MemberInfo IValueResolver.GetSourceMember(MemberMap memberMap) => SourceMembers[0]; Type IValueResolver.ResolvedType => SourceMembers[^1].GetMemberType(); -#if NETSTANDARD2_0 +#if FULL_OR_STANDARD public string SourceMemberName => null; public LambdaExpression ProjectToExpression => null; public IValueResolver CloseGenerics(TypeMap typeMap) => this; diff --git a/src/IntegrationTests/AutoMapper.IntegrationTests.csproj b/src/IntegrationTests/AutoMapper.IntegrationTests.csproj index 47c2f84beb..ccbd115d90 100644 --- a/src/IntegrationTests/AutoMapper.IntegrationTests.csproj +++ b/src/IntegrationTests/AutoMapper.IntegrationTests.csproj @@ -7,11 +7,6 @@ true - - true - $(TargetFrameworks);net462 - - diff --git a/src/UnitTests/AutoMapper.UnitTests.csproj b/src/UnitTests/AutoMapper.UnitTests.csproj index 31e14ffddd..5e37fcc40c 100644 --- a/src/UnitTests/AutoMapper.UnitTests.csproj +++ b/src/UnitTests/AutoMapper.UnitTests.csproj @@ -9,7 +9,7 @@ true - $(TargetFrameworks);net462 + $(TargetFrameworks);net471 From 3667a2ba2fd175ebdae4d7344a9a310240ae34d4 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 15:02:58 -0600 Subject: [PATCH 12/15] Fixing compile errors --- src/UnitTests/ArraysAndLists.cs | 2 +- src/UnitTests/Mappers/CustomMapperTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UnitTests/ArraysAndLists.cs b/src/UnitTests/ArraysAndLists.cs index ce9eaabad8..eb02f5dd4c 100644 --- a/src/UnitTests/ArraysAndLists.cs +++ b/src/UnitTests/ArraysAndLists.cs @@ -159,7 +159,7 @@ public Expression MapExpression(IGlobalConfiguration configurationProvider, Prof MemberMap memberMap, Expression sourceExpression, Expression destExpression) => Expression.Multiply(Expression.Convert(sourceExpression, typeof(int)), Expression.Constant(1000)); -#if NET481 +#if NET471_OR_GREATER public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } diff --git a/src/UnitTests/Mappers/CustomMapperTests.cs b/src/UnitTests/Mappers/CustomMapperTests.cs index e97b0e6230..975b5fe99c 100644 --- a/src/UnitTests/Mappers/CustomMapperTests.cs +++ b/src/UnitTests/Mappers/CustomMapperTests.cs @@ -67,7 +67,7 @@ public Expression MapExpression(IGlobalConfiguration configurationProvider, Prof return expr.Body; } -#if NET481 +#if NET471_OR_GREATER public TypePair? GetAssociatedTypes(TypePair initialTypes) => null; #endif } From 3c464499f5ea6ce082f10e9086b642ac42155995 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 15:14:31 -0600 Subject: [PATCH 13/15] Fixing compile errors --- src/UnitTests/ForPath.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnitTests/ForPath.cs b/src/UnitTests/ForPath.cs index 0c944747e6..eb45f2b165 100644 --- a/src/UnitTests/ForPath.cs +++ b/src/UnitTests/ForPath.cs @@ -254,7 +254,7 @@ public void Should_throw_exception() { var cfg = new MapperConfiguration(config => { - Assert.Throws(() => + Assert.Throws(() => { config.CreateMap() .ForPath(sourceModel => sourceModel.Name, opts => opts.MapFrom(null)); From 3428bd649cccf177082aacf76163cdd4c0163755 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 15:34:34 -0600 Subject: [PATCH 14/15] Only packing on the correct runner --- Build.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Build.ps1 b/Build.ps1 index 078a26174a..b37ce69612 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -37,4 +37,7 @@ else { exec { & dotnet test $solution --configuration Release --results-directory $artifacts --logger trx } -exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj --configuration Release --output $artifacts --no-build } +# 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 } +} From 49d6de4eb8228b9abc88281a43cd72b9dbdb1005 Mon Sep 17 00:00:00 2001 From: Jimmy Bogard Date: Tue, 4 Nov 2025 15:43:06 -0600 Subject: [PATCH 15/15] Skipping artifacts for *nix run --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 616a563e29..da05b683ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,11 +33,6 @@ jobs: - name: Build and Test run: ./Build.ps1 shell: pwsh - - name: Test Artifacts - uses: actions/upload-artifact@v4 - with: - name: artifacts - path: artifacts/**/*.trx build-windows: needs: build strategy: