Skip to content

Commit 79fd635

Browse files
committed
cosmetic
1 parent 999d65f commit 79fd635

File tree

11 files changed

+21
-18
lines changed

11 files changed

+21
-18
lines changed

AutoMapper.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
99
.github\workflows\ci.yml = .github\workflows\ci.yml
1010
CONTRIBUTING.md = CONTRIBUTING.md
1111
Directory.Build.props = Directory.Build.props
12+
icon.png = icon.png
1213
ISSUE_TEMPLATE.md = ISSUE_TEMPLATE.md
1314
nuget.config = nuget.config
1415
Push.ps1 = Push.ps1

src/AutoMapper/AutoMapper.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
36-
<None Include="..\..\README.md" Pack="true" PackagePath="" />
35+
<None Include="..\..\icon.png" Pack="true" PackagePath="" Visible="False" />
36+
<None Include="..\..\README.md" Pack="true" PackagePath="" Visible="False" />
3737
</ItemGroup>
3838

3939
<ItemGroup>
@@ -44,8 +44,8 @@
4444
</ItemGroup>
4545

4646
<Target Name="PreBuild" AfterTargets="GetAssemblyVersion">
47-
<Exec Condition=" '$(OS)' == 'Windows_NT' " Command="powershell -ExecutionPolicy Unrestricted -File &quot;$(ProjectDir)\PreBuild.ps1&quot; -version $(Version)" />
48-
<Exec Condition=" '$(OS)' != 'Windows_NT' " Command="&quot;$(ProjectDir)PreBuild.sh&quot; $(Version)" />
47+
<Exec Condition=" '$(OS)' == 'Windows_NT' " Command="powershell -ExecutionPolicy Unrestricted -File &quot;$(ProjectDir)ApiCompat\PreBuild.ps1&quot; -version $(Version)" />
48+
<Exec Condition=" '$(OS)' != 'Windows_NT' " Command="&quot;$(ProjectDir)ApiCompat/PreBuild.sh&quot; $(Version)" />
4949
</Target>
5050

5151
</Project>

src/AutoMapper/Execution/ExpressionBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public static class ExpressionBuilder
3030
public static readonly MethodInfo OverTypeDepthMethod = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.OverTypeDepth));
3131
public static readonly MethodInfo CacheDestinationMethod = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.CacheDestination));
3232
public static readonly MethodInfo GetDestinationMethod = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.GetDestination));
33-
private static readonly MethodInfo CheckContextMethod = typeof(ResolutionContext).GetStaticMethod(nameof(ResolutionContext.CheckContext));
33+
private static readonly MethodCallExpression CheckContextCall = Expression.Call(
34+
typeof(ResolutionContext).GetStaticMethod(nameof(ResolutionContext.CheckContext)), ContextParameter);
3435
private static readonly MethodInfo ContextMapMethod = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.MapInternal));
3536
private static readonly MethodInfo ArrayEmptyMethod = typeof(Array).GetStaticMethod(nameof(Array.Empty));
3637
private static readonly ParameterExpression Disposable = Variable(typeof(IDisposable), "disposableEnumerator");
@@ -143,7 +144,7 @@ public static Expression CheckContext(TypeMap typeMap)
143144
{
144145
if (typeMap.MaxDepth > 0 || typeMap.PreserveReferences)
145146
{
146-
return Expression.Call(CheckContextMethod, ContextParameter);
147+
return CheckContextCall;
147148
}
148149
return null;
149150
}

