Skip to content

Commit e7ba023

Browse files
committed
cosmetic
1 parent 970ab2d commit e7ba023

File tree

13 files changed

+24
-32
lines changed

13 files changed

+24
-32
lines changed

src/AutoMapper/Configuration/MapperConfiguration.cs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ public class MapperConfiguration : IGlobalConfiguration
4545
private readonly LockingConcurrentDictionary<MapRequest, Delegate> _executionPlans;
4646
private readonly ConfigurationValidator _validator;
4747
private readonly Features<IRuntimeFeature> _features = new();
48-
private readonly int _recursiveQueriesMaxDepth;
49-
private readonly int _maxExecutionPlanDepth;
50-
private readonly bool _enableNullPropagationForQueryMapping;
51-
private readonly Func<Type, object> _serviceCtor;
5248
private readonly bool _sealed;
5349
private readonly bool _hasOpenMaps;
5450
private readonly HashSet<TypeMap> _typeMapsPath = new();
@@ -71,11 +67,7 @@ public MapperConfiguration(MapperConfigurationExpression configurationExpression
7167
_mappers = configuration.Mappers.ToArray();
7268
_executionPlans = new(CompileExecutionPlan);
7369
_validator = new(configuration);
74-
_serviceCtor = configuration.ServiceCtor;
75-
_enableNullPropagationForQueryMapping = configuration.EnableNullPropagationForQueryMapping ?? false;
76-
_maxExecutionPlanDepth = configuration.MaxExecutionPlanDepth + 1;
7770
_projectionBuilder = new(CreateProjectionBuilder);
78-
_recursiveQueriesMaxDepth = configuration.RecursiveQueriesMaxDepth;
7971
Configuration = new((IProfileConfiguration)configuration);
8072
int typeMapsCount = Configuration.TypeMapsCount;
8173
int openTypeMapsCount = Configuration.OpenTypeMapsCount;
@@ -233,15 +225,16 @@ LambdaExpression GenerateObjectMapperExpression(in MapRequest mapRequest, IObjec
233225
return Lambda(fullExpression, source, destination, ContextParameter);
234226
}
235227
}
236-
ProjectionBuilder CreateProjectionBuilder() => new(this, _validator.Expression.ProjectionMappers.ToArray());
228+
IGlobalConfigurationExpression ConfigurationExpression => _validator.Expression;
229+
ProjectionBuilder CreateProjectionBuilder() => new(this, ConfigurationExpression.ProjectionMappers.ToArray());
237230
IProjectionBuilder IGlobalConfiguration.ProjectionBuilder => _projectionBuilder.Value;
238-
Func<Type, object> IGlobalConfiguration.ServiceCtor => _serviceCtor;
239-
bool IGlobalConfiguration.EnableNullPropagationForQueryMapping => _enableNullPropagationForQueryMapping;
240-
int IGlobalConfiguration.MaxExecutionPlanDepth => _maxExecutionPlanDepth;
231+
Func<Type, object> IGlobalConfiguration.ServiceCtor => ConfigurationExpression.ServiceCtor;
232+
bool IGlobalConfiguration.EnableNullPropagationForQueryMapping => ConfigurationExpression.EnableNullPropagationForQueryMapping.GetValueOrDefault();
233+
int IGlobalConfiguration.MaxExecutionPlanDepth => ConfigurationExpression.MaxExecutionPlanDepth + 1;
241234
private ProfileMap Configuration { get; }
242235
ProfileMap[] IGlobalConfiguration.Profiles => Profiles;
243236
internal ProfileMap[] Profiles { get; }
244-
int IGlobalConfiguration.RecursiveQueriesMaxDepth => _recursiveQueriesMaxDepth;
237+
int IGlobalConfiguration.RecursiveQueriesMaxDepth => ConfigurationExpression.RecursiveQueriesMaxDepth;
245238
Features<IRuntimeFeature> IGlobalConfiguration.Features => _features;
246239
List<MemberInfo> IGlobalConfiguration.SourceMembers => _sourceMembers;
247240
List<ParameterExpression> IGlobalConfiguration.Variables => _variables;

src/AutoMapper/Configuration/MappingExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public IMappingExpression<TSource, TDestination> IncludeMembers(params Expressio
8989
e =>
9090
{
9191
var bodyIsCastToObject = e.Body.NodeType == ExpressionType.Convert && e.Body.Type == typeof(object);
92-
return bodyIsCastToObject ? Expression.Lambda(((UnaryExpression)e.Body).Operand, e.Parameters) : e;
92+
return bodyIsCastToObject ? Lambda(((UnaryExpression)e.Body).Operand, e.Parameters) : e;
9393
});
9494
IncludeMembersCore(memberExpressionsWithoutCastToObject);
9595
return this;

