Table of Contents

Class ResultLinqExtensionsValueTaskAsync

Namespace
Trellis
Assembly
Trellis.Core.dll

Provides LINQ query expression support for ValueTask<TResult> of Result<TValue>, enabling C# query syntax over fully asynchronous Result-returning operations that may complete synchronously.

public static class ResultLinqExtensionsValueTaskAsync
Inheritance
ResultLinqExtensionsValueTaskAsync
Inherited Members

Remarks

These overloads match the C# query-pattern signatures (Select, SelectMany, Where) for an async receiver and async continuations. Semantics mirror ResultLinqExtensions: failures short-circuit subsequent steps; only success values flow through.

Methods

SelectMany<TSource, TCollection, TResult>(ValueTask<Result<TSource>>, Func<TSource, ValueTask<Result<TCollection>>>, Func<TSource, TCollection, TResult>)

Projects the value of an awaited Result<TValue> through an async collection selector and combines the results (LINQ SelectMany over async/async, ValueTask variant).

public static ValueTask<Result<TResult>> SelectMany<TSource, TCollection, TResult>(this ValueTask<Result<TSource>> source, Func<TSource, ValueTask<Result<TCollection>>> collectionSelector, Func<TSource, TCollection, TResult> resultSelector)

Parameters

source ValueTask<Result<TSource>>

The asynchronous source result.

collectionSelector Func<TSource, ValueTask<Result<TCollection>>>

An async function returning the intermediate result.

resultSelector Func<TSource, TCollection, TResult>

A synchronous function combining the source and intermediate values.

Returns

ValueTask<Result<TResult>>

A value task producing the combined result, or the first failure encountered.

Type Parameters

TSource

Type of the source value.

TCollection

Type of the intermediate collection value.

TResult

Type of the final projected value.

Select<TIn, TOut>(ValueTask<Result<TIn>>, Func<TIn, TOut>)

Projects the value of an awaited Result<TValue> using a synchronous selector (LINQ Select over ValueTask<TResult>).

public static ValueTask<Result<TOut>> Select<TIn, TOut>(this ValueTask<Result<TIn>> resultTask, Func<TIn, TOut> selector)

Parameters

resultTask ValueTask<Result<TIn>>

The asynchronous result to project.

selector Func<TIn, TOut>

The projection function applied to the success value.

Returns

ValueTask<Result<TOut>>

A value task producing a result with the projected value, or the original failure.

Type Parameters

TIn

The type of the input value.

TOut

The type of the output value.

Where<TSource>(ValueTask<Result<TSource>>, Func<TSource, bool>)

Filters an awaited Result<TValue> by a synchronous predicate (LINQ Where over ValueTask<TResult>).

public static ValueTask<Result<TSource>> Where<TSource>(this ValueTask<Result<TSource>> source, Func<TSource, bool> predicate)

Parameters

source ValueTask<Result<TSource>>

The asynchronous result to filter.

predicate Func<TSource, bool>

The predicate to test the success value.

Returns

ValueTask<Result<TSource>>

The original success when the predicate is true; otherwise a generic "filtered out" failure.

Type Parameters

TSource

Type of the source value.