From 7b0f5368a1ac67080d13cc5a86f0ddcfbed2f617 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 21 Jul 2022 12:56:30 +0200 Subject: [PATCH] Add null check. --- .../Utilities/AvaloniaPropertyDictionary.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs index 434c94b1e5..e5a6e5a825 100644 --- a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs +++ b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs @@ -82,7 +82,15 @@ namespace Avalonia.Utilities /// /// The index of the entry, between 0 and - 1. /// - public TValue this[int index] => _entries![index].Value; + public TValue this[int index] + { + get + { + if (_entries is null) + ThrowArgumentOutOfRange(); + return _entries[index].Value; + } + } /// /// Adds the specified key and value to the dictionary.