From e80e52c3036fc76b3e2cd8d5be37096e2198d951 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 17 Feb 2020 15:27:35 +0100 Subject: [PATCH] TryGetValue doesn't allow null as the value. --- .../Generators/TreeContainerIndex.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs index 0da84008f6..ca417e0d45 100644 --- a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs +++ b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs @@ -97,9 +97,13 @@ namespace Avalonia.Controls.Generators /// The container, or null of not found. public IControl ContainerFromItem(object item) { - IControl result; - _itemToContainer.TryGetValue(item, out result); - return result; + if (item != null) + { + _itemToContainer.TryGetValue(item, out var result); + return result; + } + + return null; } /// @@ -109,9 +113,13 @@ namespace Avalonia.Controls.Generators /// The item, or null of not found. public object ItemFromContainer(IControl container) { - object result; - _containerToItem.TryGetValue(container, out result); - return result; + if (container != null) + { + _containerToItem.TryGetValue(container, out var result); + return result; + } + + return null; } } }