Table of Contents

Class JsonArraySerializer

Namespace
Xunit.Sdk

A special-purpose streaming serializer for arrays to JSON. Only supports a limited number of types (boolean, DateTimeOffset, decimal, Enum, int, long, string, and trait dictionaries).

public sealed class JsonArraySerializer : JsonSerializerBase, IDisposable
Inheritance
JsonArraySerializer
Implements
Inherited Members
Extension Methods

Remarks

These types are made public for third parties only for the purpose of serializing and deserializing messages that are sent across the process boundary (that is, types which implement IMessageSinkMessage). Any other usage is not supported.

Constructors

JsonArraySerializer(StringBuilder, Action?)

A special-purpose streaming serializer for arrays to JSON. Only supports a limited number of types (boolean, DateTimeOffset, decimal, Enum, int, long, string, and trait dictionaries).

public JsonArraySerializer(StringBuilder buffer, Action? disposeNotifier = null)

Parameters

buffer StringBuilder

The buffer to write JSON to

disposeNotifier Action

An optional callback to be notified when disposed

Remarks

These types are made public for third parties only for the purpose of serializing and deserializing messages that are sent across the process boundary (that is, types which implement IMessageSinkMessage). Any other usage is not supported.

Methods

Serialize(IReadOnlyDictionary<string, IReadOnlyCollection<string>>)

Serialize a trait dictionary value into the array.

public void Serialize(IReadOnlyDictionary<string, IReadOnlyCollection<string>> dictionary)

Parameters

dictionary IReadOnlyDictionary<string, IReadOnlyCollection<string>>

Serialize(Enum?)

Serialize an Enum value into the array.

public void Serialize(Enum? value)

Parameters

value Enum

Serialize(bool?)

Serialize a bool value into the array.

public void Serialize(bool? value)

Parameters

value bool?

Serialize(DateTimeOffset?)

Serialize a DateTimeOffset value into the array.

public void Serialize(DateTimeOffset? value)

Parameters

value DateTimeOffset?

Serialize(decimal?)

Serialize a decimal value into the array.

public void Serialize(decimal? value)

Parameters

value decimal?

Serialize(int?)

Serialize an int value into the array.

public void Serialize(int? value)

Parameters

value int?

Serialize(long?)

Serialize a long value into the array.

public void Serialize(long? value)

Parameters

value long?

Serialize(string?)

Serialize a string value into the array.

public void Serialize(string? value)

Parameters

value string

SerializeArray()

Start serializing an array into the array.

public JsonArraySerializer SerializeArray()

Returns

JsonArraySerializer

Remarks

IMPORTANT: This serializer must be used completely and disposed before any other value is serialized into the array, or the serialization will be corrupted.

SerializeObject()

Start serializing an object into the array.

public JsonObjectSerializer SerializeObject()

Returns

JsonObjectSerializer

Remarks

IMPORTANT: This serializer must be used completely and disposed before any other value is serialized into the array, or the serialization will be corrupted.