HumanReadableSerializerScrubExtensions Class

Provides extension methods for scrubbing values during serialization with HumanReadableSerializerOptions.

public static class HumanReadableSerializerScrubExtensions

Methods

NameDescription
ScrubGuid(HumanReadableSerializerOptions)Scrubs GUID values by replacing them with deterministic values based on their order of appearance.
ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, string?>)Scrubs JSON values matching the specified JSONPath expression, returning a string value.
ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, JsonNode?>)Scrubs JSON values matching the specified JSONPath expression, returning a JSON node.
ScrubValue<T>(HumanReadableSerializerOptions)Scrubs values of type T by replacing them with deterministic values like "TypeName_0", "TypeName_1", etc.
ScrubValue<T>(HumanReadableSerializerOptions, IEqualityComparer<T>?)Scrubs values of type T by replacing them with deterministic values, using the specified comparer to determine uniqueness.
ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>)Scrubs values of type T by replacing them with the result of the specified scrubber function that receives the value and its index.
ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>, IEqualityComparer<T>?)Scrubs values of type T by replacing them with the result of the specified scrubber function, using the specified comparer to determine uniqueness.
ScrubValue<T>(HumanReadableSerializerOptions, Func<T, string>)Scrubs values of type T by replacing them with the result of the specified scrubber function.
ScrubXmlAttribute(HumanReadableSerializerOptions, string, Func<XAttribute, string?>)Scrubs XML attributes matching the specified XPath expression.
ScrubXmlAttribute(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XAttribute, string?>)Scrubs XML attributes matching the specified XPath expression with namespace resolution.
ScrubXmlNode(HumanReadableSerializerOptions, string, Action<XNode>)Scrubs XML nodes matching the specified XPath expression using an action.
ScrubXmlNode(HumanReadableSerializerOptions, string, Func<XNode, XNode?>)Scrubs XML nodes matching the specified XPath expression.
ScrubXmlNode(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XNode, XNode?>)Scrubs XML nodes matching the specified XPath expression with namespace resolution.
UseRelativeDateTime(HumanReadableSerializerOptions, DateTime)Serializes DateTime values relative to the specified origin.
UseRelativeDateTimeOffset(HumanReadableSerializerOptions, DateTimeOffset)Serializes DateTimeOffset values relative to the specified origin.
UseRelativeTimeSpan(HumanReadableSerializerOptions, TimeSpan)Serializes TimeSpan values relative to the specified origin.

ScrubGuid(HumanReadableSerializerOptions)

HumanReadableSerializerScrubExtensions.cs

Scrubs GUID values by replacing them with deterministic values based on their order of appearance.

public static void ScrubGuid(this HumanReadableSerializerOptions options)

ScrubJsonValue overloads

ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, string?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs JSON values matching the specified JSONPath expression, returning a string value.

public static void ScrubJsonValue(this HumanReadableSerializerOptions options, string jsonPath, Func<JsonNode, string?> scrubber)
Parameters
options HumanReadableSerializerOptions
jsonPath string
scrubber Func<JsonNode, string?>
Remarks

A match whose value is JSON null is left unchanged, as there is no JsonNode to hand to the scrubber. When the expression matches the document root, the returned value becomes the whole document, and returning null reduces the document to JSON null.

ScrubJsonValue(HumanReadableSerializerOptions, string, Func<JsonNode, JsonNode?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs JSON values matching the specified JSONPath expression, returning a JSON node.

public static void ScrubJsonValue(this HumanReadableSerializerOptions options, string jsonPath, Func<JsonNode, JsonNode?> scrubber)
Parameters
options HumanReadableSerializerOptions
jsonPath string
scrubber Func<JsonNode, JsonNode?>
Remarks

A match whose value is JSON null is left unchanged, as there is no JsonNode to hand to the scrubber. When the expression matches the document root, the returned node becomes the whole document, and returning null reduces the document to JSON null.

ScrubValue overloads

ScrubValue<T>(HumanReadableSerializerOptions)

HumanReadableSerializerScrubExtensions.cs

Scrubs values of type T by replacing them with deterministic values like "TypeName_0", "TypeName_1", etc.

public static void ScrubValue<T>(this HumanReadableSerializerOptions options)
Type parameters
T
Parameters
options HumanReadableSerializerOptions

ScrubValue<T>(HumanReadableSerializerOptions, IEqualityComparer<T>?)

HumanReadableSerializerScrubExtensions.cs

Scrubs values of type T by replacing them with deterministic values, using the specified comparer to determine uniqueness.

public static void ScrubValue<T>(this HumanReadableSerializerOptions options, IEqualityComparer<T>? comparer)
Type parameters
T
Parameters
options HumanReadableSerializerOptions
comparer IEqualityComparer<T>?

ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>)

