Trellis.Analyzers
3.0.0-alpha.140
See the version list below for details.
dotnet add package Trellis.Analyzers --version 3.0.0-alpha.140
NuGet\Install-Package Trellis.Analyzers -Version 3.0.0-alpha.140
<PackageReference Include="Trellis.Analyzers" Version="3.0.0-alpha.140" />
<PackageVersion Include="Trellis.Analyzers" Version="3.0.0-alpha.140" />
<PackageReference Include="Trellis.Analyzers" />
paket add Trellis.Analyzers --version 3.0.0-alpha.140
#r "nuget: Trellis.Analyzers, 3.0.0-alpha.140"
#:package Trellis.Analyzers@3.0.0-alpha.140
#addin nuget:?package=Trellis.Analyzers&version=3.0.0-alpha.140&prerelease
#tool nuget:?package=Trellis.Analyzers&version=3.0.0-alpha.140&prerelease
Roslyn Analyzers
20 Roslyn analyzers that enforce proper usage of Result<T> and Maybe<T> patterns at compile time — catch unsafe access, unhandled results, and anti-patterns before they reach production.
Installation
dotnet add package Trellis.Analyzers
Analyzers integrate automatically into your build and provide warnings in Visual Studio, VS Code, and dotnet build.
What It Catches
Unsafe Access
// TRLS003: Unsafe Result.Value access
var user = GetUser(id);
Console.WriteLine(user.Value.Name); // May throw
// Fix: Check first, or use Match
if (user.IsSuccess)
Console.WriteLine(user.Value.Name);
Wrong Method Usage
// TRLS002: Map returns Result<Result<T>> — use Bind
var result = userId.Map(id => GetOrder(id)); // Double-wrapped
// Fix: Bind flattens
var result = userId.Bind(id => GetOrder(id)); // Result<Order>
Common Anti-Patterns
// TRLS007: TryCreate().Value — use Create() instead
var email = EmailAddress.TryCreate(input).Value; // Poor error message
// Fix
var email = EmailAddress.Create(input);
All Rules
| Rule | Title | Severity |
|---|---|---|
| TRLS001 | Result return value is not handled | Warning |
| TRLS002 | Use Bind instead of Map when lambda returns Result | Info |
| TRLS003 | Unsafe access to Result.Value | Warning |
| TRLS004 | Unsafe access to Result.Error | Warning |
| TRLS005 | Consider using MatchError for error type discrimination | Info |
| TRLS006 | Unsafe access to Maybe.Value | Warning |
| TRLS007 | Use Create instead of TryCreate().Value | Warning |
| TRLS008 | Result is double-wrapped (Result<Result<T>>) | Warning |
| TRLS009 | Blocking on async Result (.Result or .Wait()) | Warning |
| TRLS010 | Use specific error type instead of base Error | Info |
| TRLS011 | Maybe is double-wrapped (Maybe<Maybe<T>>) | Warning |
| TRLS012 | Consider using Result.Combine | Info |
| TRLS013 | Consider GetValueOrDefault or Match instead of ternary | Info |
| TRLS014 | Use async method variant for async lambda | Warning |
| TRLS015 | Don't throw exceptions in Result chains | Warning |
| TRLS016 | Error message should not be empty | Warning |
| TRLS017 | Don't compare Result or Maybe to null | Warning |
| TRLS018 | Unsafe access to Value in LINQ expression | Warning |
| TRLS019 | Combine chain exceeds maximum tuple size | Error |
| TRLS020 | Use SaveChangesResultAsync instead of SaveChangesAsync | Warning |
| TRLS021 | HasIndex references a Maybe<T> property | Warning |
TRLS021 recommends HasTrellisIndex(...) as the preferred fix for Maybe<T> indexes. String-based HasIndex("_backingField") remains valid as a fallback when you need to specify the mapped field explicitly.
Configuration
Suppress or adjust rules using standard .NET mechanisms:
# .editorconfig
[*.cs]
dotnet_diagnostic.TRLS003.severity = suggestion
dotnet_diagnostic.TRLS012.severity = none
Related Packages
- Trellis.Results — Core
Result<T>andMaybe<T>types - Trellis.Asp — ASP.NET Core integration
License
MIT — see LICENSE for details.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.304 | 49 | 5/29/2026 |
| 3.0.0-alpha.303 | 45 | 5/29/2026 |
| 3.0.0-alpha.158 | 96 | 4/5/2026 |
| 3.0.0-alpha.157 | 57 | 4/4/2026 |
| 3.0.0-alpha.140 | 75 | 3/30/2026 |
| 3.0.0-alpha.137 | 75 | 3/27/2026 |
| 3.0.0-alpha.135 | 54 | 3/26/2026 |
| 3.0.0-alpha.127 | 68 | 3/23/2026 |
| 3.0.0-alpha.123 | 68 | 3/19/2026 |
| 3.0.0-alpha.118 | 80 | 3/14/2026 |
| 3.0.0-alpha.111 | 67 | 3/12/2026 |
| 3.0.0-alpha.104 | 81 | 3/9/2026 |
| 3.0.0-alpha.100 | 58 | 3/4/2026 |
| 3.0.0-alpha.99 | 58 | 3/4/2026 |
| 3.0.0-alpha.98 | 57 | 3/3/2026 |
| 3.0.0-alpha.95 | 60 | 3/2/2026 |
| 3.0.0-alpha.94 | 57 | 3/2/2026 |
| 3.0.0-alpha.93 | 61 | 3/1/2026 |
| 3.0.0-alpha.92 | 82 | 2/28/2026 |
| 3.0.0-alpha.83 | 58 | 2/27/2026 |