Table of Contents

Method IsSerializable

Namespace
Xunit.Sdk
Assembly
xunit.v3.common.dll

IsSerializable(Type, object?, out string?)

Determines if a specific value of data is serializable.

bool IsSerializable(Type type, object? value, out string? failureReason)

Parameters

type Type

The type of the value

value object

The value to test

failureReason string

Returns a failure reason when the value isn't serializable

Returns

bool

Return true if the value is serializable; false, otherwise

Remarks

This will be called by IsSerializable(object?), IsSerializable(object?, Type?), and Serialize(object?, Type?). The failure reason is used when called from Serialize to format an error exception, but is otherwise ignored from the calls from IsSerializable.

The type of value may not directly match type, as the type is derived from unwrapping nullability and array element types, so use care when looking at the value to determine serializability.