diff --git a/src/.editorconfig b/src/.editorconfig index 3c0a9b60..6600eeea 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -11,3 +11,6 @@ dotnet_diagnostic.S3358.severity = suggestion # S125: Sections of code should not be commented out dotnet_diagnostic.S125.severity = suggestion + +# RCS1146: Use conditional access. +dotnet_diagnostic.RCS1146.severity = suggestion diff --git a/src/Mapster/Adapters/BaseAdapter.cs b/src/Mapster/Adapters/BaseAdapter.cs index 969356f3..0064f889 100644 --- a/src/Mapster/Adapters/BaseAdapter.cs +++ b/src/Mapster/Adapters/BaseAdapter.cs @@ -410,9 +410,9 @@ private static Expression CreateAdaptExpressionCore(Expression source, Type dest if (destination != null) paramList.Add(destination); paramList.AddRange(lambda.Parameters.Skip(paramList.Count)); - if (!lambda.IsMultiLine()) - return lambda.Apply(arg.MapType, paramList.ToArray()); - return Expression.Invoke(lambda, paramList.ToArray()); + return lambda.IsMultiLine() + ? Expression.Invoke(lambda, paramList.ToArray()) + : lambda.Apply(arg.MapType, paramList.ToArray()); } finally {