src/AutoMapper/Execution/ExpressionBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,5 @@ public class ParameterReplaceVisitor : ReplaceVisitorBase
449449
public class ConvertParameterReplaceVisitor : ParameterReplaceVisitor
450450
{
451451
public override Expression Replace(Expression target, Expression oldNode, Expression newNode) =>
452-
base.Replace(target, oldNode, ExpressionBuilder.ToType(newNode, oldNode.Type));
452+
base.Replace(target, oldNode, ToType(newNode, oldNode.Type));
453453
}

src/AutoMapper/Internal/TypeDetails.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ class GenericMethod : MemberInfo
9393
{
9494
readonly MethodInfo _genericMethod;
9595
readonly Type _genericInterface;
96-
MethodInfo _closedMethod = ExpressionBuilder.DecTypeDepthInfo;
96+
MethodInfo _closedMethod = DecTypeDepthInfo;
9797
public GenericMethod(MethodInfo genericMethod, Type genericInterface)
9898
{
9999
_genericMethod = genericMethod;
100100
_genericInterface = genericInterface;
101101
}
102102
public MethodInfo Close()
103103
{
104-
if (_closedMethod == ExpressionBuilder.DecTypeDepthInfo)
104+
if (_closedMethod == DecTypeDepthInfo)
105105
{
106106
// Use method.MakeGenericMethod(genericArguments) wrapped in a try/catch(ArgumentException)
107107
// in order to catch exceptions resulting from the generic arguments not being compatible

src/AutoMapper/Mappers/ConstructorMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ private static ConstructorInfo GetConstructor(Type sourceType, Type destinationT
77
public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression)
88
{
99
var constructor = GetConstructor(sourceExpression.Type, destExpression.Type);
10-
return Expression.New(constructor, ToType(sourceExpression, constructor.FirstParameterType()));
10+
return New(constructor, ToType(sourceExpression, constructor.FirstParameterType()));
1111
}
1212
}

src/AutoMapper/Mappers/ConversionOperatorMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ private MethodInfo GetConversionOperator(Type sourceType, Type destinationType)
1818
public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression)
1919
{
2020
var conversionOperator = GetConversionOperator(sourceExpression.Type, destExpression.Type);
21-
return Expression.Call(conversionOperator, ToType(sourceExpression, conversionOperator.FirstParameterType()));
21+
return Call(conversionOperator, ToType(sourceExpression, conversionOperator.FirstParameterType()));
2222
}
2323
}

src/AutoMapper/Mappers/KeyValueMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap p
1212
var values = new TypePair(sourceArguments[1], destinationArguments[1]);
1313
var mapKeys = configuration.MapExpression(profileMap, keys, ExpressionBuilder.Property(sourceExpression, "Key"));
1414
var mapValues = configuration.MapExpression(profileMap, values, ExpressionBuilder.Property(sourceExpression, "Value"));
15-
return Expression.New(destinationType.GetConstructor(destinationArguments), mapKeys, mapValues);
15+
return New(destinationType.GetConstructor(destinationArguments), mapKeys, mapValues);
1616
}
1717
}

src/AutoMapper/Mappers/ParseStringMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ public class ParseStringMapper : IObjectMapper
55
public bool IsMatch(TypePair context) => context.SourceType == typeof(string) && HasParse(context.DestinationType);
66
static bool HasParse(Type type) => type == typeof(Guid) || type == typeof(TimeSpan) || type == typeof(DateTimeOffset);
77
public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) =>
8-
Expression.Call(destExpression.Type.GetMethod("Parse", new[] { typeof(string) }), sourceExpression);
8+
Call(destExpression.Type.GetMethod("Parse", new[] { typeof(string) }), sourceExpression);
99
}

src/AutoMapper/Mappers/ToStringMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class ToStringMapper : IObjectMapper
55
public Expression MapExpression(IGlobalConfiguration configuration, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression)
66
{
77
var sourceType = sourceExpression.Type;
8-
var toStringCall = Call(sourceExpression, ExpressionBuilder.ObjectToString);
8+
var toStringCall = Call(sourceExpression, ObjectToString);
99
return sourceType.IsEnum ? StringToEnumMapper.CheckEnumMember(sourceExpression, sourceType, toStringCall) : toStringCall;
1010
}
1111
}

src/AutoMapper/QueryableExtensions/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static class Extensions
99
{
1010
static readonly MethodInfo SelectMethod = typeof(Queryable).StaticGenericMethod("Select", parametersCount: 2);
1111
static IQueryable Select(IQueryable source, LambdaExpression lambda) => source.Provider.CreateQuery(
12-
Expression.Call(SelectMethod.MakeGenericMethod(source.ElementType, lambda.ReturnType), source.Expression, Expression.Quote(lambda)));
12+
Call(SelectMethod.MakeGenericMethod(source.ElementType, lambda.ReturnType), source.Expression, Quote(lambda)));
1313
/// <summary>
1414
/// Extension method to project from a queryable using the provided mapping engine
1515
/// </summary>

0 commit comments

Comments
 (0)