TRLS008 — Result is double-wrapped
- Severity: Warning
- Category: Trellis
What it detects
Flags declared or inferred Result<Result<T>>, and also flags Result.Success(existingResult) or Result.Failure(existingResult) when the value is already a Result<T>.
Why it matters
Double-wrapped results are awkward to handle and usually mean the pipeline used Map where Bind was intended.
Warning
A nested Result is almost never the domain model you actually want. It usually signals a flattened pipeline that never got flattened.
Bad example
using Trellis;
static class Example
{
public static Result<Result<int>> Bad() =>
Result.Success(Result.Success(42));
}
Good example
using Trellis;
static class Example
{
public static Result<int> Good() =>
Result.Success(42);
}
Code fix available
No.
Configuration
Use standard Roslyn configuration if you need to suppress this rule in a specific scope.
dotnet_diagnostic.TRLS008.severity = none
#pragma warning disable TRLS008
// Intentional: documented exception or test-only pattern.
#pragma warning restore TRLS008
Tip
If the inner expression already returns Result<T>, switch to Bind or return the inner result directly.