diff --git a/src/Avalonia.Base/CollectionPolyfills.cs b/src/Avalonia.Base/CollectionPolyfills.cs deleted file mode 100644 index b41c3a4d2c..0000000000 --- a/src/Avalonia.Base/CollectionPolyfills.cs +++ /dev/null @@ -1,33 +0,0 @@ -#if !NET6_0_OR_GREATER -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace Avalonia -{ - internal static class CollectionPolyfills - { - public static bool Remove( - this Dictionary o, - TKey key, - [MaybeNullWhen(false)] out TValue value) - where TKey : notnull - { - if (o.TryGetValue(key, out value)) - return o.Remove(key); - return false; - } - - public static bool TryAdd(this Dictionary o, TKey key, TValue value) - where TKey : notnull - { - if (!o.ContainsKey(key)) - { - o.Add(key, value); - return true; - } - - return false; - } - } -} -#endif diff --git a/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs b/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs new file mode 100644 index 0000000000..e22288a74d --- /dev/null +++ b/src/Avalonia.Base/Compatibility/CollectionCompatibilityExtensions.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace System; + +#if !NET6_0_OR_GREATER +internal static class CollectionCompatibilityExtensions +{ + public static bool Remove( + this Dictionary o, + TKey key, + [MaybeNullWhen(false)] out TValue value) + where TKey : notnull + { + if (o.TryGetValue(key, out value)) + return o.Remove(key); + return false; + } + + public static bool TryAdd(this Dictionary o, TKey key, TValue value) + where TKey : notnull + { + if (!o.ContainsKey(key)) + { + o.Add(key, value); + return true; + } + + return false; + } +} +#endif