Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Abstractions project #391

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

<PropertyGroup>
<Authors>Antao Almada</Authors>
<Copyright>Copyright 2019-2021 Antao Almada</Copyright>
<Copyright>Copyright 2019-2023 Antao Almada</Copyright>
<LangVersion>latest</LangVersion>
<Features>strict</Features>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
267 changes: 267 additions & 0 deletions NetFabric.Hyperlinq.Abstractions/ActionWrapper.cs

Large diffs are not rendered by default.

234 changes: 111 additions & 123 deletions NetFabric.Hyperlinq.Abstractions/AsyncFunctionWrapper.cs

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions NetFabric.Hyperlinq.Abstractions/AsyncValueEnumerable.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System.Collections.Generic;
using System.Threading;
namespace NetFabric.Hyperlinq;

namespace NetFabric.Hyperlinq
public interface IAsyncValueEnumerable<out T, out TEnumerator>
: IAsyncEnumerable<T>
where TEnumerator : struct, IAsyncEnumerator<T>
{
public interface IAsyncValueEnumerable<out T, out TEnumerator>
: IAsyncEnumerable<T>
where TEnumerator : struct, IAsyncEnumerator<T>
{
new TEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default);
}
new TEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default);
}
6 changes: 0 additions & 6 deletions NetFabric.Hyperlinq.Abstractions/FunctionIn.cs

This file was deleted.

37 changes: 0 additions & 37 deletions NetFabric.Hyperlinq.Abstractions/FunctionInWrapper.cs

This file was deleted.

257 changes: 123 additions & 134 deletions NetFabric.Hyperlinq.Abstractions/FunctionWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,165 +1,154 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace NetFabric.Hyperlinq
{
public readonly struct FunctionWrapper<TResult>
: IFunction<TResult>
{
readonly Func<TResult> function;

public FunctionWrapper(Func<TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke()
=> function();

public static implicit operator FunctionWrapper<TResult>(Func<TResult> func)
=> new(func);
}

public readonly struct FunctionWrapper<T, TResult>
: IFunction<T, TResult>
{
readonly Func<T, TResult> function;

public FunctionWrapper(Func<T, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T arg)
=> function(arg);

public static implicit operator FunctionWrapper<T, TResult>(Func<T, TResult> func)
=> new(func);
}

public readonly struct FunctionWrapper<T1, T2, TResult>
: IFunction<T1, T2, TResult>
{
readonly Func<T1, T2, TResult> function;
namespace NetFabric.Hyperlinq;

public FunctionWrapper(Func<T1, T2, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<TResult>(Func<TResult> function)
: IFunction<TResult>
{
readonly Func<TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2)
=> function(arg1, arg2);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke()
=> function();

public static implicit operator FunctionWrapper<T1, T2, TResult>(Func<T1, T2, TResult> func)
=> new(func);
}

public readonly struct FunctionWrapper<T1, T2, T3, TResult>
: IFunction<T1, T2, T3, TResult>
{
readonly Func<T1, T2, T3, TResult> function;
public static implicit operator FunctionWrapper<TResult>(Func<TResult> func)
=> new(func);
}

public FunctionWrapper(Func<T1, T2, T3, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T, TResult>(Func<T, TResult> function)
: IFunction<T, TResult>
{
readonly Func<T, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3)
=> function(arg1, arg2, arg3);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T arg)
=> function(arg);

public static implicit operator FunctionWrapper<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func)
=> new(func);
}
public static implicit operator FunctionWrapper<T, TResult>(Func<T, TResult> func)
=> new(func);
}

public readonly struct FunctionWrapper<T1, T2, T3, T4, TResult>
: IFunction<T1, T2, T3, T4, TResult>
{
readonly Func<T1, T2, T3, T4, TResult> function;
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, TResult>(Func<T1, T2, TResult> function)
: IFunction<T1, T2, TResult>
{
readonly Func<T1, T2, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public FunctionWrapper(Func<T1, T2, T3, T4, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2)
=> function(arg1, arg2);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
=> function(arg1, arg2, arg3, arg4);
public static implicit operator FunctionWrapper<T1, T2, TResult>(Func<T1, T2, TResult> func)
=> new(func);
}

public static implicit operator FunctionWrapper<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func)
=> new(func);
}
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> function)
: IFunction<T1, T2, T3, TResult>
{
readonly Func<T1, T2, T3, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, TResult>
: IFunction<T1, T2, T3, T4, T5, TResult>
{
readonly Func<T1, T2, T3, T4, T5, TResult> function;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3)
=> function(arg1, arg2, arg3);

public FunctionWrapper(Func<T1, T2, T3, T4, T5, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
public static implicit operator FunctionWrapper<T1, T2, T3, TResult>(Func<T1, T2, T3, TResult> func)
=> new(func);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
=> function(arg1, arg2, arg3, arg4, arg5);
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> function)
: IFunction<T1, T2, T3, T4, TResult>
{
readonly Func<T1, T2, T3, T4, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> func)
=> new(func);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4)
=> function(arg1, arg2, arg3, arg4);

public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, TResult>
: IFunction<T1, T2, T3, T4, T5, T6, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, TResult> function;
public static implicit operator FunctionWrapper<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, TResult> func)
=> new(func);
}

public FunctionWrapper(Func<T1, T2, T3, T4, T5, T6, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> function)
: IFunction<T1, T2, T3, T4, T5, TResult>
{
readonly Func<T1, T2, T3, T4, T5, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
=> function(arg1, arg2, arg3, arg4, arg5, arg6);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
=> function(arg1, arg2, arg3, arg4, arg5);

public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, TResult>(Func<T1, T2, T3, T4, T5, T6, TResult> func)
=> new(func);
}
public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, TResult>(Func<T1, T2, T3, T4, T5, TResult> func)
=> new(func);
}

public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, TResult>
: IFunction<T1, T2, T3, T4, T5, T6, T7, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, TResult> function;
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, TResult>(Func<T1, T2, T3, T4, T5, T6, TResult> function)
: IFunction<T1, T2, T3, T4, T5, T6, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public FunctionWrapper(Func<T1, T2, T3, T4, T5, T6, T7, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
=> function(arg1, arg2, arg3, arg4, arg5, arg6);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, TResult>(Func<T1, T2, T3, T4, T5, T6, TResult> func)
=> new(func);
}

public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, TResult> func)
=> new(func);
}
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, TResult> function)
: IFunction<T1, T2, T3, T4, T5, T6, T7, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, TResult>
: IFunction<T1, T2, T3, T4, T5, T6, T7, T8, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> function;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7);

public FunctionWrapper(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, TResult> func)
=> new(func);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> function)
: IFunction<T1, T2, T3, T4, T5, T6, T7, T8, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> func)
=> new(func);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);

public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>
: IFunction<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> function;
public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> func)
=> new(func);
}

public FunctionWrapper(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> function)
=> this.function = function ?? throw new ArgumentNullException(nameof(function));
[StructLayout(LayoutKind.Auto)]
public readonly struct FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> function)
: IFunction<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>
{
readonly Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> function
= function ?? throw new ArgumentNullException(nameof(function));

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TResult Invoke(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
=> function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);

public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> func)
=> new(func);
}
}
public static implicit operator FunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> func)
=> new(func);
}
Loading
Loading