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)
705
705
private const int LowerCaseOffset = 'a' - 'A' ;
706
706
public static string ToCamelCase ( this string value )
707
707
{
708
- if ( String . IsNullOrEmpty ( value ) ) return value ;
708
+ if ( string . IsNullOrEmpty ( value ) )
709
+ return value ;
709
710
710
711
var len = value . Length ;
711
712
var newValue = new char [ len ] ;
@@ -731,14 +732,17 @@ public static string ToCamelCase(this string value)
731
732
732
733
public static string ToPascalCase ( this string value )
733
734
{
734
- if ( String . IsNullOrEmpty ( value ) ) return value ;
735
+ if ( string . IsNullOrEmpty ( value ) )
736
+ return value ;
735
737
736
738
if ( value . IndexOf ( '_' ) >= 0 )
737
739
{
738
740
var parts = value . Split ( '_' ) ;
739
741
var sb = StringBuilderThreadStatic . Allocate ( ) ;
740
742
foreach ( var part in parts )
741
743
{
744
+ if ( string . IsNullOrEmpty ( part ) )
745
+ continue ;
742
746
var str = part . ToCamelCase ( ) ;
743
747
sb . Append ( char . ToUpper ( str [ 0 ] ) + str . SafeSubstring ( 1 , str . Length ) ) ;
744
748
}
Original file line number Diff line number Diff line change @@ -237,6 +237,7 @@ public void Can_ToCamelCase_String()
237
237
Assert . That ( "lllUlllUlll" . ToCamelCase ( ) , Is . EqualTo ( "lllUlllUlll" ) ) ;
238
238
Assert . That ( "" . ToCamelCase ( ) , Is . EqualTo ( "" ) ) ;
239
239
Assert . That ( ( ( string ) null ) . ToCamelCase ( ) , Is . EqualTo ( ( string ) null ) ) ;
240
+ Assert . That ( "__type" . ToCamelCase ( ) , Is . EqualTo ( "__type" ) ) ;
240
241
}
241
242
242
243
[ Test ]
@@ -343,6 +344,7 @@ public void Can_convert_ToPascalCase()
343
344
Assert . That ( "aa_bb" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
344
345
Assert . That ( "Aa_Bb" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
345
346
Assert . That ( "AA_BB" . ToPascalCase ( ) , Is . EqualTo ( "AaBb" ) ) ;
347
+ Assert . That ( "__type" . ToPascalCase ( ) , Is . EqualTo ( "Type" ) ) ;
346
348
}
347
349
348
350
[ Test ]
You can’t perform that action at this time.
0 commit comments