From 58a35d3e292149ac4d4b043e65bf5c0eb7bdc543 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Mon, 12 Feb 2024 13:54:49 +0100 Subject: [PATCH] Proper null handling. --- YDotNet/Document/Transactions/Transaction.cs | 6 ++++++ YDotNet/Native/Types/Branches/BranchKind.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/YDotNet/Document/Transactions/Transaction.cs b/YDotNet/Document/Transactions/Transaction.cs index f5f4e6fe..5dbaf53c 100644 --- a/YDotNet/Document/Transactions/Transaction.cs +++ b/YDotNet/Document/Transactions/Transaction.cs @@ -373,6 +373,12 @@ private nint GetWithKind(string name, BranchKind expectedKind) } var branchKind = (BranchKind)BranchChannel.Kind(branchHandle); + + if (branchKind == BranchKind.Null) + { + return nint.Zero; + } + if (branchKind != expectedKind) { throw new YDotNetException($"Expected '{expectedKind}', got '{branchKind}'."); diff --git a/YDotNet/Native/Types/Branches/BranchKind.cs b/YDotNet/Native/Types/Branches/BranchKind.cs index 8fb10afd..b5ea401f 100644 --- a/YDotNet/Native/Types/Branches/BranchKind.cs +++ b/YDotNet/Native/Types/Branches/BranchKind.cs @@ -2,6 +2,7 @@ namespace YDotNet.Native.Types.Branches; internal enum BranchKind { + Null = 0, Array = 1, Map = 2, Text = 3,