diff --git a/src/libraries/System.Text.Json/src/Resources/Strings.resx b/src/libraries/System.Text.Json/src/Resources/Strings.resx
index 9348208f6d8be..ef169c7a87510 100644
--- a/src/libraries/System.Text.Json/src/Resources/Strings.resx
+++ b/src/libraries/System.Text.Json/src/Resources/Strings.resx
@@ -645,7 +645,7 @@
Runtime type '{0}' has a diamond ambiguity between derived types '{1}' and '{2}' of polymorphic type '{3}'. Consider either removing one of the derived types or removing the 'JsonUnknownDerivedTypeHandling.FallBackToNearestAncestor' setting.
- Invalid JsonTypeInfo operation for metadata kind '{0}'.
+ Invalid JsonTypeInfo operation for JsonTypeInfoKind '{0}'.One of the provided resolvers is null.
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
index f372d8bd8336e..d28e826b8b3c3 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Caching.cs
@@ -28,6 +28,8 @@ public sealed partial class JsonSerializerOptions
///
/// The type to resolve contract metadata for.
/// The contract metadata resolved for .
+ /// is .
+ /// is not valid for serialization.
///
/// Returned metadata can be downcast to and used with the relevant overloads.
///
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs
index 1a45a87807437..63ce1d606fe8f 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs
@@ -175,12 +175,14 @@ public JsonSerializerOptions(JsonSerializerDefaults defaults) : this()
}
///
- /// Gets or sets a contract resolver.
+ /// Gets or sets the contract resolver used by this instance.
///
+ ///
+ /// Thrown if this property is set after serialization or deserialization has occurred.
+ ///
///
- /// When used with the reflection-based APIs,
- /// a setting be equivalent to and replaced by the reflection-based
- /// .
+ /// A setting is equivalent to using the reflection-based .
+ /// The property will be populated automatically once used with one of the methods.
///
public IJsonTypeInfoResolver? TypeInfoResolver
{
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.cs
index 01cd5430ee97e..e07908901f07f 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/DefaultJsonTypeInfoResolver.cs
@@ -10,14 +10,17 @@
namespace System.Text.Json.Serialization.Metadata
{
///
- /// Default JsonTypeInfo resolver.
+ /// Defines the default, reflection-based JSON contract resolver used by System.Text.Json.
///
+ ///
+ /// The contract resolver used by .
+ ///
public partial class DefaultJsonTypeInfoResolver : IJsonTypeInfoResolver
{
private bool _mutable;
///
- /// Constructs DefaultJsonTypeInfoResolver.
+ /// Creates a mutable instance.
///
[RequiresUnreferencedCode(JsonSerializer.SerializationUnreferencedCodeMessage)]
[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
@@ -35,7 +38,17 @@ private DefaultJsonTypeInfoResolver(bool mutable)
s_defaultSimpleConverters ??= GetDefaultSimpleConverters();
}
- ///
+ ///
+ /// Resolves a JSON contract for a given and configuration.
+ ///
+ /// The type for which to resolve a JSON contract.
+ /// A instance used to determine contract configuration.
+ /// A defining a reflection-derived JSON contract for .
+ /// or is .
+ ///
+ /// The base implementation of this method will produce a reflection-derived contract
+ /// and apply any callbacks from the list.
+ ///
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
Justification = "The ctor is marked RequiresUnreferencedCode.")]
[UnconditionalSuppressMessage("AotAnalysis", "IL3050:RequiresDynamicCode",
@@ -88,9 +101,13 @@ private static JsonTypeInfo CreateReflectionJsonTypeInfo(JsonSerializerOpt
private static MethodInfo? s_createReflectionJsonTypeInfoMethodInfo;
///
- /// List of JsonTypeInfo modifiers. Modifying callbacks are called consecutively after initial resolution
- /// and cannot be changed after GetTypeInfo is called.
+ /// Gets a list of user-defined callbacks that can be used to modify the initial contract.
///
+ ///
+ /// The modifier list will be rendered immutable after the first invocation.
+ ///
+ /// Modifier callbacks are called consecutively in the order in which they are specified in the list.
+ ///
public IList> Modifiers => _modifiers ??= new ModifierCollection(this);
private ModifierCollection? _modifiers;
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/IJsonTypeInfoResolver.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/IJsonTypeInfoResolver.cs
index 22f74387153d4..4acabe53d731f 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/IJsonTypeInfoResolver.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/IJsonTypeInfoResolver.cs
@@ -1,24 +1,22 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
namespace System.Text.Json.Serialization.Metadata
{
///
- /// Exposes method for resolving Type into JsonTypeInfo for given options.
+ /// Used to resolve the JSON serialization contract for requested types.
///
public interface IJsonTypeInfoResolver
{
///
- /// Resolves Type into JsonTypeInfo which defines serialization and deserialization logic.
+ /// Resolves a contract for the requested type and options.
///
/// Type to be resolved.
- /// JsonSerializerOptions instance defining resolution parameters.
- /// Returns JsonTypeInfo instance or null if the resolver cannot produce metadata for this type.
+ /// Configuration used when resolving the metadata.
+ ///
+ /// A instance matching the requested type,
+ /// or if no contract could be resolved.
+ ///
JsonTypeInfo? GetTypeInfo(Type type, JsonSerializerOptions options);
}
}
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPolymorphismOptions.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPolymorphismOptions.cs
index f550e910b2708..d9d518b25273a 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPolymorphismOptions.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPolymorphismOptions.cs
@@ -27,6 +27,9 @@ public class JsonPolymorphismOptions
/// unrecognized type discriminator id's and reverts to the contract of the base type.
/// Otherwise, it will fail the deserialization.
///
+ ///
+ /// The parent instance has been locked for further modification.
+ ///
public bool IgnoreUnrecognizedTypeDiscriminators
{
get => _ignoreUnrecognizedTypeDiscriminators;
@@ -40,6 +43,9 @@ public bool IgnoreUnrecognizedTypeDiscriminators
///
/// Gets or sets the behavior when serializing an undeclared derived runtime type.
///
+ ///
+ /// The parent instance has been locked for further modification.
+ ///
public JsonUnknownDerivedTypeHandling UnknownDerivedTypeHandling
{
get => _unknownDerivedTypeHandling;
@@ -54,6 +60,9 @@ public JsonUnknownDerivedTypeHandling UnknownDerivedTypeHandling
/// Gets or sets a custom type discriminator property name for the polymorhic type.
/// Uses the default '$type' property name if left unset.
///
+ ///
+ /// The parent instance has been locked for further modification.
+ ///
[AllowNull]
public string TypeDiscriminatorPropertyName
{
diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
index 1418afb476a22..bf0503ed518b6 100644
--- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
+++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
@@ -10,7 +10,7 @@
namespace System.Text.Json.Serialization.Metadata
{
///
- /// Provides JSON serialization-related metadata about a property or field.
+ /// Provides JSON serialization-related metadata about a property or field defined in an object.
///
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public abstract class JsonPropertyInfo
@@ -28,8 +28,17 @@ public abstract class JsonPropertyInfo
internal abstract JsonConverter EffectiveConverter { get; }
///
- /// Custom converter override at the property level, equivalent to annotation.
+ /// Gets or sets a custom converter override for the current property.
///
+ ///
+ /// The instance has been locked for further modification.
+ ///
+ ///
+ /// It is possible to use instances with this property.
+ ///
+ /// For contracts originating from , the value of
+ /// will be mapped from annotations.
+ ///
public JsonConverter? CustomConverter
{
get => _customConverter;
@@ -45,6 +54,9 @@ public JsonConverter? CustomConverter
///
/// Gets or sets a getter delegate for the property.
///
+ ///
+ /// The instance has been locked for further modification.
+ ///
///
/// Setting to will result in the property being skipped on serialization.
///
@@ -61,6 +73,9 @@ public JsonConverter? CustomConverter
///
/// Gets or sets a setter delegate for the property.
///
+ ///
+ /// The instance has been locked for further modification.
+ ///
///
/// Setting to will result in the property being skipped on deserialization.
///
@@ -85,13 +100,16 @@ public JsonConverter? CustomConverter
///
/// Gets or sets a predicate deciding whether the current property value should be serialized.
///
+ ///
+ /// The instance has been locked for further modification.
+ ///
///
/// The first parameter denotes the parent object, the second parameter denotes the property value.
///
/// Setting the predicate to is equivalent to always serializing the property value.
///
- /// When serializing using , the value of
- /// will map to this predicate.
+ /// For contracts originating from ,
+ /// the value of will map to this predicate.
///
public Func