ResultExtensions Type
C#-idiomatic consumption of the `Result<'T, ProcessError>` that every verb returns. F# matches
`Ok`/`Error` directly; C# pattern-matches the result with no projection or helper call, using the
result's own members:
await cmd.OutputStringAsync() switch
{
{ IsOk: true, ResultValue: var run } => run.Stdout,
{ IsOk: false, ErrorValue: var err } => err.Message,
}
The match is exhaustive (the `IsOk` bool covers both arms — no discard needed); `ResultValue` is
read only in the `IsOk: true` arm (the pattern short-circuits) and binds non-null, so no `!`. For
non-`switch` styles these extensions give `Match` / `Switch`, `TryGetValue`, and `GetValueOrThrow`
without touching the result's members. A `Result` is never `null`, and the Try out-parameters
follow the standard .NET pattern.
Static members
| Static member |
Description
|
Full Usage:
ResultExtensions.GetValueOrThrow(result)
Parameters:
Result<'T, ProcessError>
Returns: 'T
Type parameters: 'T |
The success value, or raise `ProcessException` carrying the error.
|
Full Usage:
ResultExtensions.Match(result, onOk, onError)
Parameters:
Result<'T, ProcessError>
onOk : Func<'T, 'R>
onError : Func<ProcessError, 'R>
Returns: 'R
Type parameters: 'T, 'R |
Project both cases to a single value.
|
Full Usage:
ResultExtensions.Switch(result, onOk, onError)
Parameters:
Result<'T, ProcessError>
onOk : Action<'T>
onError : Action<ProcessError>
Type parameters: 'T |
Run the matching side effect (no return value).
|
Full Usage:
ResultExtensions.TryGetValue(result, value, error)
Parameters:
Result<'T, ProcessError>
value : byref<'T>
error : byref<ProcessError>
Returns: bool
Type parameters: 'T |
On success returns `true` and sets `value`; on failure returns `false` and sets `error`. The nullability attributes make the standard Try-pattern honest to nullable-aware C#: read `value` only when the call returned `true`, and `error` only when it returned `false`.
|
ProcessKit API Reference