Skip to navigation

2.19.0

(feat): Add support for type-safe undiscriminated unions with the new use-undiscriminated-unions configuration option.

Undiscriminated unions provide a clean, type-safe way to work with values that can be one of several types:

// Creating union values
var response = MyUnion.FromString("hello");
var response = MyUnion.FromInt(42);
var response = MyUnion.FromCustomObject(new CustomObject { ... });
// Type-safe value access with Is* properties and As* methods
if (response.IsString)
{
string value = response.AsString();
Console.WriteLine($"Got string: {value}");
}
else if (response.IsInt)
{
int value = response.AsInt();
Console.WriteLine($"Got integer: {value}");
}
// Safe extraction with TryAs* pattern (no exceptions)
if (response.TryAsCustomObject(out var obj))
{
Console.WriteLine($"Got object: {obj.Name}");
}

This provides better IntelliSense support and compile-time safety compared to working with generic object types.

(chore): Reduce NuGet package dependencies. The OneOf library is no longer required when undiscriminated unions are not used, resulting in smaller package sizes and fewer transitive dependencies.

2.18.1

(fix): While most <s and >s should be escaped to &lt; and &gt; to avoid mangling the output, genuine XML/HTML tags should be kept as-is; this commit scans for potential valid tags and prevents their being escaped. (Ambiguous cases are escaped.)

Before:

/// XMLDoc (C#) (Example of actual XML tags):
/// See &lt;a href="https://example.com/docs"&gt;the docs&lt;/a&gt; for more info.
/// Use &lt;code&gt;getValue()&lt;/code&gt; to retrieve the value.
/// Note: when count &lt; 10 or count &gt; 100, special handling applies.

After:

/// XMLDoc (C#) (Example of actual XML tags):
/// See <a href="https://example.com/docs">the docs</a> for more info.
/// Use <code>getValue()</code> to retrieve the value.
/// Note: when count &lt; 10 or count &gt; 100, special handling applies.