Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add JsonDocument type to source generation
  • Loading branch information
strobelt authored and eiriktsarpalis committed Apr 20, 2022
commit 8f09f7c7987a923f711ce61c2bf9a41bcacc6cb5
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private sealed class Parser
private const string JsonNodeFullName = "System.Text.Json.Nodes.JsonNode";
private const string JsonObjectFullName = "System.Text.Json.Nodes.JsonObject";
private const string JsonValueFullName = "System.Text.Json.Nodes.JsonValue";
private const string JsonDocumentFullName = "System.Text.Json.JsonDocument";
private const string JsonIgnoreAttributeFullName = "System.Text.Json.Serialization.JsonIgnoreAttribute";
private const string JsonIgnoreConditionFullName = "System.Text.Json.Serialization.JsonIgnoreCondition";
private const string JsonIncludeAttributeFullName = "System.Text.Json.Serialization.JsonIncludeAttribute";
Expand Down Expand Up @@ -92,6 +93,7 @@ private sealed class Parser
private readonly Type? _jsonNodeType;
private readonly Type? _jsonObjectType;
private readonly Type? _jsonValueType;
private readonly Type? _jsonDocumentType;

// Unsupported types
private readonly Type _delegateType;
Expand Down Expand Up @@ -229,6 +231,7 @@ public Parser(Compilation compilation, in JsonSourceGenerationContext sourceGene
_jsonNodeType = _metadataLoadContext.Resolve(JsonNodeFullName);
_jsonObjectType = _metadataLoadContext.Resolve(JsonObjectFullName);
_jsonValueType = _metadataLoadContext.Resolve(JsonValueFullName);
_jsonDocumentType = _metadataLoadContext.Resolve(JsonDocumentFullName);

// Unsupported types.
_delegateType = _metadataLoadContext.Resolve(SpecialType.System_Delegate);
Expand Down Expand Up @@ -1556,6 +1559,7 @@ private void PopulateKnownTypes()
AddTypeIfNotNull(_knownTypes, _jsonNodeType);
AddTypeIfNotNull(_knownTypes, _jsonObjectType);
AddTypeIfNotNull(_knownTypes, _jsonValueType);
AddTypeIfNotNull(_knownTypes, _jsonDocumentType);

_knownUnsupportedTypes.Add(_typeType);
_knownUnsupportedTypes.Add(_serializationInfoType);
Expand Down