EonaCat.FastBin 1.0.0

Prefix Reserved
dotnet add package EonaCat.FastBin --version 1.0.0
                    
NuGet\Install-Package EonaCat.FastBin -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EonaCat.FastBin" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EonaCat.FastBin" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EonaCat.FastBin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EonaCat.FastBin --version 1.0.0
                    
#r "nuget: EonaCat.FastBin, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EonaCat.FastBin@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EonaCat.FastBin&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EonaCat.FastBin&version=1.0.0
                    
Install as a Cake Tool

EonaCat.FastBin

A blazingly fast, enterprise-grade binary serialization library for .NET with built-in networking capabilities.

๐Ÿš€ Features

  • โšก Ultra-fast - Binary format optimized for speed, outperforms JSON and MessagePack
  • ๐Ÿ”„ Complete object graph support - Handles nested objects, circular references, and polymorphism
  • ๐Ÿ“ฆ Zero configuration - Works with any type out of the box
  • ๐ŸŒ Built-in networking - TCP client/server with RPC support included
  • ๐ŸŽฏ Type-safe - Strongly-typed API with full generic support
  • ๐Ÿ”’ Thread-safe - Safe for concurrent serialization/deserialization
  • ๐Ÿ“ฑ Cross-platform - .NET Standard 2.1 compatible

๐Ÿ“Š Performance

EonaCat.FastBin uses several optimization techniques to achieve superior performance:

  • Binary format - No text parsing overhead
  • 7-bit integer encoding - Compact representation of small numbers
  • Type caching - Reflection performed only once per type
  • Reference tracking - Objects serialized once, referenced thereafter
  • Zero-copy operations - Direct memory access where possible

๐ŸŽฏ Quick Start

Basic Serialization

using EonaCat.FastBin;

// Serialize any object
var user = new User { Id = 1, Name = "Brasser", Email = "brasser@example.com" };
byte[] data = EonaCat.FastBin.Serialize(user);

// Deserialize back
var restored = EonaCat.FastBin.Deserialize<User>(data);

Complex Objects

// Works with nested objects
var order = new Order
{
    OrderId = Guid.NewGuid(),
    TotalAmount = 299.99m,
    Items = new List<OrderItem>
    {
        new OrderItem { ProductName = "Laptop", Quantity = 1, Price = 299.99m }
    }
};

byte[] data = EonaCat.FastBin.Serialize(order);
var restored = EonaCat.FastBin.Deserialize<Order>(data);

Collections

// Lists
var users = new List<User> { user1, user2, user3 };
byte[] data = EonaCat.FastBin.Serialize(users);

// Dictionaries
var userMap = new Dictionary<int, User> 
{
    [1] = user1,
    [2] = user2
};
byte[] data2 = EonaCat.FastBin.Serialize(userMap);

// Arrays
var userArray = new User[] { user1, user2 };
byte[] data3 = EonaCat.FastBin.Serialize(userArray);

Circular References

// Self-referencing objects work automatically
var manager = new User { Id = 1, Name = "Manager" };
var employee = new User { Id = 2, Name = "Brasser", Manager = manager };
manager.Manager = manager; // Circular reference

byte[] data = EonaCat.FastBin.Serialize(employee);
var restored = EonaCat.FastBin.Deserialize<User>(data);

// Reference integrity maintained
Console.WriteLine(ReferenceEquals(restored.Manager, restored.Manager.Manager)); // True

Polymorphism

// Handles polymorphic types automatically
object[] items = new object[]
{
    "A string",
    42,
    new User { Id = 1, Name = "Brasser" },
    new Order { OrderId = Guid.NewGuid() }
};

byte[] data = EonaCat.FastBin.Serialize(items);
var restored = EonaCat.FastBin.Deserialize<object[]>(data);

// Types preserved correctly
Console.WriteLine(restored[0].GetType()); // System.String
Console.WriteLine(restored[2].GetType()); // User

๐ŸŒ Networking

Server Setup

var server = new FastServer();

// Register handlers
server.RegisterHandler<GetUserRequest, User>("GetUser", request =>
{
    // Your business logic here
    return database.GetUser(request.UserId);
});

server.RegisterHandler<CreateOrderRequest, CreateOrderResponse>("CreateOrder", async request =>
{
    // Async handlers supported
    var order = await orderService.CreateOrderAsync(request);
    return new CreateOrderResponse { OrderId = order.Id, Message = "Success" };
});

