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 +11
-4
lines changed
tests/ServiceStack.Text.Tests Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -466,7 +466,11 @@ public static EmptyCtorDelegate GetConstructorMethod(string typeName)
466
466
467
467
public static EmptyCtorDelegate GetConstructorMethodToCache ( Type type )
468
468
{
469
- if ( type . IsInterface ( ) )
469
+ if ( type == typeof ( string ) )
470
+ {
471
+ return ( ) => String . Empty ;
472
+ }
473
+ else if ( type . IsInterface ( ) )
470
474
{
471
475
if ( type . HasGenericType ( ) )
472
476
{
@@ -550,9 +554,6 @@ public static EmptyCtorDelegate GetConstructorMethodToCache(Type type)
550
554
return System . Linq . Expressions . Expression . Lambda < EmptyCtorDelegate > (
551
555
System . Linq . Expressions . Expression . New ( type ) ) . Compile ( ) ;
552
556
#else
553
- if ( type == typeof ( string ) )
554
- return ( ) => String . Empty ;
555
-
556
557
//Anonymous types don't have empty constructors
557
558
return ( ) => FormatterServices . GetUninitializedObject ( type ) ;
558
559
#endif
Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ public void Only_serializes_public_readable_properties()
53
53
Serialize ( model ) ;
54
54
}
55
55
56
+ [ Test ]
57
+ public void Can_create_instance_of_string ( )
58
+ {
59
+ Assert . That ( typeof ( string ) . CreateInstance ( ) , Is . EqualTo ( String . Empty ) ) ;
60
+ }
61
+
56
62
[ Test ]
57
63
public void Can_create_instances_of_common_collections ( )
58
64
{
You can’t perform that action at this time.
0 commit comments