JsonSerializerOptions.MakeReadOnly Method

Definition

Overloads

MakeReadOnly()

Marks the current instance as read-only to prevent any further user modification.

MakeReadOnly(Boolean)

Marks the current instance as read-only preventing any further user modification.

MakeReadOnly()

Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs

Marks the current instance as read-only to prevent any further user modification.

C#
public void MakeReadOnly();

Exceptions

The instance does not specify a TypeInfoResolver setting.

Remarks

This method is idempotent.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

MakeReadOnly(Boolean)

Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs
Source:
JsonSerializerOptions.cs

Marks the current instance as read-only preventing any further user modification.

C#
public void MakeReadOnly(bool populateMissingResolver);

Parameters

populateMissingResolver
Boolean

Populates unconfigured TypeInfoResolver properties with the reflection-based default.

Exceptions

The instance does not specify a TypeInfoResolver setting. Thrown when populateMissingResolver is false.

-or-

The IsReflectionEnabledByDefault feature switch has been turned off.

Remarks

When populateMissingResolver is set to true, configures the instance following the semantics of the JsonSerializer methods accepting JsonSerializerOptions parameters.

This method is idempotent.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)