Skip to content

Releases: ANcpLua/ErrorOrX

v3.5.0

08 Feb 00:28

Choose a tag to compare

What's Changed

Bug Fix: Endpoints Invisible to OpenAPI/Swagger (#25)

All ErrorOrX-generated endpoints were invisible to ASP.NET Core's OpenAPI document generator — "paths": {} was empty despite endpoints working at runtime.

Root cause: The wrapper method Invoke_EpN(HttpContext ctx) returned Task, which matches the RequestDelegate signature (Func<HttpContext, Task>). ASP.NET Core's MapGet silently picked the RequestDelegate overload, bypassing RequestDelegateFactory — making endpoints invisible to OpenAPI.

Three-part fix:

Fix What Why
Typed return Wrapper returns Task<Results<Ok<T>, ...>> instead of Task Breaks RequestDelegate match, forces Delegate overload
(Delegate) cast Explicit cast on all MapGet/MapPost calls Safety net — forces Delegate overload regardless of signature
Explicit metadata Always emit ProducesResponseTypeMetadata Full response schemas in OpenAPI even without Results<...>

New: OpenAPI Parameter Definitions

When using AddErrorOrOpenApi(), the generated operation transformer now emits full OpenAPI parameter definitions for route, query, and header parameters — including types, formats, and required flags.

Two-tier support:

Setup What You Get
AddOpenApi() (existing) Endpoint visibility + response schemas
AddErrorOrOpenApi() Above + parameter definitions + XML doc summaries

Other Changes

  • Updated README examples from int id to Guid id with route constraints

Upgrade

dotnet add package ErrorOrX.Generators --version 3.5.0

For full OpenAPI parameter support, use AddErrorOrOpenApi() instead of AddOpenApi():

builder.Services
    .AddErrorOrOpenApi()        // instead of AddOpenApi()
    .AddErrorOrEndpoints()
    .UseJsonContext<AppJsonSerializerContext>();

Full Changelog: v3.4.0...v3.5.0

v3.4.0

07 Feb 21:40
569c0bf

Choose a tag to compare

What's Changed

Fixed

  • Unreachable switch arm in Extractor.cs: ReturnsError(ErrorType, string) was always falling into the custom error path instead of mapping standard ErrorType enum values. Fixed by checking TypeKind.Enum on args[0].Type to distinguish enum from raw int.

  • Integration tests missing from solution: Added ErrorOrX.Integration.Tests to ErrorOrX.slnx — 9 tests were not running in CI.

  • Documentation accuracy: Removed phantom EOE055 from CHANGELOG (EOE032 covers it), fixed README analyzer count (38 → 41), corrected CLAUDE.md dependency versions.

Changed

  • Test suite cleanup: Removed redundant assertion-based tests (-7,823 lines), consolidated shared boilerplate into dedicated snapshot tests. 455 tests pass with identical coverage.

  • Updated dependencies:

    • ANcpLua.Roslyn.Utilities 1.28.0 → 1.31.0
    • ANcpLua.Roslyn.Utilities.Testing 1.28.0 → 1.31.0
    • ANcpLua.NET.Sdk 2.0.4 → 2.0.5
    • Verify.XunitV3 31.9.4 → 31.10.0
  • Generator code cleanup: Removed unused ParameterSource properties, simplified constructor signatures, added documentation comments for suppressed warnings.

Verification

  • Build: 0 warnings, 0 errors
  • Tests: 455 passed (446 generator/runtime + 9 integration), 0 failed
  • 12-agent parallel audit: architecture, security, API contracts all clean

v3.1.0 - API Versioning & Performance

29 Jan 04:10

Choose a tag to compare

What's New

Features

  • API Versioning Support: Full support for [ApiVersion], [ApiVersionNeutral], and [MapToApiVersion] attributes
  • New Diagnostics: EOE050-054 for versioning validation

Performance

  • N+1 Fix: ErrorOrContext is now created once per compilation instead of N times, eliminating 90+ symbol lookups per endpoint

Test Coverage

  • 149 comprehensive tests across:
    • DiagnosticTests (39 tests) - EOE003-EOE040
    • MiddlewareEmissionTests (23 tests) - Security-critical attribute handling
    • ApiVersioningTests (17 tests) - Versioning emission and diagnostics
    • ParameterBindingTests (36 tests) - Smart binding inference
    • BugRegressionTests (5 tests) - Previously fixed issues

Documentation

  • New docs/api-versioning.md with complete usage guide
  • Updated docs/diagnostics.md with new codes

v3.0.1 - PrivateAssets Hotfix

25 Jan 19:17

Choose a tag to compare

🐛 Hotfix

This release fixes the critical package installation issue discovered after v3.0.0 where users had to manually edit .csproj after installing ErrorOrX.Generators.

Fixed

  • Package installation issue: Removed developmentDependency=true from .nuspec to prevent NuGet from automatically adding PrivateAssets=all
  • Added MSBuild target in .props that explicitly adds ErrorOrX reference with PrivateAssets=none
  • Users no longer need manual .csproj editing - ErrorOrX runtime flows automatically

Installation

dotnet add package ErrorOrX.Generators --version 3.0.1

The ErrorOrX runtime will now automatically flow to your project without any manual configuration!

Packages

Full Changelog: v3.0.0...v3.0.1

v3.0.0 - Major Refactoring Release

25 Jan 19:16

Choose a tag to compare

What's Changed

🐛 Fixed

Critical: Package Installation Issue

  • Removed developmentDependency=true from .nuspec to prevent NuGet from adding PrivateAssets=all automatically
  • Added MSBuild target that ensures ErrorOrX runtime flows to consuming projects
  • Users no longer need to manually edit .csproj after installing ErrorOrX.Generators

🔧 Refactoring

  • Consolidated type unwrapping logic: Unified duplicate UnwrapNullableType implementations
  • Consolidated route parameter lookup: Merged BuildMethodParamsByRouteName and BuildRouteMethodParameterLookup
  • Decomposed EmitInvoker method: Split 95-line method into focused single-responsibility methods
  • Removed Match API dependency: Generated code now uses minimal ErrorOr<T> interface (IsError/Errors/Value)

🧹 Maintenance

  • Test analyzer cleanups: Sealed test helper records, added shared Unreachable helper
  • Fixed ModuleInitializer.cs: Added missing using VerifyTests; directive
  • Removed unnecessary reflection: Simplified EquatableArrayJsonConverter
  • Fixed README links: Documentation links now point to GitHub URLs

📦 Packages

Installation

dotnet add package ErrorOrX.Generators --version 3.0.0

No manual .csproj editing required! The ErrorOrX runtime will now automatically flow to your project.

Full Changelog: v2.6.3...v3.0.0

v2.5.0

14 Jan 01:03

Choose a tag to compare

What's New

New Or* Extensions

  • OrUnexpected(description) - Returns Unexpected error (500) if null
  • OrError(Error error) - Returns custom error if null
  • OrError(Func<Error> factory) - Lazy custom error creation

Struct Overloads

Added missing struct overloads for nullable value types:

  • OrUnauthorized<T> where T : struct
  • OrForbidden<T> where T : struct
  • OrConflict<T> where T : struct
  • OrFailure<T> where T : struct

Documentation

  • Updated README with comprehensive API documentation
  • Improved NuGet package descriptions and tags

Usage

// New extensions
value.OrUnexpected("Something went wrong");
value.OrError(Error.Custom(422, "Custom.Code", "Custom message"));
value.OrError(() => BuildExpensiveError());

// Struct support
int? maybeId = GetId();
return maybeId.OrNotFound("ID not found");

Full Changelog: v2.4.0...v2.5.0

v2.3.1

13 Jan 02:28

Choose a tag to compare

Documentation

  • Streamlined README for NuGet package
  • Added docs/ folder with detailed documentation:
    • docs/api.md - Full API reference
    • docs/parameter-binding.md - Parameter binding details
    • docs/diagnostics.md - Analyzer warnings and errors

Full Changelog: v2.3.0...v2.3.1

v2.3.0 - Smart Parameter Binding & Caching Fixes

13 Jan 01:56

Choose a tag to compare

Breaking Changes

  • Smart parameter binding inference: POST/PUT/PATCH with complex types now infer [FromBody], GET/DELETE with complex types now emit EOE025 error requiring explicit binding
  • Use <ErrorOrLegacyParameterBinding>true</ErrorOrLegacyParameterBinding> MSBuild property to opt-out

Features

  • EOE025: New diagnostic for ambiguous parameter binding on GET/DELETE with complex types
  • EOE040: Warning when user's JsonSerializerContext lacks CamelCase policy
  • JSON context auto-detection: When user has existing context, emits helper file with missing types
  • PrivateAssets fix: ErrorOrX runtime now correctly flows to consuming projects

Fixes

  • Incremental caching: Removed CompilationProvider usage that broke generator caching
  • ErrorOrContext: Now created lazily from SemanticModel to avoid caching INamedTypeSymbol
  • Results max arity: Hardcoded to 6 (ASP.NET Core 8+ supports Results\6`)

Improvements

  • Comprehensive XML documentation across all generator types
  • Model consolidation: all record structs in EndpointModels.cs
  • Dead code removal and naming consistency
  • New GeneratorCachingTests to validate incremental caching

Full Changelog

v2.2.0...v2.3.0