Skip to content

Fast.UnifyResult ​

Public members, parameters, returns, and exceptions

Reference source version 3.5.41; targets: net8.0;net9.0;net10.0.

When upgrading code that uses platform flags, see the Runtime H5 migration guide and the dependency history.

Contract and constraints ​

MVC response wrapping, model validation and friendly exceptions. AddUnifyResult() includes AddDataValidation() and AddFriendlyException(), enables result handling and registers response filters/status middleware. It does not automatically wrap arbitrary Minimal API results. Validation suppresses the native invalid-model filter and implicit Required for non-nullable references; explicitly annotate required inputs. RestfulResult<T> contains Success, nullable Code, Message, Data and Timestamp. Code is a body field, not necessarily the HTTP status. Discovered providers can change the response protocol. Providers and global exception handlers are singletons and must not hold request state. NonUnifyAttribute and NonValidationAttribute opt out of their respective flows. Return business objects from controllers and avoid wrapping the same result twice.

Installation and examples ​

Install the package ​

bash
dotnet add package Fast.UnifyResult

Example 1 ​

csharp
using Fast.UnifyResult;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddUnifyResult();

var app = builder.Build();
app.MapControllers();
app.Run();

Example 2 ​

csharp
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/notes")]
public sealed class NotesController : ControllerBase
{
    [HttpPost]
    public NoteOutput Preview([FromBody] NoteInput input) => new(input.Title.Trim());
}

public sealed class NoteInput
{
    [Required, StringLength(80, MinimumLength = 1)]
    public string Title { get; set; } = "";
}

public sealed record NoteOutput(string Title);

Web-host examples belong in a consumer project using Microsoft.NET.Sdk.Web and a supported .NET target. IaaS examples can be used in an ordinary class library. Registration precedes builder.Build(); configure middleware and endpoints before app.Run(). Samples retain their original code and comments. No host, external service, database operation or client generator was run, and these snippets have not been compiled in this update.

Source reference ​

Authentication status fix: preserve the final HTTP 401/403 without token-header-based conversion; never rewrite started responses or duplicate the body.

Request cancellation exceptions ​

Since Fast.UnifyResult 3.5.36, the implementation exits the friendly-exception filter when the exception is OperationCanceledException and HttpContext.RequestAborted is cancelled. It does not create a normal business-error or 500 response or mark the exception handled; the upper pipeline controls further handling. An OperationCanceledException without request cancellation still follows the existing exception flow.

Dependency alignment on 2026-11-02 ​

2026-11-02 dependency alignment: this package increments from 3.5.40 to 3.5.41, updating its dependency to Fast.Runtime 3.5.37. This module's implementation and public declarations are unchanged. Runtime adds mobile H5 and shifts Android and subsequent flags; migrate numeric protocols/masks, rebuild consumers and regenerate client enums. See the Runtime H5 migration guide.

2026-10-24 versions and dependencies ​

On 2026-10-24, this package increments from 3.5.37 to 3.5.38, with dependencies updated to Fast.Runtime 3.5.34. This module's own implementation and public declarations are unchanged.

Consumers using AppEnvironmentEnum must migrate numeric values and rebuild according to the Runtime HarmonyOS migration guide. This batch reviewed source and effective MSBuild package metadata only. Tests were skipped as requested; no restore, build, pack or consumer runtime validation was performed.