@@ -25,9 +25,12 @@ private sealed class Parser
2525 private const string SystemTextJsonNamespace = "System.Text.Json" ;
2626 private const string JsonConverterAttributeFullName = "System.Text.Json.Serialization.JsonConverterAttribute" ;
2727 private const string JsonConverterFactoryFullName = "System.Text.Json.Serialization.JsonConverterFactory" ;
28+ private const string JsonArrayFullName = "System.Text.Json.Nodes.JsonArray" ;
2829 private const string JsonElementFullName = "System.Text.Json.JsonElement" ;
2930 private const string JsonExtensionDataAttributeFullName = "System.Text.Json.Serialization.JsonExtensionDataAttribute" ;
31+ private const string JsonNodeFullName = "System.Text.Json.Nodes.JsonNode" ;
3032 private const string JsonObjectFullName = "System.Text.Json.Nodes.JsonObject" ;
33+ private const string JsonValueFullName = "System.Text.Json.Nodes.JsonValue" ;
3134 private const string JsonIgnoreAttributeFullName = "System.Text.Json.Serialization.JsonIgnoreAttribute" ;
3235 private const string JsonIgnoreConditionFullName = "System.Text.Json.Serialization.JsonIgnoreCondition" ;
3336 private const string JsonIncludeAttributeFullName = "System.Text.Json.Serialization.JsonIncludeAttribute" ;
@@ -80,8 +83,11 @@ private sealed class Parser
8083 private readonly Type ? _guidType ;
8184 private readonly Type ? _uriType ;
8285 private readonly Type ? _versionType ;
86+ private readonly Type ? _jsonArrayType ;
8387 private readonly Type ? _jsonElementType ;
88+ private readonly Type ? _jsonNodeType ;
8489 private readonly Type ? _jsonObjectType ;
90+ private readonly Type ? _jsonValueType ;
8591
8692 // Unsupported types
8793 private readonly Type _typeType ;
@@ -193,8 +199,11 @@ public Parser(Compilation compilation, in JsonSourceGenerationContext sourceGene
193199 _guidType = _metadataLoadContext . Resolve ( typeof ( Guid ) ) ;
194200 _uriType = _metadataLoadContext . Resolve ( typeof ( Uri ) ) ;
195201 _versionType = _metadataLoadContext . Resolve ( typeof ( Version ) ) ;
202+ _jsonArrayType = _metadataLoadContext . Resolve ( JsonArrayFullName ) ;
196203 _jsonElementType = _metadataLoadContext . Resolve ( JsonElementFullName ) ;
204+ _jsonNodeType = _metadataLoadContext . Resolve ( JsonNodeFullName ) ;
197205 _jsonObjectType = _metadataLoadContext . Resolve ( JsonObjectFullName ) ;
206+ _jsonValueType = _metadataLoadContext . Resolve ( JsonValueFullName ) ;
198207
199208 // Unsupported types.
200209 _typeType = _metadataLoadContext . Resolve ( typeof ( Type ) ) ;
@@ -565,14 +574,6 @@ private static bool TryGetClassDeclarationList(INamedTypeSymbol typeSymbol, [Not
565574 }
566575 }
567576 break ;
568- case nameof ( JsonSourceGenerationOptionsAttribute . IgnoreRuntimeCustomConverters ) :
569- {
570- if ( bool . TryParse ( propertyValueStr , out bool value ) )
571- {
572- options . IgnoreRuntimeCustomConverters = value ;
573- }
574- }
575- break ;
576577 case nameof ( JsonSourceGenerationOptionsAttribute . IncludeFields ) :
577578 {
578579 if ( bool . TryParse ( propertyValueStr , out bool value ) )
@@ -640,7 +641,7 @@ private TypeGenerationSpec GetOrAddTypeGenerationSpec(Type type, JsonSourceGener
640641 string ? converterInstatiationLogic = null ;
641642 bool implementsIJsonOnSerialized = false ;
642643 bool implementsIJsonOnSerializing = false ;
643- bool hasEncounteredInitOnlyProperties = false ;
644+ bool hasInitOnlyProperties = false ;
644645 bool hasTypeFactoryConverter = false ;
645646 bool hasPropertyFactoryConverters = false ;
646647
@@ -972,10 +973,10 @@ void CacheMemberHelper()
972973 _implicitlyRegisteredTypes . Add ( dataExtensionPropGenSpec ) ;
973974 }
974975
975- if ( ! hasEncounteredInitOnlyProperties && spec . CanUseSetter && spec . IsInitOnlySetter )
976+ if ( ! hasInitOnlyProperties && spec . CanUseSetter && spec . IsInitOnlySetter )
976977 {
977978 _sourceGenerationContext . ReportDiagnostic ( Diagnostic . Create ( InitOnlyPropertyDeserializationNotSupported , Location . None , new string [ ] { type . Name } ) ) ;
978- hasEncounteredInitOnlyProperties = true ;
979+ hasInitOnlyProperties = true ;
979980 }
980981
981982 if ( spec . HasJsonInclude && ( ! spec . CanUseGetter || ! spec . CanUseSetter || ! spec . IsPublic ) )
@@ -1454,8 +1455,11 @@ private void PopulateKnownTypes()
14541455 AddTypeIfNotNull ( _knownTypes , _guidType ) ;
14551456 AddTypeIfNotNull ( _knownTypes , _uriType ) ;
14561457 AddTypeIfNotNull ( _knownTypes , _versionType ) ;
1458+ AddTypeIfNotNull ( _knownTypes , _jsonArrayType ) ;
14571459 AddTypeIfNotNull ( _knownTypes , _jsonElementType ) ;
1460+ AddTypeIfNotNull ( _knownTypes , _jsonNodeType ) ;
14581461 AddTypeIfNotNull ( _knownTypes , _jsonObjectType ) ;
1462+ AddTypeIfNotNull ( _knownTypes , _jsonValueType ) ;
14591463
14601464 _knownUnsupportedTypes . Add ( _typeType ) ;
14611465 _knownUnsupportedTypes . Add ( _serializationInfoType ) ;
0 commit comments