Skip to content

Commit 83aad52

Browse files
committed
Separate storing underlying types in delegates from property map underlying types.
1 parent 41c44a1 commit 83aad52

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Authors>Jimmy Bogard</Authors>
44
<LangVersion>latest</LangVersion>
5-
<VersionPrefix>1.0.5-preview01</VersionPrefix>
5+
<VersionPrefix>1.0.5-preview02</VersionPrefix>
66
<WarningsAsErrors>true</WarningsAsErrors>
77
<NoWarn>$(NoWarn);1701;1702;1591</NoWarn>
88
</PropertyGroup>

src/AutoMapper.Extensions.ExpressionMapping/MapperExtensions.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private static Dictionary<Type, Type> AddTypeMappingsFromDelegates(this Dictiona
256256
if (typeMappings == null)
257257
throw new ArgumentException(Resource.typeMappingsDictionaryIsNull);
258258

259-
typeMappings.DoAddTypeMappings
259+
typeMappings.DoAddTypeMappingsFromDelegates
260260
(
261261
configurationProvider,
262262
sourceType.GetGenericArguments().ToList(),
@@ -266,7 +266,7 @@ private static Dictionary<Type, Type> AddTypeMappingsFromDelegates(this Dictiona
266266
return typeMappings;
267267
}
268268

269-
private static void DoAddTypeMappings(this Dictionary<Type, Type> typeMappings, IConfigurationProvider configurationProvider, List<Type> sourceArguments, List<Type> destArguments)
269+
private static void DoAddTypeMappingsFromDelegates(this Dictionary<Type, Type> typeMappings, IConfigurationProvider configurationProvider, List<Type> sourceArguments, List<Type> destArguments)
270270
{
271271
if (sourceArguments.Count != destArguments.Count)
272272
throw new ArgumentException(Resource.invalidArgumentCount);
@@ -278,6 +278,18 @@ private static void DoAddTypeMappings(this Dictionary<Type, Type> typeMappings,
278278
}
279279
}
280280

281+
private static void DoAddTypeMappings(this Dictionary<Type, Type> typeMappings, IConfigurationProvider configurationProvider, List<Type> sourceArguments, List<Type> destArguments)
282+
{
283+
if (sourceArguments.Count != destArguments.Count)
284+
return;
285+
286+
for (int i = 0; i < sourceArguments.Count; i++)
287+
{
288+
if (!typeMappings.ContainsKey(sourceArguments[i]) && sourceArguments[i] != destArguments[i])
289+
typeMappings.AddTypeMapping(configurationProvider, sourceArguments[i], destArguments[i]);
290+
}
291+
}
292+
281293
private static void FindChildPropertyTypeMaps(this Dictionary<Type, Type> typeMappings, IConfigurationProvider ConfigurationProvider, Type source, Type dest)
282294
{
283295
//The destination becomes the source because to map a source expression to a destination expression,

0 commit comments

Comments
 (0)