From 90cbe54474deca5d2844e6714d69fb484858c8c5 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Tue, 16 Jul 2024 10:28:25 -0700 Subject: [PATCH] Remote DrainToImmutable() extension method Since moving to System.Collections.Immutable 8.0, this extension method is no longer needed. --- .../ImmutableArrayExtensions.cs | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs b/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs index e0d7478cca7..3107a833101 100644 --- a/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs +++ b/src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs @@ -29,39 +29,6 @@ public static void SetCapacityIfLarger(this ImmutableArray.Builder builder } } - /// - /// Returns the current contents as an and sets - /// the collection to a zero length array. - /// - /// - /// If equals - /// , the internal array will be extracted - /// as an without copying the contents. Otherwise, the - /// contents will be copied into a new array. The collection will then be set to a - /// zero-length array. - /// - /// An immutable array. - public static ImmutableArray DrainToImmutable(this ImmutableArray.Builder builder) - { -#if NET8_0_OR_GREATER - return builder.DrainToImmutable(); -#else - if (builder.Count == 0) - { - return []; - } - - if (builder.Count == builder.Capacity) - { - return builder.MoveToImmutable(); - } - - var result = builder.ToImmutable(); - builder.Clear(); - return result; -#endif - } - public static ImmutableArray SelectAsArray(this ImmutableArray source, Func selector) { return source switch