File tree 2 files changed +14
-1
lines changed
src/JsonApiDotNetCore/Models
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ public string StringId
37
37
/// </summary>
38
38
protected virtual string GetStringId ( object value )
39
39
{
40
+ if ( value == null )
41
+ return string . Empty ;
42
+
40
43
var type = typeof ( T ) ;
41
44
var stringValue = value . ToString ( ) ;
42
45
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ public void Setting_StringId_To_Null_Sets_Id_As_Default()
21
21
Assert . Equal ( 0 , resource . Id ) ;
22
22
}
23
23
24
- private class IntId : Identifiable { }
24
+ [ Fact ]
25
+ public void GetStringId_Returns_EmptyString_If_Object_Is_Null ( )
26
+ {
27
+ var resource = new IntId ( ) ;
28
+ var stringId = resource . ExposedGetStringId ( null ) ;
29
+ Assert . Equal ( string . Empty , stringId ) ;
30
+ }
31
+
32
+ private class IntId : Identifiable {
33
+ public string ExposedGetStringId ( object value ) => GetStringId ( value ) ;
34
+ }
25
35
}
26
36
}
You can’t perform that action at this time.
0 commit comments