-
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.
Merge pull request #1 from pfpack/feature/initial-create
Feature/initial create
- Loading branch information
Showing
62 changed files
with
1,443 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: .NET | ||
|
||
on: | ||
push: | ||
branches: [ feature/*, master ] | ||
|
||
pull_request: | ||
branches: [ master ] | ||
|
||
release: | ||
types: [ published ] | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 6.0.x | ||
include-prerelease: true | ||
|
||
- name: Create Local NuGet Directory | ||
run: mkdir ~/nuget | ||
|
||
- name: Add Local Nuget Source | ||
run: dotnet nuget add source ~/nuget | ||
|
||
- name: Restore AsyncPipeline | ||
run: dotnet restore ./src/*/*/AsyncPipeline.csproj | ||
|
||
- name: Build AsyncPipeline | ||
run: dotnet build ./src/*/*/AsyncPipeline.csproj --no-restore -c Release | ||
|
||
- name: Pack AsyncPipeline | ||
run: dotnet pack ./src/*/*/AsyncPipeline.csproj --no-restore -o ~/nuget -c Release | ||
|
||
- name: Push Packages | ||
if: ${{ github.event_name == 'release' }} | ||
run: dotnet nuget push "../../../nuget/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NuGetSourcePassword }} --skip-duplicate |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020-2021 Andrei Sergeev, Pavel Moskovoy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
25 changes: 25 additions & 0 deletions
25
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/AsyncPipeline.T.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,25 @@ | ||
#nullable enable | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
public readonly partial struct AsyncPipeline<T> : IEquatable<AsyncPipeline<T>> | ||
{ | ||
private static CancellationToken CanceledToken() => new(canceled: true); | ||
|
||
private readonly ValueTask<T> valueTask; | ||
|
||
private readonly bool isCanceled; | ||
|
||
private readonly CancellationToken cancellationToken; | ||
|
||
internal AsyncPipeline(ValueTask<T> valueTask, bool isCanceled, CancellationToken cancellationToken) | ||
{ | ||
this.valueTask = valueTask; | ||
this.isCanceled = isCanceled; | ||
this.cancellationToken = cancellationToken; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.Equals.Equality.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,15 @@ | ||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public static bool operator ==(AsyncPipeline<T> left, AsyncPipeline<T> right) | ||
=> | ||
left.Equals(right); | ||
|
||
public static bool operator !=(AsyncPipeline<T> left, AsyncPipeline<T> right) | ||
=> | ||
left.Equals(right) is false; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.Equals.Impl.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,13 @@ | ||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public bool Equals(AsyncPipeline<T> other) | ||
=> | ||
ValueTaskComparer.Equals(valueTask, other.valueTask) | ||
&& IsCanceledComparer.Equals(isCanceled, other.isCanceled) | ||
&& CancellationTokenComparer.Equals(cancellationToken, other.cancellationToken); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.Equals.Static.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,11 @@ | ||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public static bool Equals(AsyncPipeline<T> left, AsyncPipeline<T> right) | ||
=> | ||
left.Equals(right); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.Equals.Wrap.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,14 @@ | ||
#nullable enable | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public override bool Equals([NotNullWhen(true)] object? obj) | ||
=> | ||
obj is AsyncPipeline<T> other | ||
&& Equals(other); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.GetHashCode.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,15 @@ | ||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public override int GetHashCode() | ||
=> | ||
HashCode.Combine( | ||
EqualityContract, | ||
ValueTaskComparer.GetHashCode(valueTask), | ||
IsCanceledComparer.GetHashCode(isCanceled), | ||
CancellationTokenComparer.GetHashCode(cancellationToken)); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Equality/Equality.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,19 @@ | ||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
private static Type EqualityContract => typeof(AsyncPipeline<T>); | ||
|
||
private static IEqualityComparer<ValueTask<T>> ValueTaskComparer => EqualityComparer<ValueTask<T>>.Default; | ||
|
||
private static IEqualityComparer<bool> IsCanceledComparer => EqualityComparer<bool>.Default; | ||
|
||
private static IEqualityComparer<CancellationToken> CancellationTokenComparer => EqualityComparer<CancellationToken>.Default; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Pipe.Result/Pipe.Task.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,18 @@ | ||
#nullable enable | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncResultFlow<TSuccess, TFailure> Pipe<TSuccess, TFailure>( | ||
Func<T, CancellationToken, Task<Result<TSuccess, TFailure>>> pipeAsync) | ||
where TFailure : struct | ||
=> | ||
new( | ||
InternalPipe( | ||
pipeAsync ?? throw new ArgumentNullException(nameof(pipeAsync)))); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Pipe.Result/Pipe.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,14 @@ | ||
#nullable enable | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncResultFlow<TSuccess, TFailure> Pipe<TSuccess, TFailure>(Func<T, Result<TSuccess, TFailure>> pipe) | ||
where TFailure : struct | ||
=> | ||
new( | ||
InternalPipe( | ||
pipe ?? throw new ArgumentNullException(nameof(pipe)))); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Pipe.Result/PipeValue.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,18 @@ | ||
#nullable enable | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncResultFlow<TSuccess, TFailure> PipeValue<TSuccess, TFailure>( | ||
Func<T, CancellationToken, ValueTask<Result<TSuccess, TFailure>>> pipeAsync) | ||
where TFailure : struct | ||
=> | ||
new( | ||
InternalPipeValue( | ||
pipeAsync ?? throw new ArgumentNullException(nameof(pipeAsync)))); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Pipe/Pipe.Task.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,27 @@ | ||
#nullable enable | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncPipeline<TResult> Pipe<TResult>(Func<T, CancellationToken, Task<TResult>> pipeAsync) | ||
=> | ||
InternalPipe( | ||
pipeAsync ?? throw new ArgumentNullException(nameof(pipeAsync))); | ||
|
||
internal AsyncPipeline<TResult> InternalPipe<TResult>(Func<T, CancellationToken, Task<TResult>> pipeAsync) | ||
=> | ||
isCanceled || cancellationToken.IsCancellationRequested | ||
? new(valueTask: default, isCanceled: true, cancellationToken: cancellationToken) | ||
: new(valueTask: InnerPipeAsync(pipeAsync), isCanceled: false, cancellationToken: cancellationToken); | ||
|
||
private async ValueTask<TResult> InnerPipeAsync<TResult>(Func<T, CancellationToken, Task<TResult>> pipeAsync) | ||
{ | ||
var result = await valueTask.ConfigureAwait(false); | ||
return await pipeAsync.Invoke(result, cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Pipe/Pipe.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,26 @@ | ||
#nullable enable | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncPipeline<TResult> Pipe<TResult>(Func<T, TResult> pipe) | ||
=> | ||
InternalPipe( | ||
pipe ?? throw new ArgumentNullException(nameof(pipe))); | ||
|
||
internal AsyncPipeline<TResult> InternalPipe<TResult>(Func<T, TResult> pipe) | ||
=> | ||
isCanceled | ||
? new(valueTask: default, isCanceled: true, cancellationToken: cancellationToken) | ||
: new(valueTask: InnerPipeAsync(pipe), isCanceled: false, cancellationToken: cancellationToken); | ||
|
||
private async ValueTask<TResult> InnerPipeAsync<TResult>(Func<T, TResult> pipe) | ||
{ | ||
var result = await valueTask.ConfigureAwait(false); | ||
return pipe.Invoke(result); | ||
} | ||
} | ||
} |
Oops, something went wrong.