From 4bbd9a4aea6e2d7a655a26d6b15e74a2b6b18272 Mon Sep 17 00:00:00 2001 From: Edward Miller Date: Fri, 22 Mar 2024 23:36:36 -0500 Subject: [PATCH] improve thread-safety --- Maui.DataGrid/Extensions/ReflectionExtensions.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Maui.DataGrid/Extensions/ReflectionExtensions.cs b/Maui.DataGrid/Extensions/ReflectionExtensions.cs index 503b6be..2ce758e 100644 --- a/Maui.DataGrid/Extensions/ReflectionExtensions.cs +++ b/Maui.DataGrid/Extensions/ReflectionExtensions.cs @@ -105,11 +105,7 @@ internal static class ReflectionExtensions [MethodImpl(MethodImplOptions.AggressiveInlining)] private static PropertyDescriptor? GetPropertyDescriptor(Type type, string propertyName) { - if (!PropertyTypeCache.TryGetValue(type, out var properties)) - { - properties = TypeDescriptor.GetProperties(type); - PropertyTypeCache[type] = properties; - } + var properties = PropertyTypeCache.GetOrAdd(type, TypeDescriptor.GetProperties); return properties.Find(propertyName, false); }