AutoPatch.Client 10.1.0

dotnet add package AutoPatch.Client --version 10.1.0
                    
NuGet\Install-Package AutoPatch.Client -Version 10.1.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="AutoPatch.Client" Version="10.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoPatch.Client" Version="10.1.0" />
                    
Directory.Packages.props
<PackageReference Include="AutoPatch.Client" />
                    
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 AutoPatch.Client --version 10.1.0
                    
#r "nuget: AutoPatch.Client, 10.1.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 AutoPatch.Client@10.1.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=AutoPatch.Client&version=10.1.0
                    
Install as a Cake Addin
#tool nuget:?package=AutoPatch.Client&version=10.1.0
                    
Install as a Cake Tool

🩹 AutoPatch Framework

NuGet Server NuGet Client Build Status License: MIT

Real-time object synchronization between server and client using SignalR and JsonPatch

AutoPatch Framework enables automatic, transparent real-time synchronization of objects between server and client. Once configured, objects are kept in sync automatically without additional code - just subscribe and watch your objects update in real-time.

✨ Features

  • 🔄 Automatic Real-time Sync - Objects stay synchronized without manual intervention
  • 🚀 Performance Optimized - Intelligent throttling and batching system
  • 📱 UI Integration - Seamless data binding via INotifyPropertyChanged
  • 🛡️ Type Safety - Strongly typed API with compile-time validation
  • 🎯 Minimal API - Just Subscribe/Unsubscribe - everything else is automatic
  • 📦 JsonPatch Based - Efficient delta updates, only changes are transmitted
  • 🔌 SignalR Powered - Built on proven real-time communication infrastructure
  • 🔑 Multiple Collections - Support for multiple keyed collections of the same type
  • 🔐 Subscription Validation - Per-collection authentication and authorization control

🎯 Use Cases

Live Dashboards • Real-time Tracking • Status Monitoring • Live Feeds • IoT Applications • Multi-tenant Systems

🚀 Quick Start

Installation

dotnet add package AutoPatch.Server  # Server
dotnet add package AutoPatch.Client  # Client

Server Setup

// Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddAutoPatch(cfg => cfg.DefaultThrottleInterval = TimeSpan.FromMilliseconds(500))
    .AddTrackedCollection<Order>()
    .AddSignalR();

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

// Use tracked collections
public class OrderService
{
    private readonly ObservableCollection<Order> _orders;

    public OrderService(ITrackedCollectionManager manager)
    {
        _orders = manager.GetOrCreateCollection<Order>();
    }

    public void ProcessOrder(Order order)
    {
        _orders.Add(order);              // → Auto-sync to clients
        order.Status = "Processing";     // → Auto-sync property changes
    }
}

Client Setup

// App setup
services.AddAutoPatch(cfg => cfg.Endpoint = "http://localhost:5249/autopatch")
        .AddTrackedCollection<Order>()
        .AddAutoPatchHostedConnection(); // optional: connect in the background when the host starts

// Usage
public class OrderViewModel
{
    public ObservableCollection<Order> Orders { get; private set; } = [];

    public async Task InitializeAsync()
    {
        await _client.ConnectAsync();                   // no-op if already connected
        await _client.SubscribeToTypeAsync<Order>();
        Orders = _client.GetTrackedCollection<Order>(); // Auto-updating collection
    }
}

The client reconnects automatically and subscribes again after a reconnect. Blazor WebAssembly does not run hosted services, so call ConnectAsync() yourself there.


## 📖 Advanced Features

### Multiple Collections & Authentication

```csharp
// Server: Collection per tenant
var tenantOrders = manager.GetOrCreateCollection<Order>($"tenant_{tenantId}");

// Client: Subscribe with auth
await client.SubscribeToTypeAsync<Order>("tenant_123", "auth_token");
var orders = client.GetTrackedCollection<Order>("tenant_123");

// Validator (async; receives the authenticated ClaimsPrincipal + the legacy auth string)
public class OrderValidator : ICollectionSubscriptionValidator<Order>
{
    public Task<bool> ValidateSubscriptionAsync(ClaimsPrincipal? user, string? auth, string key)
        => Task.FromResult(auth == "valid_token");
}
builder.Services.AddTrackedCollection<Order, OrderValidator>();

// Optional: require an authenticated user on the hub endpoint (opt-in per app)
app.UseAutoPatch().RequireAuthorization();

// Client: send a bearer token (JWT) so the hub sees an authenticated Context.User
services.AddAutoPatch(cfg =>
{
    cfg.Endpoint = "https://server/autopatch";
    cfg.AccessTokenProvider = () => tokenService.GetAccessTokenAsync();
});

Only collection types registered with AddTrackedCollection can be subscribed; unknown type names are rejected.

Configuration Options

builder.Services.AddTrackedCollection<Order>(cfg =>
{
    cfg.ThrottleInterval = TimeSpan.FromMilliseconds(100);  // Update frequency
    cfg.ExcludedProperties = ["InternalData"];              // Never sent to clients
    cfg.FlushMode = FlushMode.Manual;                       // Only send on FlushAsync
});

// e.g. exactly one batch per simulation tick
await manager.FlushAsync<Order>(zoneKey);
FlushMode A batch is sent
Timed (default) at the latest one throttle interval after the first change, or earlier at MaxBatchSize
MaxBatchSize at MaxBatchSize or on FlushAsync
Manual only on FlushAsync

Own Hub

To use a single connection for your own hub methods and AutoPatch, derive your hub from AutoPatchHub and map it instead of calling UseAutoPatch():

public class GameHub(ITrackedCollectionManager manager, IServiceProvider services) : AutoPatchHub(manager, services)
{
    public Task Move(int x, int y) => ...;
}

app.MapHub<GameHub>("/game");

🏗️ How It Works

Server: ObservableCollection<T> changes → JSON Patch operations (insert, remove, replace, move, property changes) → ordered batches with sequence numbers → SignalR broadcast
Client: Receive batches → apply each batch completely or not at all → UI updates. A missing batch or a batch that does not fit makes the client fetch the full data again.

The wire protocol is described in spec.md.

🌟 Roadmap

  • Bidirectional Sync - Client-to-server change propagation
  • Change Policies - accept, confirm or reject client changes
  • Filtering - Subscription filters and conditional updates
  • Offline Support - Sync on reconnect

🆘 Support & Community

Got questions? We're here to help!

🐛 Report Issues - Found a bug or have a feature request?
💬 Join Discussions - Ask questions, share ideas, or showcase your projects
📧 Direct Contact - Need enterprise support or consulting?
⭐ Star the Project - Show your support and stay updated!


Made with ❤️ for real-time applications

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
10.1.0 138 9/11/2026
10.0.0 216 6/27/2026
9.1.1 219 9/12/2025
9.0.7 267 9/8/2025
9.0.6 249 9/8/2025
9.0.3 325 8/24/2025
9.0.2 321 8/24/2025
9.0.1 310 8/24/2025