Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Mapster.Tests/WhenMappingRecordTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public void Map_RecordType()
dest.Age.ShouldBe(10);
}

[TestMethod]
public void Map_RecordType_CapitalizationChanged()
{
TypeAdapterConfig<RecordType, RecordTypeDto>.NewConfig()
.Map(dest => dest.SpecialID, src => src.Id)
.Compile();

var source = new RecordType(Guid.NewGuid(), DayOfWeek.Monday);
var dest = source.Adapt<RecordTypeDto>();

dest.SpecialID.ShouldBe(source.Id);
}

public class SimplePoco
{
public Guid Id { get; set; }
Expand All @@ -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)
{
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion src/Mapster/Settings/ValueAccessingStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down