diff --git a/src/ExpressionDebugger/ExpressionDebugger.csproj b/src/ExpressionDebugger/ExpressionDebugger.csproj
index 6b9241c3..530de3d6 100644
--- a/src/ExpressionDebugger/ExpressionDebugger.csproj
+++ b/src/ExpressionDebugger/ExpressionDebugger.csproj
@@ -21,9 +21,6 @@
-
-
-
diff --git a/src/ExpressionTranslator/ExpressionTranslator.csproj b/src/ExpressionTranslator/ExpressionTranslator.csproj
index 70f574b7..8d4f5de6 100644
--- a/src/ExpressionTranslator/ExpressionTranslator.csproj
+++ b/src/ExpressionTranslator/ExpressionTranslator.csproj
@@ -21,18 +21,6 @@
enable
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Mapster.Async/Mapster.Async.csproj b/src/Mapster.Async/Mapster.Async.csproj
index 2e5503bb..132ef0a5 100644
--- a/src/Mapster.Async/Mapster.Async.csproj
+++ b/src/Mapster.Async/Mapster.Async.csproj
@@ -1,4 +1,4 @@
-
+
net7.0;net6.0
diff --git a/src/Mapster.Core/Mapster.Core.csproj b/src/Mapster.Core/Mapster.Core.csproj
index e5902ce7..a15e23cc 100644
--- a/src/Mapster.Core/Mapster.Core.csproj
+++ b/src/Mapster.Core/Mapster.Core.csproj
@@ -11,9 +11,6 @@
Mapster.Core.snk
Mapster
-
-
-
diff --git a/src/Mapster.DependencyInjection/Mapster.DependencyInjection.csproj b/src/Mapster.DependencyInjection/Mapster.DependencyInjection.csproj
index 87a2a89b..4723750a 100644
--- a/src/Mapster.DependencyInjection/Mapster.DependencyInjection.csproj
+++ b/src/Mapster.DependencyInjection/Mapster.DependencyInjection.csproj
@@ -9,9 +9,6 @@
Mapster.DependencyInjection.snk
1.0.1-pre02
-
-
-
diff --git a/src/Mapster.Tests/WhenMappingRecordTypes.cs b/src/Mapster.Tests/WhenMappingRecordTypes.cs
index 686f92f5..b855c354 100644
--- a/src/Mapster.Tests/WhenMappingRecordTypes.cs
+++ b/src/Mapster.Tests/WhenMappingRecordTypes.cs
@@ -37,6 +37,19 @@ public void Map_RecordType()
dest.Age.ShouldBe(10);
}
+ [TestMethod]
+ public void Map_RecordType_CapitalizationChanged()
+ {
+ TypeAdapterConfig.NewConfig()
+ .Map(dest => dest.SpecialID, src => src.Id)
+ .Compile();
+
+ var source = new RecordType(Guid.NewGuid(), DayOfWeek.Monday);
+ var dest = source.Adapt();
+
+ dest.SpecialID.ShouldBe(source.Id);
+ }
+
public class SimplePoco
{
public Guid Id { get; set; }
@@ -49,7 +62,7 @@ public class SimpleDto
public string Name { get; set; }
}
- public class RecordType
+ public record RecordType
{
public RecordType(Guid id, DayOfWeek day, string name = "foo", int age = 10)
{
@@ -64,5 +77,7 @@ public RecordType(Guid id, DayOfWeek day, string name = "foo", int age = 10)
public int Age { get; }
public DayOfWeek Day { get; }
}
+
+ public record RecordTypeDto(Guid SpecialID);
}
}
diff --git a/src/Mapster.Tool/Program.cs b/src/Mapster.Tool/Program.cs
index 0d4babc0..dd81c661 100644
--- a/src/Mapster.Tool/Program.cs
+++ b/src/Mapster.Tool/Program.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
+using System.Text;
using CommandLine;
using ExpressionDebugger;
using Mapster.Models;
@@ -495,8 +496,7 @@ private static void GenerateExtensionMethods(MapType mapType, TypeAdapterConfig
{
//add type name to prevent duplication
translator.Translate(entityType);
- var destName = translator.Translate(tuple.Destination);
- destName = destName.Split('.').Last();
+ var destName = GetMethodNameFromType(tuple.Destination);
var name = tuple.Destination.Name == entityType.Name
? destName
@@ -522,5 +522,43 @@ private static void GenerateExtensionMethods(MapType mapType, TypeAdapterConfig
"ProjectTo" + name);
}
}
+
+ private static string GetMethodNameFromType(Type type) => GetMethodNameFromType(new StringBuilder(), type).ToString();
+
+ private static StringBuilder GetMethodNameFromType(StringBuilder sb, Type type)
+ {
+ foreach (var subType in type.GenericTypeArguments)
+ {
+ GetMethodNameFromType(sb, subType);
+ }
+
+ if (type.IsArray)
+ {
+ GetMethodNameFromType(sb, type.GetElementType()!);
+ sb.Append("Array");
+ return sb;
+ }
+
+ var name = type.Name;
+ var i = name.IndexOf('`');
+ if (i>0) name = name.Remove(i);
+ name = name switch
+ {
+ "Nullable" => "",
+ "SByte" => "Sbyte",
+ "Int16" => "Short",
+ "UInt16" => "Ushort",
+ "Int32" => "Int",
+ "UInt32" => "Uint",
+ "Int64" => "Long",
+ "UInt64" => "Ulong",
+ "Single" => "Float",
+ "Boolean" => "Bool",
+ _ => name,
+ };
+
+ if (!string.IsNullOrEmpty(name)) sb.Append(name);
+ return sb;
+ }
}
}
\ No newline at end of file
diff --git a/src/Mapster/Mapster.csproj b/src/Mapster/Mapster.csproj
index 6e314e65..81283f31 100644
--- a/src/Mapster/Mapster.csproj
+++ b/src/Mapster/Mapster.csproj
@@ -14,23 +14,12 @@
https://github.com/MapsterMapper/Mapster
https://github.com/MapsterMapper/Mapster
- 1.6.1
true
Mapster
7.4.0-pre06
enable
1701;1702;8618
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Mapster/Settings/ValueAccessingStrategy.cs b/src/Mapster/Settings/ValueAccessingStrategy.cs
index 29e6e443..ea47d9ad 100644
--- a/src/Mapster/Settings/ValueAccessingStrategy.cs
+++ b/src/Mapster/Settings/ValueAccessingStrategy.cs
@@ -36,7 +36,7 @@ public static class ValueAccessingStrategy
Expression? getter = null;
foreach (var resolver in resolvers)
{
- if (!destinationMember.Name.Equals(resolver.DestinationMemberName))
+ if (!destinationMember.Name.Equals(resolver.DestinationMemberName, StringComparison.InvariantCultureIgnoreCase))
continue;
var invoke = resolver.GetInvokingExpression(source, arg.MapType);
diff --git a/src/Mapster/TypeAdapter.cs b/src/Mapster/TypeAdapter.cs
index 85bc2f62..2e1db2f1 100644
--- a/src/Mapster/TypeAdapter.cs
+++ b/src/Mapster/TypeAdapter.cs
@@ -21,7 +21,7 @@ public static ITypeAdapterBuilder BuildAdapter(this TSource so
/// Destination type.
/// Source object to adapt.
/// Adapted destination type.
- public static TDestination Adapt(this object source)
+ public static TDestination Adapt(this object? source)
{
return Adapt(source, TypeAdapterConfig.GlobalSettings);
}
@@ -33,7 +33,7 @@ public static TDestination Adapt(this object source)
/// Source object to adapt.
/// Configuration
/// Adapted destination type.
- public static TDestination Adapt(this object source, TypeAdapterConfig config)
+ public static TDestination Adapt(this object? source, TypeAdapterConfig config)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if (source == null)