forked from dotnet/corefxlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Added System.Buffers.ReaderWriter (dotnet#2155)"
This reverts commit fd72e1a.
- Loading branch information
Showing
29 changed files
with
115 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions
11
src/System.Buffers.Primitives/System/Buffers/IBufferTransformation.cs
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
src/System.Buffers.Primitives/System/Buffers/ThrowHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Buffers | ||
{ | ||
internal class ThrowHelper | ||
{ | ||
public static void ThrowArgumentOutOfRangeException(ExceptionArgument argument) | ||
{ | ||
throw GetArgumentOutOfRangeException(argument); | ||
} | ||
|
||
public static void ThrowInvalidOperationException(ExceptionResource resource) | ||
{ | ||
throw GetInvalidOperationException(resource); | ||
} | ||
|
||
public static void ThrowArgumentNullException(ExceptionArgument argument) | ||
{ | ||
throw GetArgumentNullException(argument); | ||
} | ||
|
||
public static void ThrowNotSupportedException() | ||
{ | ||
throw GetNotSupportedException(); | ||
} | ||
|
||
public static void ThrowCursorOutOfBoundsException() | ||
{ | ||
throw GetCursorOutOfBoundsException(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument) | ||
{ | ||
return new ArgumentOutOfRangeException(GetArgumentName(argument)); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static InvalidOperationException GetInvalidOperationException(ExceptionResource resource) | ||
{ | ||
return new InvalidOperationException(GetResourceString(resource)); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static NotSupportedException GetNotSupportedException() | ||
{ | ||
return new NotSupportedException(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static ArgumentNullException GetArgumentNullException(ExceptionArgument argument) | ||
{ | ||
return new ArgumentNullException(GetArgumentName(argument)); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Exception GetCursorOutOfBoundsException() | ||
{ | ||
return new InvalidOperationException("Cursor is out of bounds"); | ||
} | ||
|
||
private static string GetArgumentName(ExceptionArgument argument) | ||
{ | ||
Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), | ||
"The enum value is not defined, please check the ExceptionArgument Enum."); | ||
|
||
return argument.ToString(); | ||
} | ||
|
||
private static string GetResourceString(ExceptionResource argument) | ||
{ | ||
Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), argument), | ||
"The enum value is not defined, please check the ExceptionResource Enum."); | ||
|
||
// Should be look up with environment resources | ||
string resourceString = null; | ||
switch (argument) | ||
{ | ||
case ExceptionResource.UnexpectedSegmentType: | ||
resourceString = "Unexpected segment type"; | ||
break; | ||
case ExceptionResource.EndCursorNotReached: | ||
resourceString = "Segment chain ended without reaching end cursor location"; | ||
break; | ||
} | ||
|
||
resourceString = resourceString ?? $"Error ResourceKey not defined {argument}."; | ||
|
||
return resourceString; | ||
} | ||
} | ||
|
||
internal enum ExceptionArgument | ||
{ | ||
destination, | ||
offset, | ||
length, | ||
data, | ||
size | ||
} | ||
|
||
internal enum ExceptionResource | ||
{ | ||
UnexpectedSegmentType, | ||
EndCursorNotReached | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
src/System.Buffers.ReaderWriter/System.Buffers.ReaderWriter.csproj
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters