Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Add System.IO.Pipelines API #27007

Merged
merged 14 commits into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/Microsoft.Private.PackageBaseline/packageIndex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,12 @@
"4.0.3.0": "4.5.0"
}
},
"System.IO.Pipelines": {
"InboxOn": {},
"AssemblyVersionInPackageVersion": {
"4.0.0.0": "4.5.0"
}
},
"System.IO.Pipes": {
"StableVersions": [
"4.0.0",
Expand Down
9 changes: 9 additions & 0 deletions pkg/descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,15 @@
"Description": "Provides classes that support storage of multiple data objects in a single container.",
"CommonTypes": []
},
{
"Name": "System.IO.Pipelines",
"Description": "Single producer single consumer byte buffer management.",
"CommonTypes": [
"System.IO.Pipelines.Pipe",
"System.IO.Pipelines.PipeWriter",
"System.IO.Pipelines.PipeReader"
]
},
{
"Name": "System.IO.Pipes",
"Description": "Provides a means for interprocess communication through anonymous and/or named pipes.",
Expand Down
49 changes: 49 additions & 0 deletions src/System.IO.Pipelines/System.IO.Pipelines.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27325.3006
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipelines.Tests", "tests\System.IO.Pipelines.Tests.csproj", "{9E984EB2-827E-4029-9647-FB5F8B67C553}"
ProjectSection(ProjectDependencies) = postProject
{1032D5F6-5AE7-4002-A0E4-FEBEADFEA977} = {1032D5F6-5AE7-4002-A0E4-FEBEADFEA977}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipelines", "src\System.IO.Pipelines.csproj", "{1032D5F6-5AE7-4002-A0E4-FEBEADFEA977}"
ProjectSection(ProjectDependencies) = postProject
{9C524CA0-92FF-437B-B568-BCE8A794A69A} = {9C524CA0-92FF-437B-B568-BCE8A794A69A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.IO.Pipelines", "ref\System.IO.Pipelines.csproj", "{9C524CA0-92FF-437B-B568-BCE8A794A69A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1A2F9F4A-A032-433E-B914-ADD5992BB178}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E107E9C1-E893-4E87-987E-04EF0DCEAEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{2E666815-2EDB-464B-9DF6-380BF4789AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9E984EB2-827E-4029-9647-FB5F8B67C553}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{9E984EB2-827E-4029-9647-FB5F8B67C553}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{9E984EB2-827E-4029-9647-FB5F8B67C553}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{9E984EB2-827E-4029-9647-FB5F8B67C553}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
{9C524CA0-92FF-437B-B568-BCE8A794A69A}.Debug|Any CPU.ActiveCfg = netstandard-Debug|Any CPU
{9C524CA0-92FF-437B-B568-BCE8A794A69A}.Debug|Any CPU.Build.0 = netstandard-Debug|Any CPU
{9C524CA0-92FF-437B-B568-BCE8A794A69A}.Release|Any CPU.ActiveCfg = netstandard-Release|Any CPU
{9C524CA0-92FF-437B-B568-BCE8A794A69A}.Release|Any CPU.Build.0 = netstandard-Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9E984EB2-827E-4029-9647-FB5F8B67C553} = {1A2F9F4A-A032-433E-B914-ADD5992BB178}
{1032D5F6-5AE7-4002-A0E4-FEBEADFEA977} = {E107E9C1-E893-4E87-987E-04EF0DCEAEFD}
{9C524CA0-92FF-437B-B568-BCE8A794A69A} = {2E666815-2EDB-464B-9DF6-380BF4789AD4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {895BDE3D-0E51-485D-908E-16FB1A74FA64}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions src/System.IO.Pipelines/dir.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\dir.props" />
<PropertyGroup>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyKey>Open</AssemblyKey>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need the following tags:

<IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>

cc @weshaggard

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you don't need those tags. This library is supposed to ship as a nuget package and not in the shared frameworks.

</PropertyGroup>
</Project>
11 changes: 11 additions & 0 deletions src/System.IO.Pipelines/pkg/System.IO.Pipelines.pkgproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<ItemGroup>
<ProjectReference Include="..\ref\System.IO.Pipelines.csproj">
<SupportedFramework>net46;netcore50;netcoreapp1.0;$(UAPvNextTFM);$(AllXamarinFrameworks)</SupportedFramework>
</ProjectReference>
<ProjectReference Include="..\src\System.IO.Pipelines.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
8 changes: 8 additions & 0 deletions src/System.IO.Pipelines/ref/Configurations.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add netcoreapp and uap here?

</BuildConfigurations>
</PropertyGroup>
</Project>
98 changes: 98 additions & 0 deletions src/System.IO.Pipelines/ref/System.IO.Pipelines.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// 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.
// ------------------------------------------------------------------------------
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------

namespace System.IO.Pipelines
{
public partial struct FlushResult
{
private int _dummy;
public FlushResult(bool isCanceled, bool isCompleted) { throw null; }
public bool IsCanceled { get { throw null; } }
public bool IsCompleted { get { throw null; } }
}
public partial interface IDuplexPipe : System.IDisposable
Copy link
Member

@davidfowl davidfowl Feb 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets get rid of IDisposable. Not critical for this PR but we'll need to make more changes.

{
System.IO.Pipelines.PipeReader Input { get; }
System.IO.Pipelines.PipeWriter Output { get; }
}
public partial interface IPipeAwaiter<out T>
{
bool IsCompleted { get; }
T GetResult();
void OnCompleted(System.Action continuation);
}
public sealed partial class Pipe
{
public Pipe() { }
public Pipe(System.IO.Pipelines.PipeOptions options) { }
public System.IO.Pipelines.PipeReader Reader { get { throw null; } }
public System.IO.Pipelines.PipeWriter Writer { get { throw null; } }
public void Reset() { }
}
public partial struct PipeAwaiter<T> : System.Runtime.CompilerServices.ICriticalNotifyCompletion, System.Runtime.CompilerServices.INotifyCompletion
{
private object _dummy;
public PipeAwaiter(System.IO.Pipelines.IPipeAwaiter<T> awaiter) { throw null; }
public bool IsCompleted { get { throw null; } }
public System.IO.Pipelines.PipeAwaiter<T> GetAwaiter() { throw null; }
public T GetResult() { throw null; }
public void OnCompleted(System.Action continuation) { }
public void UnsafeOnCompleted(System.Action continuation) { }
}
public partial class PipeOptions
{
public PipeOptions(System.Buffers.MemoryPool<byte> pool = null, System.IO.Pipelines.PipeScheduler readerScheduler = null, System.IO.Pipelines.PipeScheduler writerScheduler = null, long pauseWriterThreshold = (long)0, long resumeWriterThreshold = (long)0, int minimumSegmentSize = 2048) { }
public static System.IO.Pipelines.PipeOptions Default { get { throw null; } }
public int MinimumSegmentSize { get { throw null; } }
public long PauseWriterThreshold { get { throw null; } }
public System.Buffers.MemoryPool<byte> Pool { get { throw null; } }
public System.IO.Pipelines.PipeScheduler ReaderScheduler { get { throw null; } }
public long ResumeWriterThreshold { get { throw null; } }
public System.IO.Pipelines.PipeScheduler WriterScheduler { get { throw null; } }
}
public abstract partial class PipeReader
{
protected PipeReader() { }
public abstract void AdvanceTo(System.SequencePosition consumed);
public abstract void AdvanceTo(System.SequencePosition consumed, System.SequencePosition examined);
public abstract void CancelPendingRead();
public abstract void Complete(System.Exception exception = null);
public abstract void OnWriterCompleted(System.Action<System.Exception, object> callback, object state);
public abstract System.IO.Pipelines.PipeAwaiter<System.IO.Pipelines.ReadResult> ReadAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public abstract bool TryRead(out System.IO.Pipelines.ReadResult result);
}
public abstract partial class PipeScheduler
{
protected PipeScheduler() { }
public static System.IO.Pipelines.PipeScheduler Inline { get { throw null; } }
public static System.IO.Pipelines.PipeScheduler ThreadPool { get { throw null; } }
public abstract void Schedule(System.Action action);
public abstract void Schedule(System.Action<object> action, object state);
}
public abstract partial class PipeWriter : System.Buffers.IBufferWriter<byte>
{
protected PipeWriter() { }
public abstract void Advance(int bytes);
public abstract void CancelPendingFlush();
public abstract void Commit();
public abstract void Complete(System.Exception exception = null);
public abstract System.IO.Pipelines.PipeAwaiter<System.IO.Pipelines.FlushResult> FlushAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
public abstract System.Memory<byte> GetMemory(int minimumLength = 0);
public abstract System.Span<byte> GetSpan(int minimumLength = 0);
public abstract int MaxBufferSize { get; }
public abstract void OnReaderCompleted(System.Action<System.Exception, object> callback, object state);
public virtual System.IO.Pipelines.PipeAwaiter<System.IO.Pipelines.FlushResult> WriteAsync(System.ReadOnlyMemory<byte> source, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial struct ReadResult
{
private object _dummy;
public ReadResult(System.Buffers.ReadOnlySequence<byte> buffer, bool isCanceled, bool isCompleted) { throw null; }
public System.Buffers.ReadOnlySequence<byte> Buffer { get { throw null; } }
public bool IsCanceled { get { throw null; } }
public bool IsCompleted { get { throw null; } }
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public bool IsFlush { get { throw null; } }

to differentiate between PipeWriter.WriteAsync and PipeWriter.FlushAsync

}
17 changes: 17 additions & 0 deletions src/System.IO.Pipelines/ref/System.IO.Pipelines.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<ProjectGuid>{9C524CA0-92FF-437B-B568-BCE8A794A69A}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Debug|AnyCPU'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'netstandard-Release|AnyCPU'" />
<ItemGroup>
<Compile Include="System.IO.Pipelines.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
<ProjectReference Include="..\..\System.Memory\ref\System.Memory.csproj" />
<ProjectReference Include="..\..\System.Buffers\ref\System.Buffers.csproj" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
8 changes: 8 additions & 0 deletions src/System.IO.Pipelines/src/Configurations.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BuildConfigurations>
netstandard;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add netstandard1.3 and netcoreapp here (and add corresponding PropertyGroup in the csproj as well). See https://github.com/dotnet/corefx/blob/master/src/System.Memory/src/System.Memory.csproj#L13-L22

</BuildConfigurations>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions src/System.IO.Pipelines/src/Properties/InternalsVisibleTo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 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.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("System.IO.Pipelines.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010015c01ae1f50e8cc09ba9eac9147cf8fd9fce2cfe9f8dce4f7301c4132ca9fb50ce8cbf1df4dc18dd4d210e4345c744ecb3365ed327efdbc52603faa5e21daa11234c8c4a73e51f03bf192544581ebe107adee3a34928e39d04e524a9ce729d5090bfd7dad9d10c722c0def9ccc08ff0a03790e48bcd1f9b6c476063e1966a1c4")]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid this. If tests need to extract internals (and this practice should be used with discretion), it should use Reflection to get just what's needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? The ASP.NET uses this pattern for tests all the time. In fact thats the only valid use of internals visible to IMO.

Loading