Skip to content

Commit 9a47023

Browse files
committed
merge master to development
2 parents 0875f34 + aa74882 commit 9a47023

File tree

6 files changed

+39
-7
lines changed

6 files changed

+39
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Adding equivalence to objects is done with EqualityComparison extended from the
2424
cfg.CreateMap<OrderItemDTO, OrderItem>().EqualityComparison((odto, o) => odto.ID == o.ID);
2525
Mapping OrderDTO back to Order will compare Order items list based on if their ID's match
2626

27-
Mapper.Map<OrderDTO[],Order[]>(orderDtos, orders);
27+
Mapper.Map<List<OrderDTO>,List<Order>>(orderDtos, orders);
2828
If ID's match will map OrderDTO to Order
2929

3030
If OrderDTO exists and Order doesn't add to collection
@@ -71,4 +71,4 @@ On Nuget
7171
PM> Install-Package AutoMapper.Collection.EntityFramework
7272
Also have AutoMapper.LinqToSQL
7373

74-
PM> Install-Package AutoMapper.Collection.LinqToSQL
74+
PM> Install-Package AutoMapper.Collection.LinqToSQL

src/AutoMapper.Collection.EntityFramework/AutoMapper.Collection.EntityFramework.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<AssemblyOriginatorKeyFile>../Key.snk</AssemblyOriginatorKeyFile>
1313
<SignAssembly>true</SignAssembly>
1414
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
15+
<Version>3.1.4</Version>
1516
</PropertyGroup>
1617

1718
<ItemGroup>

src/AutoMapper.Collection.LinqToSQL/AutoMapper.Collection.LinqToSQL.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<AssemblyOriginatorKeyFile>../Key.snk</AssemblyOriginatorKeyFile>
1313
<SignAssembly>true</SignAssembly>
1414
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
15+
<Version>3.1.4</Version>
1516
</PropertyGroup>
1617

1718
<ItemGroup>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using AutoMapper.EquivalencyExpression;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Threading.Tasks;
5+
6+
namespace AutoMapper.Collection
7+
{
8+
public class MapCollectionWithEqualityThreadSafetyTests
9+
{
10+
public async Task Should_Work_When_Initialized_Concurrently()
11+
{
12+
Action act = () =>
13+
{
14+
new MapperConfiguration(cfg =>
15+
{
16+
cfg.AddCollectionMappers();
17+
});
18+
};
19+
var tasks = new List<Task>();
20+
for (var i = 0; i < 5; i++)
21+
{
22+
tasks.Add(Task.Run(act));
23+
}
24+
25+
await Task.WhenAll(tasks.ToArray());
26+
}
27+
}
28+
}

src/AutoMapper.Collection/AutoMapper.Collection.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<Description>Collection Add/Remove/Update support for AutoMapper. AutoMapper.Collection adds EqualityComparison Expressions for TypeMaps to determine if Source and Destination type are equivalent to each other when mapping collections.</Description>
5+
<VersionPrefix>3.1.3</VersionPrefix>
56
<Authors>Tyler Carlson</Authors>
67
<TargetFrameworks>netstandard2.0;netstandard1.3;net45</TargetFrameworks>
78
<AssemblyName>AutoMapper.Collection</AssemblyName>
@@ -13,6 +14,7 @@
1314
<AssemblyOriginatorKeyFile>../Key.snk</AssemblyOriginatorKeyFile>
1415
<SignAssembly>true</SignAssembly>
1516
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
17+
<Version>3.1.4</Version>
1618
</PropertyGroup>
1719

1820
<ItemGroup>

src/AutoMapper.Collection/EquivalencyExpression/EquivalentExpressions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ namespace AutoMapper.EquivalencyExpression
1212
public static class EquivalentExpressions
1313
{
1414
private static readonly
15-
IDictionary<IConfigurationProvider, ConcurrentDictionary<TypePair, IEquivalentComparer>>
15+
ConcurrentDictionary<IConfigurationProvider, ConcurrentDictionary<TypePair, IEquivalentComparer>>
1616
EquivalentExpressionDictionary =
17-
new Dictionary<IConfigurationProvider, ConcurrentDictionary<TypePair, IEquivalentComparer>>();
17+
new ConcurrentDictionary<IConfigurationProvider, ConcurrentDictionary<TypePair, IEquivalentComparer>>();
1818

1919
private static ConcurrentDictionary<TypePair, IEquivalentComparer> _equalityComparisonCache = new ConcurrentDictionary<TypePair, IEquivalentComparer>();
2020

21-
private static readonly IDictionary<IConfigurationProvider, IList<IGeneratePropertyMaps>> GeneratePropertyMapsDictionary = new Dictionary<IConfigurationProvider, IList<IGeneratePropertyMaps>>();
21+
private static readonly ConcurrentDictionary<IConfigurationProvider, IList<IGeneratePropertyMaps>> GeneratePropertyMapsDictionary = new ConcurrentDictionary<IConfigurationProvider, IList<IGeneratePropertyMaps>>();
2222
private static IList<IGeneratePropertyMaps> _generatePropertyMapsCache = new List<IGeneratePropertyMaps>();
2323

2424
public static void AddCollectionMappers(this IMapperConfigurationExpression cfg)
@@ -41,10 +41,10 @@ private static void InsertBefore<TObjectMapper>(this IMapperConfigurationExpress
4141
foreach (var configurationObjectMapper in adds)
4242
configurationObjectMapper.ConfigurationProvider = c;
4343

44-
EquivalentExpressionDictionary.Add(c, _equalityComparisonCache);
44+
EquivalentExpressionDictionary.AddOrUpdate(c, _equalityComparisonCache, (type, old) => _equalityComparisonCache);
4545
_equalityComparisonCache = new ConcurrentDictionary<TypePair, IEquivalentComparer>();
4646

47-
GeneratePropertyMapsDictionary.Add(c, _generatePropertyMapsCache);
47+
GeneratePropertyMapsDictionary.AddOrUpdate(c, _generatePropertyMapsCache, (type, old) => _generatePropertyMapsCache);
4848
_generatePropertyMapsCache = new List<IGeneratePropertyMaps>();
4949
});
5050
}

0 commit comments

Comments
 (0)