// Start server
await server.StartAsync(5000);

Client Usage

using (var client = new FastClient())
{
    await client.ConnectAsync("localhost", 5000);
    
    // Make RPC calls
    var user = await client.CallAsync<GetUserRequest, User>(
        "GetUser",
        new GetUserRequest { UserId = 123 }
    );
    
    var response = await client.CallAsync<CreateOrderRequest, CreateOrderResponse>(
        "CreateOrder",
        new CreateOrderRequest 
        { 
            UserId = 123,
            Items = orderItems 
        }
    );
}

๐Ÿ“‹ Supported Types

Primitives

  • All numeric types: byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal
  • bool, char, string
  • DateTime, Guid
  • Enums

Collections

  • Arrays: T[]
  • Lists: List<T>, IList, IList<T>
  • Dictionaries: Dictionary<K,V>, IDictionary, IDictionary<K,V>

Complex Types

  • Classes (public and non-public fields)
  • Structs
  • Nested objects
  • Generic types
  • Polymorphic types
  • Self-referencing objects
  • Circular references

๐Ÿ”ง Advanced Usage

Custom Domain Models

public class Customer
{
    public int Id;
    public string Name;
    public string Email;
    public DateTime CreatedAt;
    public Address ShippingAddress;
    public List<Order> Orders;
    public Customer ReferredBy; // Self-reference supported
}

public class Address
{
    public string Street;
    public string City;
    public string ZipCode;
    public string Country;
}

No attributes or special configuration needed - just define your classes normally!

Error Handling (Networking)

try
{
    var result = await client.CallAsync<Request, Response>("Route", request);
}
catch (Exception ex)
{
    // Handle network errors, deserialization errors, or handler exceptions
    Console.WriteLine($"RPC failed: {ex.Message}");
}

Server Shutdown

// Graceful shutdown
server.Stop();

๐Ÿ—๏ธ Architecture

Binary Format

EonaCat.FastBin uses a compact binary format with the following features:

  1. Type markers - Single byte to identify data type
  2. 7-bit encoding - Variable-length integers for efficiency
  3. Reference tracking - Objects assigned IDs, referenced by ID on subsequent encounters
  4. Type polymorphism - Actual type stored when different from declared type
  5. Field ordering - Consistent ordering by name for versioning

Networking Protocol

  1. Message framing - 4-byte length prefix
  2. Request/Response - Structured messages with route and data
  3. Error handling - Exceptions marshaled back to client
  4. Type safety - Generic request/response types

โš ๏ธ Limitations & Considerations

  • Private fields - Serializes all fields (public and private)
  • Properties - Only backing fields are serialized
  • Versioning - Adding/removing fields requires redeployment (no built-in versioning)
  • Security - No encryption built-in (use TLS/SSL at transport layer)
  • Large objects - Keep network messages under 2GB (int.MaxValue)

๐Ÿงช Testing

The included example application demonstrates:

  1. โœ… Basic serialization of primitives and collections
  2. โœ… Complex nested object graphs
  3. โœ… Self-referencing and circular references
  4. โœ… Polymorphic type handling
  5. โœ… Client-server RPC communication

๐Ÿ”„ Migration Guide

From JSON.NET

// Before (JSON.NET)
string json = JsonConvert.SerializeObject(obj);
var restored = JsonConvert.DeserializeObject<T>(json);

// After (EonaCat.FastBin)
byte[] data = FastBin.Serialize(obj);
var restored = FastBin.Deserialize<T>(data);

From MessagePack

// Before (MessagePack)
byte[] data = MessagePackSerializer.Serialize(obj);
var restored = MessagePackSerializer.Deserialize<T>(data);

// After (EonaCat.FastBin) - Same API!
byte[] data = FastBin.Serialize(obj);
var restored = FastBin.Deserialize<T>(data);

๐Ÿ“ Best Practices

  1. Reuse clients - Create one FastClient per connection, reuse for multiple calls
  2. Dispose properly - Always dispose clients: using (var client = new FastClient())
  3. Handler registration - Register all handlers before calling StartAsync()
  4. Error handling - Always wrap RPC calls in try-catch
  5. Thread safety - FastBin class is thread-safe, instances are not
  6. Network timeout - Implement timeouts at the TCP socket level if needed
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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.

Version Downloads Last Updated
1.0.0 198 11/1/2025

With EonaCat.FastBin you can serialize and deserialize fast and efficiently.