From 5db13683ec6a80b2c7a48376ce5d4c5d1d411ca2 Mon Sep 17 00:00:00 2001 From: Chaowlert Chaisrchalermpol Date: Thu, 9 Apr 2020 11:05:48 +0700 Subject: [PATCH] run analytics --- src/Mapster/Adapters/BaseClassAdapter.cs | 2 +- src/Mapster/Adapters/ObjectType.cs | 6 +----- src/Mapster/Interfaces/IMapper.cs | 1 + src/Mapster/Mapper.cs | 1 + src/Mapster/Mapster.csproj | 1 + src/Mapster/Models/ClassMapping.cs | 2 +- src/Mapster/Models/ClassModel.cs | 2 +- src/Mapster/TypeAdapterBuilder.cs | 8 ++++---- src/Mapster/TypeAdapterConfig.cs | 6 +++--- src/Mapster/Utils/DynamicTypeGenerator.cs | 2 +- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Mapster/Adapters/BaseClassAdapter.cs b/src/Mapster/Adapters/BaseClassAdapter.cs index fb5cca26..35a0495b 100644 --- a/src/Mapster/Adapters/BaseClassAdapter.cs +++ b/src/Mapster/Adapters/BaseClassAdapter.cs @@ -158,7 +158,7 @@ protected Expression CreateInstantiationExpression(Expression source, ClassMappi arguments.Add(getter); } - return Expression.New(classConverter.ConstructorInfo, arguments); + return Expression.New(classConverter.ConstructorInfo!, arguments); } protected virtual ClassModel GetConstructorModel(ConstructorInfo ctor, bool breakOnUnmatched) diff --git a/src/Mapster/Adapters/ObjectType.cs b/src/Mapster/Adapters/ObjectType.cs index dfc938a5..6e23976b 100644 --- a/src/Mapster/Adapters/ObjectType.cs +++ b/src/Mapster/Adapters/ObjectType.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Mapster.Adapters +namespace Mapster.Adapters { public enum ObjectType { diff --git a/src/Mapster/Interfaces/IMapper.cs b/src/Mapster/Interfaces/IMapper.cs index a28607a7..4ef3d2b0 100644 --- a/src/Mapster/Interfaces/IMapper.cs +++ b/src/Mapster/Interfaces/IMapper.cs @@ -1,6 +1,7 @@ using System; using Mapster; +// ReSharper disable once CheckNamespace namespace MapsterMapper { public interface IMapper diff --git a/src/Mapster/Mapper.cs b/src/Mapster/Mapper.cs index 27af30aa..b2342b26 100644 --- a/src/Mapster/Mapper.cs +++ b/src/Mapster/Mapper.cs @@ -2,6 +2,7 @@ using System.Reflection; using Mapster; +// ReSharper disable once CheckNamespace namespace MapsterMapper { public class Mapper : IMapper diff --git a/src/Mapster/Mapster.csproj b/src/Mapster/Mapster.csproj index cfc1f62f..b453639b 100644 --- a/src/Mapster/Mapster.csproj +++ b/src/Mapster/Mapster.csproj @@ -22,6 +22,7 @@ 5.2.0 8.0 enable + 1701;1702;8618 diff --git a/src/Mapster/Models/ClassMapping.cs b/src/Mapster/Models/ClassMapping.cs index 43ce8510..d90d7158 100644 --- a/src/Mapster/Models/ClassMapping.cs +++ b/src/Mapster/Models/ClassMapping.cs @@ -5,7 +5,7 @@ namespace Mapster.Models { internal class ClassMapping { - public ConstructorInfo ConstructorInfo { get; set; } + public ConstructorInfo? ConstructorInfo { get; set; } public List Members { get; set; } } } diff --git a/src/Mapster/Models/ClassModel.cs b/src/Mapster/Models/ClassModel.cs index 98486c1a..3c9946a7 100644 --- a/src/Mapster/Models/ClassModel.cs +++ b/src/Mapster/Models/ClassModel.cs @@ -6,7 +6,7 @@ namespace Mapster.Models internal class ClassModel { public bool BreakOnUnmatched { get; set; } - public ConstructorInfo ConstructorInfo { get; set; } + public ConstructorInfo? ConstructorInfo { get; set; } public IEnumerable Members { get; set; } } } diff --git a/src/Mapster/TypeAdapterBuilder.cs b/src/Mapster/TypeAdapterBuilder.cs index a9d0e9e2..f00ce09e 100644 --- a/src/Mapster/TypeAdapterBuilder.cs +++ b/src/Mapster/TypeAdapterBuilder.cs @@ -44,7 +44,7 @@ public TypeAdapterBuilder AddParameters(string name, object value) return this; } - private MapContextScope createMapContextScope() + private MapContextScope CreateMapContextScope() { var scope = new MapContextScope(); var parameters = scope.Context.Parameters; @@ -56,14 +56,14 @@ private MapContextScope createMapContextScope() return scope; } - MapContextScope IAdapterBuilder.CreateMapContextScope() => createMapContextScope(); + MapContextScope IAdapterBuilder.CreateMapContextScope() => CreateMapContextScope(); public TDestination AdaptToType() { if (_parameters == null) return Map(); - using (this.createMapContextScope()) + using (this.CreateMapContextScope()) { return Map(); } @@ -80,7 +80,7 @@ public TDestination AdaptTo(TDestination destination) if (_parameters == null) return MapToTarget(destination); - using (this.createMapContextScope()) + using (this.CreateMapContextScope()) { return MapToTarget(destination); } diff --git a/src/Mapster/TypeAdapterConfig.cs b/src/Mapster/TypeAdapterConfig.cs index 46e15a44..6187200e 100644 --- a/src/Mapster/TypeAdapterConfig.cs +++ b/src/Mapster/TypeAdapterConfig.cs @@ -299,7 +299,7 @@ internal MethodCallExpression GetProjectionCallExpression(Type sourceType, Type return del; } - private Dictionary _dynamicMapDict; + private Dictionary? _dynamicMapDict; internal Func GetDynamicMapFunction(Type sourceType) { if (_dynamicMapDict == null) @@ -593,7 +593,7 @@ private void Remove(TypeTuple key) _dynamicMapDict?.Remove(key); } - private static TypeAdapterConfig _cloneConfig; + private static TypeAdapterConfig? _cloneConfig; public TypeAdapterConfig Clone() { if (_cloneConfig == null) @@ -607,7 +607,7 @@ public TypeAdapterConfig Clone() return fn(this); } - private Dictionary _inlineConfigs; + private Dictionary? _inlineConfigs; public TypeAdapterConfig Fork(Action action, #if !NET40 [CallerFilePath] diff --git a/src/Mapster/Utils/DynamicTypeGenerator.cs b/src/Mapster/Utils/DynamicTypeGenerator.cs index a9f4f0d1..c44e7be8 100644 --- a/src/Mapster/Utils/DynamicTypeGenerator.cs +++ b/src/Mapster/Utils/DynamicTypeGenerator.cs @@ -123,7 +123,7 @@ private static void CreateProperty(Type interfaceType, TypeBuilder builder, Prop { // Define the "set" accessor method for property. string setMethodName = "set_" + prop.Name; - MethodBuilder propSet = builder.DefineMethod(setMethodName, classPropMethodAttrs, null, new Type[] { prop.PropertyType }); + MethodBuilder propSet = builder.DefineMethod(setMethodName, classPropMethodAttrs, null, new[] { prop.PropertyType }); ILGenerator propSetIL = propSet.GetILGenerator(); propSetIL.Emit(OpCodes.Ldarg_0); propSetIL.Emit(OpCodes.Ldarg_1);