Table of Contents

Class MessageSinkMessage

Namespace
Xunit.v3
Assembly
xunit.v3.core.dll

Default implementation of IMessageSinkMessage, with serialization support.

public abstract class MessageSinkMessage : IMessageSinkMessage, IJsonSerializable
Inheritance
MessageSinkMessage
Implements
Derived
Inherited Members

Remarks

Because of serialization, all concrete message sink message types must be decorated with JsonTypeIDAttribute to set a unique type ID for serialization purposes.

Constructors

MessageSinkMessage()

Initializes a new instance of the see MessageSinkMessage class.

protected MessageSinkMessage()

Methods

Serialize(JsonObjectSerializer)

Override to serialize the values in the message into JSON.

protected abstract void Serialize(JsonObjectSerializer serializer)

Parameters

serializer JsonObjectSerializer

The serializer to write values to.

ToDisplayString(string?[]?)

Converts a string array into a display value, for use in an ToString() overload.

protected static string ToDisplayString(string?[]? array)

Parameters

array string[]

Returns

string

ToDisplayString<T>(T[]?)

Converts am array into a display value, for use in an ToString() overload.

protected static string ToDisplayString<T>(T[]? array)

Parameters

array T[]

Returns

string

Type Parameters

T

ToJson()

Creates a JSON serialized version of this message.

public string ToJson()

Returns

string

Exceptions

InvalidOperationException

Thrown if the message class does not have a JsonTypeIDAttribute.

UnsetPropertiesException

Thrown when one or more properties are missing values.

ValidateObjectState()

Validates the state of the message object. This should be called just before serializing the message or just after deserializing the message to ensure that the message is not missing any required property values.

public void ValidateObjectState()

Exceptions

UnsetPropertiesException

Throw when one or more properties are missing values.

ValidateObjectState(HashSet<string>)

Called before serializing the message. Implementers are expected to call ValidatePropertyIsNotNull(object?, string, HashSet<string>) for each property that must have a value, to record invalid property values into the provided hash set.

protected abstract void ValidateObjectState(HashSet<string> invalidProperties)

Parameters

invalidProperties HashSet<string>

The hash set to record invalid properties into

ValidatePropertyIsNotNull(object?, string, HashSet<string>)

Validates that the property value is not null, and if it is, adds the given property name to the invalid property hash set.

protected static void ValidatePropertyIsNotNull(object? propertyValue, string propertyName, HashSet<string> invalidProperties)

Parameters

propertyValue object

The property value

propertyName string

The property name

invalidProperties HashSet<string>

The hash set to contain the invalid property name list