Table of Contents

UnmappedMemberHandlingAttribute Class

Definition

Namespace
Bodu.Text.Serialization
Assembly
Bodu.Text.Serialization.dll
Package
Bodu.Text.Serialization 1.0.0
Source
UnmappedMemberHandlingAttribute.cs

Specifies, for the annotated type, how the serializer treats a dictionary key that maps to no member during deserialization, overriding the serializer-wide unmapped-member handling.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface, AllowMultiple = false, Inherited = false)]
public sealed class UnmappedMemberHandlingAttribute : SerializationAttribute
Inheritance
UnmappedMemberHandlingAttribute
Attributes
System.AttributeUsageAttribute
Inherited Members
Extension Methods

Examples

[UnmappedMemberHandling(UnmappedMemberHandling.Disallow)]
public sealed class StrictConfig
{
    public int Port { get; set; }
}

// Input containing a key that maps to no member throws a serialization exception.

Remarks

When a type carries this attribute, its configured handling is used in place of the options-level default for that type. A type with an extension-data member still captures unmapped keys into that member regardless of this setting.

Constructors

UnmappedMemberHandlingAttribute(UnmappedMemberHandling)

Initializes a new instance of the UnmappedMemberHandlingAttribute class.

public UnmappedMemberHandlingAttribute(UnmappedMemberHandling unmappedMemberHandling)

Parameters

unmappedMemberHandling UnmappedMemberHandling

The handling applied to unmapped keys for the annotated type.

Exceptions

ArgumentOutOfRangeException

Thrown when unmappedMemberHandling is not a defined UnmappedMemberHandling value.

Properties

UnmappedMemberHandling

Gets the handling applied to unmapped keys for the annotated type.

public UnmappedMemberHandling UnmappedMemberHandling { get; }

Property Value

UnmappedMemberHandling

The unmapped-member handling.

Applies to

ProductVersions
.NET8, 10