Table of Contents

Class XunitSerializationInfo

Namespace
Xunit.Sdk

Represents serialization information for serializing a complex object. This is typically used by objects which implement IXunitSerializable.

public class XunitSerializationInfo : IXunitSerializationInfo
Inheritance
XunitSerializationInfo
Implements
Inherited Members
Extension Methods

Constructors

XunitSerializationInfo(SerializationHelper)

Initializes a new instance of the XunitSerializationInfo class for the purposes of serialization (starting empty).

public XunitSerializationInfo(SerializationHelper serializationHelper)

Parameters

serializationHelper SerializationHelper

The serialization helper

XunitSerializationInfo(SerializationHelper, string)

Initializes a new instance of the XunitSerializationInfo class for the purposes of deserialization.

public XunitSerializationInfo(SerializationHelper serializationHelper, string serializedValue)

Parameters

serializationHelper SerializationHelper

The serialization helper

serializedValue string

The serialized value to copy into the serialization info

XunitSerializationInfo(SerializationHelper, IXunitSerializable)

Initializes a new instance of the XunitSerializationInfo class for the purposes of serialization (starting populated by the given object).

public XunitSerializationInfo(SerializationHelper serializationHelper, IXunitSerializable @object)

Parameters

serializationHelper SerializationHelper

The serialization helper

object IXunitSerializable

The data to copy into the serialization info

Methods

AddValue(string, object?, Type?)

Adds a value to the serialization. Supported value types include the built-in intrinsics (string, int, long, float, double, and decimal, including nullable versions of those), any class which implements IXunitSerializable), or arrays of any supported types.

public void AddValue(string key, object? value, Type? valueType = null)

Parameters

key string

The key to store the value with

value object

The value to be stored

valueType Type

The type of the value to be stored; optional, unless the value of value is null.

Exceptions

ArgumentException

Thrown if the value is not a supported type.

GetValue(string)

Gets a value from the serialization.

public object? GetValue(string key)

Parameters

key string

The key of the value to retrieve

Returns

object

The value, if present; null, otherwise

ToSerializedString()

Returns a string that represents the entirety of the data.

public string ToSerializedString()

Returns

string