Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
667a3d5
use Enum.Parse<TEnum>
lbargaoanu Jul 30, 2022
77086e8
less allocations
lbargaoanu Jul 31, 2022
e3aecd3
reuse the execution plan between user Map calls and internal Map calls
lbargaoanu Aug 1, 2022
6581906
remove IObjectMapperInfo
lbargaoanu Aug 2, 2022
5f0cebd
use the more efficient Expression.Invoke instead of ConvertReplacePar…
lbargaoanu Aug 3, 2022
9fc7cdf
less allocations
lbargaoanu Aug 3, 2022
7fdf915
less null checks
lbargaoanu Aug 4, 2022
4b507ee
unreachable, As maps are sealed by default
lbargaoanu Aug 6, 2022
84e3fff
less allocations
lbargaoanu Aug 6, 2022
b5cc0a6
don't try to match ignored members
lbargaoanu Aug 7, 2022
df48e72
more efficient
lbargaoanu Aug 7, 2022
12eaef9
drop RegEx
lbargaoanu Aug 8, 2022
06b0713
docs
lbargaoanu Aug 8, 2022
dc7e58f
cosmetic
lbargaoanu Aug 8, 2022
9356388
less allocations
lbargaoanu Aug 8, 2022
39fccd9
cosmetic
lbargaoanu Aug 9, 2022
a3ae964
less allocations
lbargaoanu Aug 9, 2022
00d29ee
we don't need to create As type maps
lbargaoanu Aug 11, 2022
c9bceef
remove ITypeMapConfiguration
lbargaoanu Aug 11, 2022
a0988d7
cosmetic
lbargaoanu Aug 11, 2022
0b9cf8c
try to show a better error message when mapping records through const…
lbargaoanu Aug 11, 2022
b9699dd
less allocations
lbargaoanu Aug 13, 2022
ed9097f
special case the defaults for naming conventions
lbargaoanu Aug 13, 2022
93576ef
make TypeMapPlanBuilder a struct
lbargaoanu Aug 15, 2022
3adb02f
use readonly record struct
lbargaoanu Aug 15, 2022
7720ac8
assume that a protected constructor with CompilerGeneratedAttribute m…
lbargaoanu Aug 15, 2022
4e1117f
less allocations
lbargaoanu Aug 15, 2022
dac3062
rename configurationProvider to the shorter configuration in most places
lbargaoanu Aug 17, 2022
b24560f
less allocations
lbargaoanu Aug 17, 2022
953d66d
converters with no source should throw
lbargaoanu Aug 17, 2022
ebd2c43
less allocations
lbargaoanu Aug 18, 2022
c5d7c36
cosmetic
lbargaoanu Aug 18, 2022
12676dd
less allocations
lbargaoanu Aug 19, 2022
85ff705
make MapFrom name more like the built-in mapping
lbargaoanu Aug 19, 2022
c71f168
less allocations
lbargaoanu Aug 20, 2022
3de255f
cosmetic
lbargaoanu Aug 21, 2022
6925737
use profiles in the benchmark
lbargaoanu Aug 21, 2022
08ec72a
simplify conventions
lbargaoanu Aug 21, 2022
e9287a2
merge the profile member configuration with the global one
lbargaoanu Aug 21, 2022
0d2aa50
cosmetic
lbargaoanu Aug 22, 2022
ec0a832
test reusing the execution plan
lbargaoanu Aug 22, 2022
593ad53
refactor test base classes
lbargaoanu Aug 22, 2022
806e73f
cosmetic
lbargaoanu Aug 23, 2022
d0e0e24
avoid changing the resolver configuration objects because they're reu…
lbargaoanu Aug 31, 2022
77e0015
cosmetic
lbargaoanu Aug 31, 2022
20c283a
less allocations
lbargaoanu Sep 3, 2022
66f0020
cosmetic
lbargaoanu Sep 3, 2022
f1655e1
file scoped namespaces
lbargaoanu Sep 3, 2022
288c4ad
global usings
lbargaoanu Sep 3, 2022
e6f2ca3
cosmetic
lbargaoanu Sep 4, 2022
daacd80
less allocations
lbargaoanu Sep 10, 2022
c608787
NullMappingOrderComesFirst
lbargaoanu Sep 10, 2022
434703c
less allocations
lbargaoanu Sep 10, 2022
4ba0e5f
we could include a different constructor
lbargaoanu Sep 10, 2022
b98273e
less allocations
lbargaoanu Sep 10, 2022
7eeaf59
cosmetic
lbargaoanu Sep 11, 2022
efd1df9
allocate _runtimeTypeDetails lazily
lbargaoanu Sep 12, 2022
3a491a3
create the projection builder lazily
lbargaoanu Sep 12, 2022
7da36f6
cosmetic
lbargaoanu Sep 12, 2022
970ab2d
an adhoc fix for including open generic config
lbargaoanu Sep 14, 2022
e7ba023
cosmetic
lbargaoanu Sep 18, 2022
2b99e96
MapFrom should override ignore
lbargaoanu Sep 18, 2022
3f8448a
UseDestinationValueNullable
lbargaoanu Sep 19, 2022
8b83aa7
cosmetic
lbargaoanu Sep 21, 2022
5e0066e
avoid LINQ
lbargaoanu Sep 23, 2022
7d65b78
the destination type name is already in the error message
lbargaoanu Sep 24, 2022
3c2d8cd
cosmetic
lbargaoanu Sep 24, 2022
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
Prev Previous commit
Next Next commit
remove IObjectMapperInfo
  • Loading branch information
