File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
fern/products/sdks/overview/csharp/changelog Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ ## 2.19.0
2+ ** ` (feat): ` ** Add support for type-safe undiscriminated unions with the new ` use-undiscriminated-unions ` configuration option.
3+
4+ Undiscriminated unions provide a clean, type-safe way to work with values that can be one of several types:
5+
6+ ``` csharp
7+ // Creating union values
8+ var response = MyUnion .FromString (" hello" );
9+ var response = MyUnion .FromInt (42 );
10+ var response = MyUnion .FromCustomObject (new CustomObject { .. . });
11+
12+ // Type-safe value access with Is* properties and As* methods
13+ if (response .IsString )
14+ {
15+ string value = response .AsString ();
16+ Console .WriteLine ($" Got string: {value }" );
17+ }
18+ else if (response .IsInt )
19+ {
20+ int value = response .AsInt ();
21+ Console .WriteLine ($" Got integer: {value }" );
22+ }
23+
24+ // Safe extraction with TryAs* pattern (no exceptions)
25+ if (response .TryAsCustomObject (out var obj ))
26+ {
27+ Console .WriteLine ($" Got object: {obj .Name }" );
28+ }
29+ ```
30+
31+ This provides better IntelliSense support and compile-time safety compared to working with generic ` object ` types.
32+
33+
34+ ** ` (chore): ` ** Reduce NuGet package dependencies. The OneOf library is no longer required when undiscriminated unions are not used,
35+ resulting in smaller package sizes and fewer transitive dependencies.
36+
37+
138## 2.18.1
239** ` (fix): ` ** While most ` < ` s and ` > ` s should be escaped to ` < ` and ` > ` to avoid mangling the output,
340genuine XML/HTML tags should be kept as-is; this commit scans for potential valid tags and
You can’t perform that action at this time.
0 commit comments