Skip to content

Fast.Mapster ​

Public members, parameters, returns, and exceptions

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

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

Centrally managed Mapster and Mapster.DependencyInjection remain at 10.0.13; this batch updates only the Runtime package dependency.

Contract and constraints ​

AddMapster() uses TypeAdapterConfig.GlobalSettings, scans IRegister implementations from MAppContext.Assemblies, registers the configuration as a singleton and MapsterMapper.IMapper as a scoped ServiceMapper. It has no additional callback parameter. The implementation applies Flexible followed by IgnoreCase; the final naming strategy is IgnoreCase. PreserveReference(true) preserves references in mapping graphs but is not a lossless clone guarantee. Global settings can affect other Mapster consumers in the same process. Adapt, query projection and other mapping APIs follow Mapster itself; provider-specific query translation needs separate verification. Do not capture the scoped mapper in a singleton.

Installation and examples ​

Install the package ​

bash
dotnet add package Fast.Mapster

Example 1 ​

csharp
using Fast.Mapster;
using Mapster;
using MapsterMapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMapster();

var app = builder.Build();
app.MapPost("/map", (SourceModel source, IMapper mapper) => mapper.Map<TargetModel>(source));
app.Run();

public sealed class SourceModel
{
    public string Title { get; set; } = "";
}

public sealed class TargetModel
{
    public string Title { get; set; } = "";
}

public sealed class MappingProfile : IRegister
{
    public void Register(TypeAdapterConfig config)
        => config.NewConfig<SourceModel, TargetModel>();
}

public sealed class MappingService(IMapper mapper)
{
    public TargetModel Convert(SourceModel source) => mapper.Map<TargetModel>(source);
}

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 ​

Dependency alignment on 2026-11-02 ​

2026-11-02 dependency alignment: this package increments from 3.5.33 to 3.5.34, 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.30 to 3.5.31, 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.