YHG.FastBF
1.0.1
dotnet add package YHG.FastBF --version 1.0.1
NuGet\Install-Package YHG.FastBF -Version 1.0.1
<PackageReference Include="YHG.FastBF" Version="1.0.1" />
<PackageVersion Include="YHG.FastBF" Version="1.0.1" />
<PackageReference Include="YHG.FastBF" />
paket add YHG.FastBF --version 1.0.1
#r "nuget: YHG.FastBF, 1.0.1"
#:package YHG.FastBF@1.0.1
#addin nuget:?package=YHG.FastBF&version=1.0.1
#tool nuget:?package=YHG.FastBF&version=1.0.1
YHG.FastBF
A high-performance, zero-dependency [MS-NRBF] (BinaryFormatter) serialization and deserialization engine for modern .NET.
Overview
Starting with .NET 8 and .NET 9, Microsoft marked BinaryFormatter obsolete and completely disabled it by default due to critical remote code execution (RCE) attack vectors.
YHG.FastBF provides a secure, standalone replacement designed to read and write the official Microsoft .NET Remoting Binary Format ([MS-NRBF]) specification. It allows modern applications to serialize and hydrate binary streams, Unity asset structures, and legacy save containers without relying on deprecated framework APIs.
Features
- Protocol Compliant: Fully implements major wire tags of the
[MS-NRBF]specification. - Native AOT & Trimming Ready: Fully annotated with
[DynamicallyAccessedMembers]to preserve metadata during IL trimming; executes reliably under Native AOT environments. - High Throughput: Dynamic compiled
Expressiontrees replace slow runtime reflection with fast member extractors, utilizing internal interpreted execution fallback on Native AOT targets. - Cross-Framework Interoperability: Automatically aliases modern
System.Private.CoreLibtypes to legacymscorlib, Version=4.0.0.0for backward compatibility with Unity and .NET Framework. - Graph Resolution: Multi-pass object tracking resolves circular references and shared object instances safely.
- Dictionary & Collection Hydration: Native support for generic dictionaries, key-value pair arrays, and primitive lists.
- Zero External Dependencies: Pure managed code running seamlessly across
AnyCPU(x86, x64, ARM64).
Installation
.NET CLI
dotnet add package YHG.FastBF
Package Manager
Install-Package YHG.FastBF
Quick Start
1. Model Definition
You can map legacy or custom property names using attributes:
using System.Collections.Generic;
using YHG.FastBF.Attributes;
[BfType("GameData.PlayerProfile", "Assembly-CSharp")]
public class PlayerProfile : IBfDeserialized
{
[BfProperty("player_level")]
public int Level { get; set; }
public string PlayerName { get; set; } = string.Empty;
public Dictionary<string, int> Inventory { get; set; } = new();
[BfIgnore]
public int EphemeralCache { get; set; }
public void OnDeserialized()
{
// Executed immediately after hydration completes
}
}
2. Writing (Serialization)
using System.IO;
using System.Collections.Generic;
using YHG.FastBF.Binary;
var profile = new PlayerProfile
{
Level = 50,
PlayerName = "Commander",
Inventory = new Dictionary<string, int>
{
{ "HealthPotion", 10 },
{ "GoldCoins", 2500 }
}
};
using (var stream = File.Create("savedata.bin"))
using (var writer = new BfWriter(stream))
{
writer.WriteRootClass(profile);
}
3. Reading (Deserialization)
using System;
using System.IO;
using YHG.FastBF.Binary;
using (var stream = File.OpenRead("savedata.bin"))
using (var reader = new BfReader(stream))
{
PlayerProfile profile = reader.ReadRootClass<PlayerProfile>();
Console.WriteLine($"Loaded: {profile.PlayerName} (Level {profile.Level})");
}
Supported [MS-NRBF] Records
| Tag | Record Name | Status |
|---|---|---|
0x00 |
SerializedStreamHeader |
Supported |
0x01 |
ClassWithId |
Supported |
0x04 |
SystemClassWithMembers |
Supported |
0x05 |
ClassWithMembersAndTypes |
Supported |
0x06 |
BinaryObjectString |
Supported |
0x07 |
BinaryArray |
Supported |
0x08 |
MemberPrimitiveTyped |
Supported |
0x09 |
MemberReference |
Supported |
0x0A |
ObjectNull |
Supported |
0x0B |
MessageEnd |
Supported |
0x0C |
BinaryLibrary |
Supported |
0x0D |
ObjectNullMultiple256 |
Supported |
0x0E |
ObjectNullMultiple |
Supported |
0x0F |
ArraySinglePrimitive |
Supported |
0x10 |
ArraySingleObject |
Supported |
0x11 |
ArraySingleString |
Supported |
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.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.