Skip to content

Commit 8f09f7c

Browse files
strobelteiriktsarpalis
authored andcommitted
Add JsonDocument type to source generation
1 parent 13975b4 commit 8f09f7c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ private sealed class Parser
3434
private const string JsonNodeFullName = "System.Text.Json.Nodes.JsonNode";
3535
private const string JsonObjectFullName = "System.Text.Json.Nodes.JsonObject";
3636
private const string JsonValueFullName = "System.Text.Json.Nodes.JsonValue";
37+
private const string JsonDocumentFullName = "System.Text.Json.JsonDocument";
3738
private const string JsonIgnoreAttributeFullName = "System.Text.Json.Serialization.JsonIgnoreAttribute";
3839
private const string JsonIgnoreConditionFullName = "System.Text.Json.Serialization.JsonIgnoreCondition";
3940
private const string JsonIncludeAttributeFullName = "System.Text.Json.Serialization.JsonIncludeAttribute";
@@ -92,6 +93,7 @@ private sealed class Parser
9293
private readonly Type? _jsonNodeType;
9394
private readonly Type? _jsonObjectType;
9495
private readonly Type? _jsonValueType;
96+
private readonly Type? _jsonDocumentType;
9597

9698
// Unsupported types
9799
private readonly Type _delegateType;
@@ -229,6 +231,7 @@ public Parser(Compilation compilation, in JsonSourceGenerationContext sourceGene
229231
_jsonNodeType = _metadataLoadContext.Resolve(JsonNodeFullName);
230232
_jsonObjectType = _metadataLoadContext.Resolve(JsonObjectFullName);
231233
_jsonValueType = _metadataLoadContext.Resolve(JsonValueFullName);
234+
_jsonDocumentType = _metadataLoadContext.Resolve(JsonDocumentFullName);
232235

233236
// Unsupported types.
234237
_delegateType = _metadataLoadContext.Resolve(SpecialType.System_Delegate);
@@ -1556,6 +1559,7 @@ private void PopulateKnownTypes()
15561559
AddTypeIfNotNull(_knownTypes, _jsonNodeType);
15571560
AddTypeIfNotNull(_knownTypes, _jsonObjectType);
15581561
AddTypeIfNotNull(_knownTypes, _jsonValueType);
1562+
AddTypeIfNotNull(_knownTypes, _jsonDocumentType);
15591563

15601564
_knownUnsupportedTypes.Add(_typeType);
15611565
_knownUnsupportedTypes.Add(_serializationInfoType);

0 commit comments

Comments
 (0)