From 0f8656e8867919e0e156f3180365b523eda521c6 Mon Sep 17 00:00:00 2001 From: Domn Werner Date: Sat, 27 Aug 2022 09:50:03 -0700 Subject: [PATCH] Release v1.2.0 --- Readme.md | 25 +++++++++++++++++++++++++ src/Dunet.csproj | 9 +++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 8c563b9..2b0d61d 100644 --- a/Readme.md +++ b/Readme.md @@ -117,6 +117,31 @@ var output = result.Match( Console.WriteLine(output); // "Cannot divide by zero!" ``` +## Nested Union Suppoort + +To declare a union nested within a class or record, the class or record must be `partial`. For example: + +```cs +// This type declaration must be partial. +public partial class Parent1 +{ + // So must this one. + public partial class Parent2 + { + // Unions must always be partial. + [Union] + public partial record Nested + { + public partial record Member1; + public partial record Member2; + } + } +} + +// Access union members like any other nested type. +var member1 = new Parent1.Parent2.Nested.Member1(); +``` + ## Samples - [Area Calculator](./samples/AreaCalculator/Program.cs) diff --git a/src/Dunet.csproj b/src/Dunet.csproj index 1353fac..d040f69 100644 --- a/src/Dunet.csproj +++ b/src/Dunet.csproj @@ -14,10 +14,11 @@ Readme.md https://github.com/domn1995/dunet source; generator; discriminated; union; functional; tagged; - 1.1.0 - 1.1.0 + 1.2.0 + 1.2.0 MIT - 1.1.0 - Add implicit conversions for union members. + 1.2.0 - Support nested union declarations. +1.1.0 - Add implicit conversions for union members. 1.0.2 - Support multiple unions with the same name. 1.0.1 - Configure Dunet as development dependency. 1.0.0 - Production release. @@ -35,7 +36,7 @@ git favicon.png False - 1.1.0 + 1.2.0 en true $(NoWarn);NU5128