Move the ArrayPool code to the shared location. Also use wraps to make
code identical to CoreFX. (Fixing an exception message issue.)
Commit migrated from https://github.com/dotnet/coreclr/commit/
6a7f5ead07e244e89df5602a4d5d477aa1f14b4b
get { return Environment.GetResourceString("InvalidOperation_NativeOverlappedReused"); }
}
+ public static string ArgumentException_BufferNotFromPool
+ {
+ get { return Environment.GetResourceString("ArgumentException_BufferNotFromPool"); }
+ }
+
public static string Format(string formatString, params object[] args)
{
return string.Format(CultureInfo.CurrentCulture, formatString, args);
// Check to see if the buffer is the correct size for this bucket
if (array.Length != _bufferLength)
{
- throw new ArgumentException(Environment.GetResourceString("ArgumentException_BufferNotFromPool", nameof(array)));
+ throw new ArgumentException(SR.ArgumentException_BufferNotFromPool, nameof(array));
}
// While holding the spin lock, if there's room available in the bucket,
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace System.Buffers
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static int SelectBucketIndex(int bufferSize)
{
- BCLDebug.Assert(bufferSize > 0);
+ Debug.Assert(bufferSize > 0);
uint bitsRemaining = ((uint)bufferSize - 1) >> 4;
internal static int GetMaxSizeForBucket(int binIndex)
{
int maxSize = 16 << binIndex;
- BCLDebug.Assert(maxSize >= 0);
+ Debug.Assert(maxSize >= 0);
return maxSize;
}
}
<ItemGroup>
<NumericsSources Include="$(BclSourcesRoot)\System\Numerics\Hashing\HashHelpers.cs" />
</ItemGroup>
- <ItemGroup>
- <BuffersSources Condition="'$(FeatureCoreClr)'=='true'" Include="$(BclSourcesRoot)\System\Buffers\ArrayPool.cs" />
- <BuffersSources Condition="'$(FeatureCoreClr)'=='true'" Include="$(BclSourcesRoot)\System\Buffers\ArrayPoolEventSource.cs" />
- <BuffersSources Condition="'$(FeatureCoreClr)'=='true'" Include="$(BclSourcesRoot)\System\Buffers\DefaultArrayPool.cs" />
- <BuffersSources Condition="'$(FeatureCoreClr)'=='true'" Include="$(BclSourcesRoot)\System\Buffers\DefaultArrayPoolBucket.cs" />
- <BuffersSources Condition="'$(FeatureCoreClr)'=='true'" Include="$(BclSourcesRoot)\System\Buffers\Utilities.cs" />
+ <ItemGroup Condition="'$(FeatureCoreClr)'=='true'">
+ <BuffersSources Include="$(CoreFxSourcesRoot)\System\Buffers\ArrayPool.cs" />
+ <BuffersSources Include="$(CoreFxSourcesRoot)\System\Buffers\ArrayPoolEventSource.cs" />
+ <BuffersSources Include="$(CoreFxSourcesRoot)\System\Buffers\DefaultArrayPool.cs" />
+ <BuffersSources Include="$(CoreFxSourcesRoot)\System\Buffers\DefaultArrayPoolBucket.cs" />
+ <BuffersSources Include="$(CoreFxSourcesRoot)\System\Buffers\Utilities.cs" />
</ItemGroup>
<ItemGroup Condition="'$(FeatureCoreFxWindowsInterop)' == 'true'">
<WindowsInteropSources Include="$(CoreFxSourcesRoot)\System\HResults.cs" />