Skip to content

Commit

Permalink
automapper upgrade to v12 (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lghinet authored Nov 22, 2022
1 parent f060866 commit f576cf6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<SerilogExtensionsLoggingPackageVersion>2.0.2</SerilogExtensionsLoggingPackageVersion>
<SerilogSinksMSSqlServerPackageVersion>5.1.2</SerilogSinksMSSqlServerPackageVersion>
<SerilogAspNetCorePackageVersion>2.1.1</SerilogAspNetCorePackageVersion>
<AutoMapperPackageVersion>8.0.0</AutoMapperPackageVersion>
<AutoMapperPackageVersion>12.0.0</AutoMapperPackageVersion>
<OpenTracingPackageVersion>0.12.0</OpenTracingPackageVersion>
<OpenTracingContribPackageVersion>0.5.0</OpenTracingContribPackageVersion>
<SystemDataSqlClientPackageVersion>4.5.0</SystemDataSqlClientPackageVersion>
Expand Down
1 change: 1 addition & 0 deletions src/NBB.Tools.AutomapperExtensions/AutoMapperExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoMapper;
using AutoMapper.Configuration;
using AutoMapper.Internal;
using System;
using System.Linq.Expressions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ public void Should_map_immutable_type_using_constructor_match()
var source = new Source(111, 222);

//Act
Mapper.Initialize(cfg => cfg
.CreateMap<Source, Destination>()
.ForCtorParamMatching(dest => dest.DestinationValue, opt => opt.MapFrom(src => src.SourceValue)));
var config = new MapperConfiguration(cfg =>
{
cfg
.CreateMap<Source, Destination>()
.ForCtorParamMatching(dest => dest.DestinationValue,
opt => opt.MapFrom(src => src.SourceValue));
});

var destination = Mapper.Map<Destination>(source);
var destination = config.CreateMapper().Map<Destination>(source);

//Assert
destination.CommonValue.Should().Be(source.CommonValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net7.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down

0 comments on commit f576cf6

Please sign in to comment.