This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -705,7 +705,8 @@ public static string StripMarkdownMarkup(this string markdown)
705705 private const int LowerCaseOffset = 'a' - 'A' ;
706706 public static string ToCamelCase ( this string value )
707707 {
708- if ( String . IsNullOrEmpty ( value ) ) return value ;
708+ if ( string . IsNullOrEmpty ( value ) )
709+ return value ;
709710
710711 var len = value . Length ;
711712 var newValue = new char [ len ] ;
@@ -731,14 +732,17 @@ public static string ToCamelCase(this string value)
731732
732733 public static string ToPascalCase ( this string value )
733734 {
734- if ( String . IsNullOrEmpty ( value ) ) return value ;
735+ if ( string . IsNullOrEmpty ( value ) )
736+ return value ;
735737
736738 if ( value . IndexOf ( '_' ) >= 0 )
737739 {
738740 var parts = value . Split ( '_' ) ;
739741 var sb = StringBuilderThreadStatic . Allocate ( ) ;
740742 foreach ( var part in parts )
741743 {
744+ if ( string . IsNullOrEmpty ( part ) )
745+ continue ;
742746 var str = part . ToCamelCase ( ) ;
743747 sb . Append ( char . ToUpper ( str [ 0 ] ) + str . SafeSubstring ( 1 , str . Length ) ) ;
744748 }
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ public void Can_ToCamelCase_String()
237237 Assert . That ( "lllUlllUlll" . ToCamelCase ( ) , Is . EqualTo ( "lllUlllUlll" ) ) ;
238238 Assert . That ( "" . ToCamelCase ( ) , Is . EqualTo ( "" ) ) ;
239239 Assert . That ( ( ( string ) null ) . ToCamelCase ( ) , Is . EqualTo ( ( string ) null ) ) ;
240+ Assert . That ( "__type" . ToCamelCase ( ) , Is . EqualTo ( "__type" ) ) ;
240241 }
241242
242243 [ Test ]
@@ -343,6 +344,7 @@ public void Can_convert_ToPascalCase()
343344 Assert . That ( "aa_bb" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
344345 Assert . That ( "Aa_Bb" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
345346 Assert . That ( "AA_BB" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
347+ Assert . That ( "__type" . ToPascalCase ( ) , Is . EqualTo ( "Type" ) ) ;
346348 }
347349
348350 [ Test ]
You can’t perform that action at this time.
0 commit comments