src/AutoMapper/Execution/ProxyGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class ProxyGenerator
1616
private static readonly EventInfo PropertyChanged = typeof(INotifyPropertyChanged).GetEvent(nameof(INotifyPropertyChanged.PropertyChanged));
1717
private static readonly ConstructorInfo ProxyBaseCtor = typeof(ProxyBase).GetConstructor(Type.EmptyTypes);
1818
private static readonly ModuleBuilder ProxyModule = CreateProxyModule();
19-
private static readonly LockingConcurrentDictionary<TypeDescription, Type> ProxyTypes = new LockingConcurrentDictionary<TypeDescription, Type>(EmitProxy);
19+
private static readonly LockingConcurrentDictionary<TypeDescription, Type> ProxyTypes = new(EmitProxy);
2020
private static ModuleBuilder CreateProxyModule()
2121
{
2222
var assemblyName = typeof(Mapper).Assembly.GetName();

src/AutoMapper/Execution/TypeMapPlanBuilder.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public LambdaExpression CreateMapperLambda(HashSet<TypeMap> typeMapsPath)
4949
{
5050
variables.AddRange(_typeMap.IncludedMembersTypeMaps.Select(i => i.Variable));
5151
statements.AddRange(variables.Zip(_typeMap.IncludedMembersTypeMaps, (v, i) =>
52-
Assign(v, i.MemberExpression.ReplaceParameters(Source).NullCheck())));
52+
Assign(v, i.MemberExpression.ReplaceParameters(parameters).NullCheck())));
5353
}
5454
var createDestinationFunc = CreateDestinationFunc();
5555
var assignmentFunc = CreateAssignmentFunc(createDestinationFunc);
@@ -161,7 +161,8 @@ private Expression CreateAssignmentFunc(Expression createDestination)
161161
{
162162
var actions = new List<Expression> { createDestination };
163163
Expression typeMapExpression = null;
164-
if (_typeMap.MaxDepth > 0)
164+
var hasMaxDepth = _typeMap.MaxDepth > 0;
165+
if (hasMaxDepth)
165166
{
166167
typeMapExpression = Constant(_typeMap);
167168
actions.Add(Call(ContextParameter, IncTypeDepthInfo, typeMapExpression));
@@ -193,7 +194,7 @@ private Expression CreateAssignmentFunc(Expression createDestination)
193194
{
194195
actions.Add(afterMapAction.ReplaceParameters(Source, _destination, ContextParameter));
195196
}
196-
if (_typeMap.MaxDepth > 0)
197+
if (hasMaxDepth)
197198
{
198199
actions.Add(Call(ContextParameter, DecTypeDepthInfo, typeMapExpression));
199200
}
@@ -382,7 +383,7 @@ private Expression BuildValueResolverFunc(MemberMap memberMap, Expression custom
382383
{
383384
valueResolverFunc = memberMap.NullSubstitute(valueResolverFunc);
384385
}
385-
else if (!memberMap.AllowsNullDestinationValues())
386+
else if (!memberMap.AllowsNullDestinationValues)
386387
{
387388
var toCreate = memberMap.SourceType;
388389
if (!toCreate.IsAbstract && toCreate.IsClass && !toCreate.IsArray)

src/AutoMapper/Internal/MemberPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public MemberPath(Stack<Member> members) : this(members.ToMemberInfos()){}
1717

1818
public MemberPath(MemberInfo[] members) => Members = members;
1919

20-
public MemberInfo Last => Members[Members.Length - 1];
20+
public MemberInfo Last => Members[^1];
2121

2222
public MemberInfo First => Members[0];
2323

src/AutoMapper/MemberMap.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ public void MapFrom(string sourceMembersPath)
6060
public Expression ChainSourceMembers(Expression source) => SourceMembers.Chain(source);
6161
public Expression ChainSourceMembers(Expression source, Type destinationType, Expression defaultValue) =>
6262
ChainSourceMembers(source)?.NullCheck(destinationType, defaultValue);
63-
public bool AllowsNullDestinationValues() => Profile?.AllowsNullDestinationValuesFor(this) ?? true;
64-
public bool AllowsNullCollections() => (Profile?.AllowsNullCollectionsFor(this)).GetValueOrDefault();
63+
public bool AllowsNullDestinationValues => Profile?.AllowsNullDestinationValuesFor(this) ?? true;
64+
public bool AllowsNullCollections => (Profile?.AllowsNullCollectionsFor(this)).GetValueOrDefault();
6565
public ProfileMap Profile => TypeMap?.Profile;
6666
private int MaxDepth => (TypeMap?.MaxDepth).GetValueOrDefault();
6767
public bool MapperEquals(MemberMap other)
@@ -71,9 +71,9 @@ public bool MapperEquals(MemberMap other)
7171
return false;
7272
}
7373
return other.MustUseDestination == MustUseDestination && other.MaxDepth == MaxDepth &&
74-
other.AllowsNullDestinationValues() == AllowsNullDestinationValues() && other.AllowsNullCollections() == AllowsNullCollections();
74+
other.AllowsNullDestinationValues == AllowsNullDestinationValues && other.AllowsNullCollections == AllowsNullCollections;
7575
}
76-
public int MapperGetHashCode() => HashCode.Combine(MustUseDestination, MaxDepth, AllowsNullDestinationValues(), AllowsNullCollections());
76+
public int MapperGetHashCode() => HashCode.Combine(MustUseDestination, MaxDepth, AllowsNullDestinationValues, AllowsNullCollections);
7777
protected Type GetSourceType() => Resolver?.ResolvedType ?? DestinationType;
7878
public void MapByConvention(MemberInfo[] sourceMembers)
7979
{

src/AutoMapper/QueryableExtensions/NullsafeQueryRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace AutoMapper.QueryableExtensions
4040
/// </remarks>
4141
internal class NullsafeQueryRewriter : ExpressionVisitor
4242
{
43-
static readonly LockingConcurrentDictionary<Type, Expression> Cache = new LockingConcurrentDictionary<Type, Expression>(Fallback);
43+
static readonly LockingConcurrentDictionary<Type, Expression> Cache = new(Fallback);
4444

4545
public static Expression NullCheck(Expression expression) => new NullsafeQueryRewriter().Visit(expression);
4646

0 commit comments

Comments
 (0)