Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/AutoMapper/Configuration/INamingConvention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public string[] Split(string input)
int lower = 0;
for(int index = 1; index < input.Length; index++)
{
if (char.IsUpper(input[index]))
if (char.IsUpper(input[index]) &&
(!char.IsUpper(input[index - 1]) || (index + 1 < input.Length && !char.IsUpper(input[index + 1]))))
{
result ??= [];
result.Add(input[lower..index]);
Expand Down
18 changes: 18 additions & 0 deletions src/UnitTests/Bug/NamingConventions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@ public void Should_map_from_pascal_to_lower()
}
}


public class PascalCaseAcronymInPropertyName : AutoMapperSpecBase
{
class Source { public Inner Form { get; set; } }
class Inner { public int XML { get; set; } }
class Dest { public int FormXML { get; set; } }

protected override MapperConfiguration CreateConfiguration() => new(cfg =>
cfg.CreateMap<Source, Dest>());

[Fact]
public void Should_flatten_acronym_property()
{
var result = Mapper.Map<Dest>(new Source { Form = new Inner { XML = 42 } });
result.FormXML.ShouldBe(42);
}
}

public class When_mapping_with_lowercase_naming_conventions_two_ways : AutoMapperSpecBase
{
private Dario _dario;
Expand Down
Loading