HumanReadableSerializerScrubExtensions.cs

Scrubs values of type T by replacing them with the result of the specified scrubber function that receives the value and its index.

public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, int, string> scrubber)
Type parameters
T
Parameters
options HumanReadableSerializerOptions
scrubber Func<T, int, string>

ScrubValue<T>(HumanReadableSerializerOptions, Func<T, int, string>, IEqualityComparer<T>?)

HumanReadableSerializerScrubExtensions.cs

Scrubs values of type T by replacing them with the result of the specified scrubber function, using the specified comparer to determine uniqueness.

public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, int, string> scrubber, IEqualityComparer<T>? comparer)
Type parameters
T
Parameters
options HumanReadableSerializerOptions
scrubber Func<T, int, string>
comparer IEqualityComparer<T>?

ScrubValue<T>(HumanReadableSerializerOptions, Func<T, string>)

HumanReadableSerializerScrubExtensions.cs

Scrubs values of type T by replacing them with the result of the specified scrubber function.

public static void ScrubValue<T>(this HumanReadableSerializerOptions options, Func<T, string> scrubber)
Type parameters
T
Parameters
options HumanReadableSerializerOptions
scrubber Func<T, string>

ScrubXmlAttribute overloads

ScrubXmlAttribute(HumanReadableSerializerOptions, string, Func<XAttribute, string?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs XML attributes matching the specified XPath expression.

public static void ScrubXmlAttribute(this HumanReadableSerializerOptions options, string xpath, Func<XAttribute, string?> scrubber)

ScrubXmlAttribute(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XAttribute, string?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs XML attributes matching the specified XPath expression with namespace resolution.

public static void ScrubXmlAttribute(this HumanReadableSerializerOptions options, string xpath, IXmlNamespaceResolver? nsResolver, Func<XAttribute, string?> scrubber)

ScrubXmlNode overloads

ScrubXmlNode(HumanReadableSerializerOptions, string, Action<XNode>)

HumanReadableSerializerScrubExtensions.cs

Scrubs XML nodes matching the specified XPath expression using an action.

public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, Action<XNode> scrubber)
Parameters
options HumanReadableSerializerOptions
xpath string
scrubber Action<XNode>

ScrubXmlNode(HumanReadableSerializerOptions, string, Func<XNode, XNode?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs XML nodes matching the specified XPath expression.

public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, Func<XNode, XNode?> scrubber)
Parameters
options HumanReadableSerializerOptions
xpath string
scrubber Func<XNode, XNode?>
Remarks

Returning the matched node replaces nothing, so a scrubber can mutate the node in place. Returning null removes the node; removing the document element leaves an empty document.

ScrubXmlNode(HumanReadableSerializerOptions, string, IXmlNamespaceResolver?, Func<XNode, XNode?>)

HumanReadableSerializerScrubExtensions.cs

Scrubs XML nodes matching the specified XPath expression with namespace resolution.

public static void ScrubXmlNode(this HumanReadableSerializerOptions options, string xpath, IXmlNamespaceResolver? nsResolver, Func<XNode, XNode?> scrubber)
Parameters
options HumanReadableSerializerOptions
xpath string
nsResolver IXmlNamespaceResolver?
scrubber Func<XNode, XNode?>
Remarks

Returning the matched node replaces nothing, so a scrubber can mutate the node in place. Returning null removes the node; removing the document element leaves an empty document.

UseRelativeDateTime(HumanReadableSerializerOptions, DateTime)

HumanReadableSerializerScrubExtensions.cs

Serializes DateTime values relative to the specified origin.

public static void UseRelativeDateTime(this HumanReadableSerializerOptions options, DateTime origin)

UseRelativeDateTimeOffset(HumanReadableSerializerOptions, DateTimeOffset)

HumanReadableSerializerScrubExtensions.cs

Serializes DateTimeOffset values relative to the specified origin.

public static void UseRelativeDateTimeOffset(this HumanReadableSerializerOptions options, DateTimeOffset origin)

UseRelativeTimeSpan(HumanReadableSerializerOptions, TimeSpan)

HumanReadableSerializerScrubExtensions.cs

Serializes TimeSpan values relative to the specified origin.

public static void UseRelativeTimeSpan(this HumanReadableSerializerOptions options, TimeSpan origin)