Fixes formatting (#200)
This commit is contained in:
parent
1f651992d7
commit
86b7b3aed1
209 changed files with 51326 additions and 50397 deletions
|
|
@ -1,51 +1,53 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Buffers
|
||||
{
|
||||
public static class MemoryPoolThrowHelper
|
||||
{
|
||||
public static void ThrowArgumentOutOfRangeException(int sourceLength, int offset)
|
||||
{
|
||||
throw GetArgumentOutOfRangeException(sourceLength, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(int sourceLength, int offset) =>
|
||||
(uint)offset > (uint)sourceLength
|
||||
? new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.offset))
|
||||
: new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.length));
|
||||
|
||||
public static void ThrowArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize)
|
||||
{
|
||||
throw GetArgumentOutOfRangeException_BufferRequestTooLarge(maxSize);
|
||||
}
|
||||
|
||||
public static void ThrowObjectDisposedException(ExceptionArgument argument)
|
||||
{
|
||||
throw GetObjectDisposedException(argument);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize) =>
|
||||
new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.size),
|
||||
$"Cannot allocate more than {maxSize} bytes in a single buffer");
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ObjectDisposedException GetObjectDisposedException(ExceptionArgument argument) =>
|
||||
new ObjectDisposedException(GetArgumentName(argument));
|
||||
|
||||
private static string GetArgumentName(ExceptionArgument argument) => argument.ToString();
|
||||
|
||||
public enum ExceptionArgument
|
||||
{
|
||||
size,
|
||||
offset,
|
||||
length,
|
||||
MemoryPoolBlock,
|
||||
MemoryPool
|
||||
}
|
||||
}
|
||||
}
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Buffers
|
||||
{
|
||||
public static class MemoryPoolThrowHelper
|
||||
{
|
||||
public enum ExceptionArgument
|
||||
{
|
||||
size,
|
||||
offset,
|
||||
length,
|
||||
MemoryPoolBlock,
|
||||
MemoryPool
|
||||
}
|
||||
|
||||
public static void ThrowArgumentOutOfRangeException(int sourceLength, int offset)
|
||||
{
|
||||
throw GetArgumentOutOfRangeException(sourceLength, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(int sourceLength, int offset) =>
|
||||
(uint)offset > (uint)sourceLength
|
||||
? new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.offset))
|
||||
: new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.length));
|
||||
|
||||
public static void ThrowArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize)
|
||||
{
|
||||
throw GetArgumentOutOfRangeException_BufferRequestTooLarge(maxSize);
|
||||
}
|
||||
|
||||
public static void ThrowObjectDisposedException(ExceptionArgument argument)
|
||||
{
|
||||
throw GetObjectDisposedException(argument);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize) =>
|
||||
new ArgumentOutOfRangeException(
|
||||
GetArgumentName(ExceptionArgument.size),
|
||||
$"Cannot allocate more than {maxSize} bytes in a single buffer"
|
||||
);
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private static ObjectDisposedException GetObjectDisposedException(ExceptionArgument argument) =>
|
||||
new ObjectDisposedException(GetArgumentName(argument));
|
||||
|
||||
private static string GetArgumentName(ExceptionArgument argument) => argument.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue