Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Added System.Buffers.ReaderWriter (#2155)
Browse files Browse the repository at this point in the history
* Refactored Reader/Writer

* More refactoring
  • Loading branch information
KrzysztofCwalina authored Mar 12, 2018
1 parent fc0c8d8 commit fd72e1a
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 115 deletions.
15 changes: 15 additions & 0 deletions corefxlab.sln
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Azure.Experimental",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.IO.Pipelines.Extensions.Tests", "tests\System.IO.Pipelines.Extensions.Tests\System.IO.Pipelines.Extensions.Tests.csproj", "{64C08774-982C-4141-8F8D-2884B6FA0E4B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Buffers.ReaderWriter", "src\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj", "{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -892,6 +894,18 @@ Global
{64C08774-982C-4141-8F8D-2884B6FA0E4B}.Release|x64.Build.0 = Release|Any CPU
{64C08774-982C-4141-8F8D-2884B6FA0E4B}.Release|x86.ActiveCfg = Release|Any CPU
{64C08774-982C-4141-8F8D-2884B6FA0E4B}.Release|x86.Build.0 = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|x64.ActiveCfg = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|x64.Build.0 = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|x86.ActiveCfg = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Debug|x86.Build.0 = Debug|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|Any CPU.Build.0 = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|x64.ActiveCfg = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|x64.Build.0 = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|x86.ActiveCfg = Release|Any CPU
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -959,6 +973,7 @@ Global
{0BA3C0A9-64B9-445D-B085-8FFAC09D6E37} = {3079E458-D0E6-4F99-8CAB-80011D35C7DA}
{916370AB-B0D3-4136-850B-AA12FAB23ECD} = {4B000021-5278-4F2A-B734-DE49F55D4024}
{64C08774-982C-4141-8F8D-2884B6FA0E4B} = {3079E458-D0E6-4F99-8CAB-80011D35C7DA}
{C5F9D191-CA3B-4648-B8A9-62E33B4622EB} = {4B000021-5278-4F2A-B734-DE49F55D4024}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9DD4022C-A010-4A9B-BCC5-171566D4CB17}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ItemGroup>
<ProjectReference Include="..\System.Binary.Base64\System.Binary.Base64.csproj" />
<ProjectReference Include="..\System.Buffers.Experimental\System.Buffers.Experimental.csproj" />
<ProjectReference Include="..\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj" />
<ProjectReference Include="..\System.Text.Encodings.Web.Utf8\System.Text.Encodings.Web.Utf8.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ public interface IBufferOperation
{
OperationStatus Execute(ReadOnlySpan<byte> input, Span<byte> output, out int consumed, out int written);
}
public interface IBufferTransformation : IBufferOperation
{
OperationStatus Transform(Span<byte> buffer, int dataLength, out int written);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace System.Buffers
{
public interface IBufferTransformation : IBufferOperation
{
OperationStatus Transform(Span<byte> buffer, int dataLength, out int written);
}
}
111 changes: 0 additions & 111 deletions src/System.Buffers.Primitives/System/Buffers/ThrowHelper.cs

This file was deleted.

17 changes: 17 additions & 0 deletions src/System.Buffers.ReaderWriter/System.Buffers.ReaderWriter.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\tools\common.props" />
<PropertyGroup>
<Description>Buffer Readers, Writers, and Transformations</Description>
<TargetFramework>netstandard1.3</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PackageTags>Span BufferReader BufferWriter corefxlab</PackageTags>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\System.Collections.Sequences\System.Collections.Sequences.csproj" />
<ProjectReference Include="..\System.Text.Primitives\System.Text.Primitives.csproj" />
<ProjectReference Include="..\System.Text.Utf8String\System.Text.Utf8String.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesVersion)" />
</ItemGroup>
</Project>
37 changes: 37 additions & 0 deletions src/System.Buffers.ReaderWriter/System/ThrowHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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);
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument)
{
return new ArgumentOutOfRangeException(GetArgumentName(argument));
}

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();
}
}

internal enum ExceptionArgument
{

length,

}
}
1 change: 1 addition & 0 deletions src/System.Text.Http.Parser/System.Text.Http.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\System.Buffers.Experimental\System.Buffers.Experimental.csproj" />
<ProjectReference Include="..\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesVersion)" />
Expand Down
1 change: 1 addition & 0 deletions src/System.Text.Http/System.Text.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<LangVersion>7.2</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj" />
<ProjectReference Include="..\System.Text.Formatting\System.Text.Formatting.csproj" />
<ProjectReference Include="..\System.Text.Http.Parser\System.Text.Http.Parser.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
</ItemGroup>
<!-- Project references -->
<ItemGroup>
<ProjectReference Include="..\..\src\System.Buffers.Experimental\System.Buffers.Experimental.csproj" />
<ProjectReference Include="..\..\src\System.Buffers.Primitives\System.Buffers.Primitives.csproj" />
<ProjectReference Include="..\..\src\System.Buffers.ReaderWriter\System.Buffers.ReaderWriter.csproj" />
</ItemGroup>
<!-- register for test discovery in Visual Studio -->
<ItemGroup>
Expand Down

0 comments on commit fd72e1a

Please sign in to comment.