Skip to content

Commit 1093d93

Browse files
committed
Use JsonSerializer context for source generation; compatible with AOT
1 parent a5e9058 commit 1093d93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Microsoft.OpenApi/Reader/ParseNodes/MapNode.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq;
99
using System.Text.Json;
1010
using System.Text.Json.Nodes;
11+
using System.Text.Json.Serialization;
1112
using Microsoft.OpenApi.Any;
1213
using Microsoft.OpenApi.Exceptions;
1314
using Microsoft.OpenApi.Interfaces;
@@ -114,7 +115,7 @@ IEnumerator IEnumerable.GetEnumerator()
114115

115116
public override string GetRaw()
116117
{
117-
var x = JsonSerializer.Serialize(_node);
118+
var x = JsonSerializer.Serialize(_node, SourceGenerationContext.Default.JsonObject);
118119
return x;
119120
}
120121

@@ -176,4 +177,7 @@ public override JsonNode CreateAny()
176177
return _node;
177178
}
178179
}
180+
181+
[JsonSerializable(typeof(JsonObject))]
182+
internal partial class SourceGenerationContext : JsonSerializerContext { }
179183
}

0 commit comments

Comments
 (0)