Skip to content

Commit 0a08a75

Browse files
committed
Fix issue with incorrect serialization type
When passing `this`, it resolves to type `Thing` generically and the serializer then only looks for properties on `Thing`. To work around this, we get the runtime type via `GetType()` and pass that in.
1 parent dae8562 commit 0a08a75

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Source/Schema.NET/Thing.Partial.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static Thing()
6969
/// A <see cref="string" /> that represents the JSON-LD representation of this instance.
7070
/// </returns>
7171
public string ToString(JsonSerializerOptions serializerSettings) =>
72-
RemoveAllButRootContext(JsonSerializer.Serialize(this, serializerSettings));
72+
RemoveAllButRootContext(JsonSerializer.Serialize(this, this.GetType(), serializerSettings));
7373

7474
private static string RemoveAllButRootContext(string json)
7575
{

0 commit comments

Comments
 (0)