Fast.Runtime
Public members, parameters, returns, and exceptions
Reference source version 3.5.37; targets: net8.0;net9.0;net10.0.
Contract and constraints
Shared configuration, assembly discovery, MVC extensions, validation attributes and application context. This package is normally referenced transitively by the web modules; it does not start a host. Configuration registration returns the original IServiceCollection. Options validation and post-configuration exceptions propagate. MAppContext request data is only available when a request exists. LocalIpv4/LocalIpv6 read the server connection address; RemoteIpv4/RemoteIpv6 read Connection.RemoteIpAddress. The old LanIpv4/LanIpv6 members are no longer part of this API.
Installation and examples
Install the package
dotnet add package Fast.RuntimeExample 1
using Fast.Runtime;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddConfigurableOptions<FeatureOptions>("Feature");
var app = builder.Build();
app.MapGet("/feature", (Microsoft.Extensions.Options.IOptions<FeatureOptions> options) => options.Value.BatchSize);
app.Run();
public sealed class FeatureOptions : IPostConfigure
{
public int? BatchSize { get; set; }
public void PostConfigure() => BatchSize ??= 50;
}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
Background scope ownership
Outside HTTP requests, helpers no longer allocate hidden scopes or dispose background services when an unrelated request ends. A background operation must own CreateScope/CreateAsyncScope and dispose it after that operation; pass the scoped provider explicitly. Only registered singletons may use the root provider. Explicit UnmanagedObjects belong to application lifetime, not request cleanup.
IRefreshTokenReplayStore.TryConsumeAsync(key, expiresAt, reuseLeewaySeconds, cancellationToken) grants atomic replay consumption. The key is a purpose-prefixed digest and expiry is absolute. MemoryRefreshTokenReplayStore is process-local and must not impersonate an atomic shared backend.
IPv4 lookup cancellation and upgrade compatibility
RemoteIpv4InfoAsync(this HttpContext httpContext, string ip = null, CancellationToken? cancellationToken = null) accepts cancellation through its third parameter. Fast.Runtime 3.5.33 returns a request-local result from HttpContext.Items before resolving or checking the token, so that cache hit can return even when the default or explicit token is already cancelled. A request-local miss checks cancellation before accessing shared memory cache, waiting for a lock or issuing a remote request; a shared memory-cache hit still requires that cancellation check. Omitting the token or passing null uses HttpContext.RequestAborted; an explicit token replaces that default without linking both tokens. A null context still returns null.
Starting with Fast.Runtime 3.5.32, this three-parameter method replaced the old two-parameter declaration. Version 3.5.33 retains that public signature and changes only the cache/cancellation-check order. Ordinary direct calls can still omit the new argument after recompilation, but existing consumer assemblies must be rebuilt rather than only replacing the Runtime DLL. Review method-group delegates, reflection lookups and dynamic calls that depend on the old signature. This compatibility change follows the requested 3.5.x patch cadence.
The 2026-10-17 update synchronized source documentation and versions only. No Fast.NET build, pack or tests were run for that batch, as requested; preceding batch validation does not validate it.
3.5.37 mobile H5 and numeric migration
On 2026-11-02, Fast.Runtime increments from 3.5.36 to 3.5.37, adding H5 = 1L << 4 (16) for mobile H5 pages, separately from the Web platform flag. Android and every following independent flag shift left one bit. All 25 members use contiguous, non-overlapping bits 0 through 24. The enum retains long and [Flags]; the four former composite declarations remain removed. Runtime and its 13 referencing packages each increment one patch version; see the batch version table.
This is a breaking numeric-contract change on the requested 3.5.x patch cadence. Web=1, Windows=2, Mac=4 and Linux=8 remain unchanged. The mapping below uses 3.5.36 as its baseline:
| Member | 3.5.36 | 3.5.37 | New bit value |
|---|---|---|---|
| H5 | New | 16 | 1L << 4 |
| Android | 16 | 32 | 1L << 5 |
| HarmonyOS | 32 | 64 | 1L << 6 |
| IOS | 64 | 128 | 1L << 7 |
| QuickApp | 128 | 256 | 1L << 8 |
| WeChatMiniProgram | 256 | 512 | 1L << 9 |
| WeChatOfficialAccount | 512 | 1024 | 1L << 10 |
| WeChatServiceAccount | 1024 | 2048 | 1L << 11 |
| WeChatOpenPlatform | 2048 | 4096 | 1L << 12 |
| WorkWeChat | 4096 | 8192 | 1L << 13 |
| AlipayMiniProgram | 8192 | 16384 | 1L << 14 |
| TiktokMiniProgram | 16384 | 32768 | 1L << 15 |
| DingTalkMiniProgram | 32768 | 65536 | 1L << 16 |
| FeiShuMiniProgram | 65536 | 131072 | 1L << 17 |
| QQMiniProgram | 131072 | 262144 | 1L << 18 |
| BaiduMiniProgram | 262144 | 524288 | 1L << 19 |
| KuaiShouMiniProgram | 524288 | 1048576 | 1L << 20 |
| XiaoHongShuMiniProgram | 1048576 | 2097152 | 1L << 21 |
| JDMiniProgram | 2097152 | 4194304 | 1L << 22 |
| Api | 4194304 | 8388608 | 1L << 23 |
| Other | 8388608 | 16777216 | 1L << 24 |
Migrate old database, cache, configuration and numeric protocol values by their original member meanings, then recombine flags. Do not double entire masks: Web through Linux remain unchanged while Android and later bits shift left. Old Android=16 now means H5. A mixed Web | Android | Api mask changes from 4194321 to 8388641. For earlier versions, identify the source meaning through the corresponding historical migration first.
Migrating old masks does not automatically include the new H5 platform. This caller-owned example separates native mobile platforms from a scope that includes H5:
using System;
const AppEnvironmentEnum nativeMobile =
AppEnvironmentEnum.Android | AppEnvironmentEnum.HarmonyOS | AppEnvironmentEnum.IOS;
const AppEnvironmentEnum mobileWithH5 = nativeMobile | AppEnvironmentEnum.H5;
Console.WriteLine(mobileWithH5.HasFlag(AppEnvironmentEnum.H5));The native mobile mask changes from 112 to 224; explicitly including H5 produces 240. The old mini-program scope changes from 4186496 to 8372992, and native-mobile-plus-mini-program scope changes from 4186608 to 8373216. The former Desktop scope remains 14. These are caller-owned masks, without restoring the four removed SDK composite members.
Regenerate client enums and rebuild consumers. Constants can be inlined, so replacing a DLL alone cannot update existing numbers. String names still identify existing members, but numeric values, masks and generated enum mappings must be updated together. Validation passed on 2026-11-02: final full-solution restore, Release build and local packaging completed without warnings or errors after permitted network retry resolved the initial NU1900 access warnings. Verified 84 DLL/XML files, 42 assembly versions and 45 internal dependencies across 14 affected packages; all three Runtime XML files include H5 documentation and its Web reference. Both exact examples compiled for all targets; packaged Runtime assemblies each passed 290 value, uniqueness, scope, JSON round-trip and mixed-mask assertions on .NET 8/9/10. All 42 bilingual migration rows match the previous/current source. Runtime declarations increase from 261 to 262. Fast.Docs full checks passed, including 34 tests passed/1 Nginx test skipped because Nginx is unavailable, links across 434 pages, and formatting. No database migration, application host or live external service operation was performed.
3.5.36 composite-member removal and migration
This section records historical 3.5.36 behavior and values; see the preceding section for 3.5.37 H5 shifts and current masks.
On 2026-10-31, Fast.Runtime increments from 3.5.35 to 3.5.36 and removes Desktop, Mobile, MiniProgram and MobileThree. The enum retains long, [Flags] and all 24 independent numeric values from 3.5.35, using contiguous bits 0 through 23. Removing public members is a breaking API change despite the requested patch cadence. Its 13 referencing packages also increment; see the batch version table.
Replace source references to removed members with caller-owned bitwise-OR masks. This example preserves their original membership:
using System;
const AppEnvironmentEnum desktop =
AppEnvironmentEnum.Windows | AppEnvironmentEnum.Mac | AppEnvironmentEnum.Linux;
const AppEnvironmentEnum mobile =
AppEnvironmentEnum.Android | AppEnvironmentEnum.HarmonyOS | AppEnvironmentEnum.IOS;
const AppEnvironmentEnum miniProgram =
AppEnvironmentEnum.QuickApp
| AppEnvironmentEnum.WeChatMiniProgram
| AppEnvironmentEnum.AlipayMiniProgram
| AppEnvironmentEnum.TiktokMiniProgram
| AppEnvironmentEnum.DingTalkMiniProgram
| AppEnvironmentEnum.FeiShuMiniProgram
| AppEnvironmentEnum.QQMiniProgram
| AppEnvironmentEnum.BaiduMiniProgram
| AppEnvironmentEnum.KuaiShouMiniProgram
| AppEnvironmentEnum.XiaoHongShuMiniProgram
| AppEnvironmentEnum.JDMiniProgram;
const AppEnvironmentEnum mobileThree = mobile | miniProgram;
Console.WriteLine(mobileThree.HasFlag(AppEnvironmentEnum.Android));| Former member | Caller-owned combination | Preserved value |
|---|---|---|
| Desktop | Windows, Mac, Linux | 14 |
| Mobile | Android, HarmonyOS, IOS | 112 |
| MiniProgram | The 11 independent quick-app/mini-program flags in the example | 4186496 |
| MobileThree | Bitwise OR of mobile and miniProgram | 4186608 |
Numeric masks persisted with 3.5.35 do not require renumbering. Upgrades from earlier versions must still follow the historical mapping below. Removing combination declarations does not invalidate their numeric bit patterns.
Regenerate client enums and replace source references to the four former members. Constants can be inlined in existing assemblies, so previously compiled numeric constants may continue working without preserving their former declaration names. Review Enum.Parse, string enum serialization, ToString, reflection, selection lists and protocols that use enum names: removed names are no longer declared, and composite values may display constituent names instead. The example preserves the original scope without adding platforms.
On 2026-10-31, review confirmed the API inventory decreases from 265 to 261 declarations by removing exactly these four members. Final full-solution restore, Release build and local packaging passed without warnings or errors; initial NU1900 network failures were resolved by a permitted network retry. Both guides contain the same example, compiled for all three targets. Each packaged Runtime assembly passed 182 independent-value, name-parsing, mask-membership and JSON string round-trip assertions on .NET 8/9/10. Fast.Docs full checks passed, including 34 tests passed/1 Nginx test skipped because Nginx is unavailable, links across 434 pages, and formatting. No database migration, application host, live external service or publication operation was performed.
HarmonyOS and enum-value migration
System.AppEnvironmentEnum is a long enum marked with [Flags]. Version 3.5.34 added HarmonyOS = 64 and shifted the former IOS and later independent flags left one bit; Android remained 32 and gaps remained between flags. The migration below uses 3.5.34 as its baseline and must not be applied directly to earlier data versions.
On 2026-10-30, Fast.Runtime increments from 3.5.34 to 3.5.35, assigning all 24 independent flags continuously to bits 0 through 23 in declaration order. Android starts at 1L << 4, followed consecutively by all remaining members, including Api and Other. All 13 packages referencing Runtime also increment one patch version, while external dependency versions remain unchanged; see the dependency version table. The requested 3.5.x patch cadence is retained despite this breaking numeric-contract change.
Web=1, Windows=2, Mac=4 and Linux=8 remain unchanged. Migrate the other independent members as follows:
| Member | 3.5.34 | 3.5.35 | New bit value |
|---|---|---|---|
| Android | 32 | 16 | 1L << 4 |
| HarmonyOS | 64 | 32 | 1L << 5 |
| IOS | 128 | 64 | 1L << 6 |
| QuickApp | 256 | 128 | 1L << 7 |
| WeChatMiniProgram | 512 | 256 | 1L << 8 |
| WeChatOfficialAccount | 1024 | 512 | 1L << 9 |
| WeChatServiceAccount | 2048 | 1024 | 1L << 10 |
| WeChatOpenPlatform | 4096 | 2048 | 1L << 11 |
| WorkWeChat | 8192 | 4096 | 1L << 12 |
| AlipayMiniProgram | 16384 | 8192 | 1L << 13 |
| TiktokMiniProgram | 32768 | 16384 | 1L << 14 |
| DingTalkMiniProgram | 65536 | 32768 | 1L << 15 |
| FeiShuMiniProgram | 131072 | 65536 | 1L << 16 |
| QQMiniProgram | 262144 | 131072 | 1L << 17 |
| BaiduMiniProgram | 524288 | 262144 | 1L << 18 |
| KuaiShouMiniProgram | 1048576 | 524288 | 1L << 19 |
| XiaoHongShuMiniProgram | 2097152 | 1048576 | 1L << 20 |
| JDMiniProgram | 4194304 | 2097152 | 1L << 21 |
| Api | 4294967296 | 4194304 | 1L << 22 |
| Other | 8589934592 | 8388608 | 1L << 23 |
The following table records historical 3.5.35 composite declarations; 3.5.36 removes those declarations while retaining the corresponding numeric bit patterns:
| Composite member | 3.5.34 | 3.5.35 |
|---|---|---|
| Desktop | 14 | 14 |
| Mobile | 224 | 112 |
| MiniProgram | 8372992 | 4186496 |
| MobileThree | 8373216 | 4186608 |
Before migrating database, cache, configuration or numeric protocol values, identify their source version, map each old flag by member meaning and recombine it. Do not shift entire masks: Web through Linux stay unchanged and Api/Other move by a different offset. For example, Android=32 from 3.5.34 now means HarmonyOS. A Mobile=96 mask from 3.5.33 becomes 80 when preserving its Android/IOS scope; use the three-platform mask 112 only when intentionally adding HarmonyOS; the Mobile declaration is removed in 3.5.36.
Recompile dependent assemblies and regenerate client enums. Constants can be embedded in consumers, so replacing the Runtime DLL alone is insufficient. This update changes platform identifiers only; it does not implement HarmonyOS package upload, installation or hot updates, and it does not run database migrations. On 2026-10-30, Release builds and local packaging passed for net8.0/net9.0/net10.0 without warnings or errors. Package identity and per-target DLL/XML contents were checked; the packaged assemblies each passed 131 numeric, composite-membership and mixed-mask assertions on their corresponding runtimes. All 40 bilingual migration rows match the previous and current source. Fast.Docs pnpm run check passed: typecheck, lint, 34 documentation tests passed/1 Nginx test skipped because Nginx is unavailable, API coverage, site build, links/assets/anchors across 434 HTML pages, and formatting. No application host, device verification, database operation or NuGet publication was performed.
