1+ using System ;
12using System . Text . RegularExpressions ;
23namespace AutoMapper
34{
@@ -15,23 +16,31 @@ public interface INamingConvention
1516 }
1617 public class ExactMatchNamingConvention : INamingConvention
1718 {
18- public static readonly ExactMatchNamingConvention Instance = new ExactMatchNamingConvention ( ) ;
19+ public static readonly ExactMatchNamingConvention Instance = new ( ) ;
1920 public Regex SplittingExpression { get ; }
2021 public string SeparatorCharacter => "" ;
2122 public string ReplaceValue ( Match match ) => match . Value ;
2223 }
2324 public class PascalCaseNamingConvention : INamingConvention
2425 {
25- private static readonly Regex PascalCase = new Regex ( @"(\p{Lu}+(?=$|\p{Lu}[\p{Ll}0-9])|\p{Lu}?[\p{Ll}0-9]+)" ) ;
26- public static readonly PascalCaseNamingConvention Instance = new PascalCaseNamingConvention ( ) ;
26+ private static readonly Regex PascalCase = new ( @"(\p{Lu}+(?=$|\p{Lu}[\p{Ll}0-9])|\p{Lu}?[\p{Ll}0-9]+)" ) ;
27+ public static readonly PascalCaseNamingConvention Instance = new ( ) ;
2728 public Regex SplittingExpression { get ; } = PascalCase ;
2829 public string SeparatorCharacter => string . Empty ;
29- public string ReplaceValue ( Match match ) => match . Value [ 0 ] . ToString ( ) . ToUpper ( ) + match . Value . Substring ( 1 ) ;
30+ public string ReplaceValue ( Match match )
31+ {
32+ var source = match . Value ;
33+ return string . Create ( source . Length , source , static ( buffer , state ) =>
34+ {
35+ buffer [ 0 ] = char . ToUpper ( state [ 0 ] ) ;
36+ ( ( ReadOnlySpan < char > ) state ) [ 1 ..] . CopyTo ( buffer [ 1 ..] ) ;
37+ } ) ;
38+ }
3039 }
3140 public class LowerUnderscoreNamingConvention : INamingConvention
3241 {
33- private static readonly Regex LowerUnderscore = new Regex ( @"[\p{Ll}\p{Lu}0-9]+(?=_?)" ) ;
34- public static readonly LowerUnderscoreNamingConvention Instance = new LowerUnderscoreNamingConvention ( ) ;
42+ private static readonly Regex LowerUnderscore = new ( @"[\p{Ll}\p{Lu}0-9]+(?=_?)" ) ;
43+ public static readonly LowerUnderscoreNamingConvention Instance = new ( ) ;
3544 public Regex SplittingExpression { get ; } = LowerUnderscore ;
3645 public string SeparatorCharacter => "_" ;
3746 public string ReplaceValue ( Match match ) => match . Value . ToLower ( ) ;
0 commit comments