lbargaoanu committed Aug 2, 2022
commit 6581906a10c48c99d51237befa96e63f37cbb4c5
10 changes: 9 additions & 1 deletion src/AutoMapper/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'AutoMappe
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'AutoMapper.Configuration.Annotations.UseExistingValueAttribute' changed from '[AttributeUsageAttribute(384)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Field | AttributeTargets.Property)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'AutoMapper.Configuration.Annotations.ValueConverterAttribute' changed from '[AttributeUsageAttribute(384)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Field | AttributeTargets.Property)]' in the implementation.
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'AutoMapper.Configuration.Annotations.ValueResolverAttribute' changed from '[AttributeUsageAttribute(384)]' in the contract to '[AttributeUsageAttribute(AttributeTargets.Field | AttributeTargets.Property)]' in the implementation.
CannotRemoveBaseTypeOrInterface : Type 'AutoMapper.Internal.Mappers.CollectionMapper' does not implement interface 'AutoMapper.Internal.Mappers.IObjectMapperInfo' in the implementation but it does in the contract.
MembersMustExist : Member 'public AutoMapper.Internal.TypePair AutoMapper.Internal.Mappers.CollectionMapper.GetAssociatedTypes(AutoMapper.Internal.TypePair)' does not exist in the implementation but it does exist in the contract.
InterfacesShouldHaveSameMembers : Default interface member 'public System.Nullable<AutoMapper.Internal.TypePair> AutoMapper.Internal.Mappers.IObjectMapper.GetAssociatedTypes(AutoMapper.Internal.TypePair)' is present in the implementation but not in the contract.
TypesMustExist : Type 'AutoMapper.Internal.Mappers.IObjectMapperInfo' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'AutoMapper.Internal.Mappers.NullableDestinationMapper' does not implement interface 'AutoMapper.Internal.Mappers.IObjectMapperInfo' in the implementation but it does in the contract.
MembersMustExist : Member 'public AutoMapper.Internal.TypePair AutoMapper.Internal.Mappers.NullableDestinationMapper.GetAssociatedTypes(AutoMapper.Internal.TypePair)' does not exist in the implementation but it does exist in the contract.
CannotRemoveBaseTypeOrInterface : Type 'AutoMapper.Internal.Mappers.NullableSourceMapper' does not implement interface 'AutoMapper.Internal.Mappers.IObjectMapperInfo' in the implementation but it does in the contract.
MembersMustExist : Member 'public AutoMapper.Internal.TypePair AutoMapper.Internal.Mappers.NullableSourceMapper.GetAssociatedTypes(AutoMapper.Internal.TypePair)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.Linq.IQueryable<TDestination> AutoMapper.QueryableExtensions.Extensions.Map<TSource, TDestination>(System.Linq.IQueryable<TSource>, System.Linq.IQueryable<TDestination>, AutoMapper.IConfigurationProvider)' does not exist in the implementation but it does exist in the contract.
MembersMustExist : Member 'public System.Collections.Generic.IReadOnlyCollection<System.Reflection.MemberInfo> AutoMapper.QueryableExtensions.MemberVisitor.MemberPath.get()' does not exist in the implementation but it does exist in the contract.
TypesMustExist : Type 'AutoMapper.QueryableExtensions.Impl.MemberAccessQueryMapperVisitor' does not exist in the implementation but it does exist in the contract.
Total Issues: 18
Total Issues: 26
8 changes: 2 additions & 6 deletions src/AutoMapper/Configuration/ConfigurationValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,9 @@ private void DryRunTypeMap(ICollection<TypeMap> typeMapsChecked, TypePair types,
}
var context = new ValidationContext(types, memberMap, mapperToUse);
Validate(context);
if(mapperToUse is IObjectMapperInfo mapperInfo)
if (mapperToUse.GetAssociatedTypes(types) is TypePair newTypes && newTypes != types)
{
var newTypePair = mapperInfo.GetAssociatedTypes(types);
if (newTypePair != types)
{
DryRunTypeMap(typeMapsChecked, newTypePair, null, memberMap);
}
DryRunTypeMap(typeMapsChecked, newTypes, null, memberMap);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/AutoMapper/Configuration/MapperConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ TypeMap IGlobalConfiguration.ResolveAssociatedTypeMap(TypePair types)
{
return typeMap;
}
if (FindMapper(types) is IObjectMapperInfo objectMapperInfo)
if (FindMapper(types)?.GetAssociatedTypes(types) is TypePair newTypes)
{
return ResolveTypeMap(objectMapperInfo.GetAssociatedTypes(types));
return ResolveTypeMap(newTypes);
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/AutoMapper/Mappers/CollectionMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace AutoMapper.Internal.Mappers
using static Execution.ExpressionBuilder;
using static Expression;
using static ReflectionHelper;
public class CollectionMapper : IObjectMapperInfo
public class CollectionMapper : IObjectMapper
{
public TypePair GetAssociatedTypes(TypePair context) => new(GetElementType(context.SourceType), GetElementType(context.DestinationType));
public TypePair? GetAssociatedTypes(TypePair context) => new(GetElementType(context.SourceType), GetElementType(context.DestinationType));
public bool IsMatch(TypePair context) => context.IsCollection();
public Expression MapExpression(IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression)
{
Expand Down
6 changes: 1 addition & 5 deletions src/AutoMapper/Mappers/IObjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ public interface IObjectMapper
/// <returns>Map expression</returns>
Expression MapExpression(IGlobalConfiguration configurationProvider, ProfileMap profileMap,
MemberMap memberMap, Expression sourceExpression, Expression destExpression);
TypePair? GetAssociatedTypes(TypePair initialTypes) => null;
}
public interface IObjectMapperInfo : IObjectMapper
{
TypePair GetAssociatedTypes(TypePair initialTypes);
}

/// <summary>
/// Base class for simple object mappers that don't want to use expressions.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/AutoMapper/Mappers/NullableDestinationMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
using AutoMapper.Execution;
namespace AutoMapper.Internal.Mappers
{
public class NullableDestinationMapper : IObjectMapperInfo
public class NullableDestinationMapper : IObjectMapper
{
public bool IsMatch(TypePair context) => context.DestinationType.IsNullableType();
public Expression MapExpression(IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) =>
configurationProvider.MapExpression(profileMap, GetAssociatedTypes(sourceExpression.Type, destExpression.Type), sourceExpression, memberMap);
public TypePair GetAssociatedTypes(TypePair initialTypes) => GetAssociatedTypes(initialTypes.SourceType, initialTypes.DestinationType);
public TypePair? GetAssociatedTypes(TypePair initialTypes) => GetAssociatedTypes(initialTypes.SourceType, initialTypes.DestinationType);
TypePair GetAssociatedTypes(Type sourceType, Type destinationType) => new(sourceType, Nullable.GetUnderlyingType(destinationType));
}
}
4 changes: 2 additions & 2 deletions src/AutoMapper/Mappers/NullableSourceMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using AutoMapper.Execution;
namespace AutoMapper.Internal.Mappers
{
public class NullableSourceMapper : IObjectMapperInfo
public class NullableSourceMapper : IObjectMapper
{
public bool IsMatch(TypePair context) => context.SourceType.IsNullableType();
public Expression MapExpression(IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) =>
configurationProvider.MapExpression(profileMap, GetAssociatedTypes(sourceExpression.Type, destExpression.Type),
ExpressionBuilder.Property(sourceExpression, "Value"), memberMap, destExpression);
public TypePair GetAssociatedTypes(TypePair initialTypes) => GetAssociatedTypes(initialTypes.SourceType, initialTypes.DestinationType);
public TypePair? GetAssociatedTypes(TypePair initialTypes) => GetAssociatedTypes(initialTypes.SourceType, initialTypes.DestinationType);
TypePair GetAssociatedTypes(Type sourceType, Type destinationType) => new(Nullable.GetUnderlyingType(sourceType), destinationType);
}
}