Nabs.Launchpad.Core.Interfaces 10.0.221

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

Nabs Launchpad Core Interfaces Library

The Nabs Launchpad Core Interfaces library provides essential serialization configuration for Orleans-based distributed applications. This library enables JSON serialization for custom types and Ardalis.Result types in Orleans grain communication.

Key Features

  • Orleans JSON Serialization: Configure JSON serialization for Orleans grain method parameters and return types
  • Namespace-Based Configuration: Use namespace prefixes to control which types are JSON-serialized
  • Ardalis.Result Support: Built-in JSON serialization support for Ardalis.Result types
  • Flexible Type Selection: Customize serialization behavior based on type namespaces
  • Dependency Injection Integration: Fluent API for registering serialization in service collection

Core Components

SerializationExtensions

Provides extension methods for configuring Orleans serialization with JSON support.

OrleansSerializationOptions

Configuration options specifying which namespace prefixes should use JSON serialization.

Usage Examples

Basic Serialization Setup

using Nabs.Launchpad.Core.Interfaces;

var builder = WebApplication.CreateBuilder(args);

// Configure Orleans serialization
var serializationOptions = new OrleansSerializationOptions();
serializationOptions.SupportedPrefixes.Add("MyApp.Models");
serializationOptions.SupportedPrefixes.Add("MyApp.Dtos");

builder.Services.AddOrleansSerialization(serializationOptions);

Multiple Namespace Prefixes

var serializationOptions = new OrleansSerializationOptions();

// Add multiple namespace prefixes
serializationOptions.SupportedPrefixes.Add("MyCompany.Domain");
serializationOptions.SupportedPrefixes.Add("MyCompany.Contracts");
serializationOptions.SupportedPrefixes.Add("MyCompany.ViewModels");
serializationOptions.SupportedPrefixes.Add("ThirdParty.Library");

builder.Services.AddOrleansSerialization(serializationOptions);

Silo Configuration

// In Orleans Silo configuration
var builder = Host.CreateDefaultBuilder(args);

builder.UseOrleans((context, siloBuilder) =>
{
    siloBuilder.ConfigureServices(services =>
    {
        var serializationOptions = new OrleansSerializationOptions();
        serializationOptions.SupportedPrefixes.Add("MyApp.Models");
        
        services.AddOrleansSerialization(serializationOptions);
    });
});

Client Configuration

// In Orleans Client configuration
var clientBuilder = new ClientBuilder();

clientBuilder.ConfigureServices(services =>
{
    var serializationOptions = new OrleansSerializationOptions();
    serializationOptions.SupportedPrefixes.Add("MyApp.Models");
    
    services.AddOrleansSerialization(serializationOptions);
});

var client = clientBuilder.Build();

Using with Grain Interfaces

// Define your DTOs in a supported namespace
namespace MyApp.Models
{
    public class UserProfile
    {
        public string Id { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
    }
}

// Grain interface using the DTO
public interface IUserGrain : IGrainWithStringKey
{
    Task<Result<UserProfile>> GetProfileAsync();
    Task<Result> UpdateProfileAsync(UserProfile profile);
}

// Grain implementation
public class UserGrain : Grain, IUserGrain
{
    public Task<Result<UserProfile>> GetProfileAsync()
    {
        var profile = new UserProfile
        {
            Id = this.GetPrimaryKeyString(),
            Name = "John Doe",
            Email = "john@example.com"
        };
        
        return Task.FromResult(Result<UserProfile>.Success(profile));
    }
    
    public Task<Result> UpdateProfileAsync(UserProfile profile)
    {
        // Update logic
        return Task.FromResult(Result.Success());
    }
}

Ardalis.Result Integration (Automatic)

// Ardalis.Result types are automatically supported
public interface IOrderGrain : IGrainWithGuidKey
{
    // Result types are automatically JSON-serialized
    Task<Result<OrderDto>> GetOrderAsync();
    Task<Result> ProcessOrderAsync(OrderDto order);
    Task<Result<List<OrderDto>>> GetAllOrdersAsync();
}

// No additional configuration needed for Result types
var grain = client.GetGrain<IOrderGrain>(orderId);
var result = await grain.GetOrderAsync();

if (result.IsSuccess)
{
    var order = result.Value;
    Console.WriteLine($"Order: {order.Id}");
}

API Reference

SerializationExtensions

AddOrleansSerialization
public static IServiceCollection AddOrleansSerialization(
    this IServiceCollection services,
    OrleansSerializationOptions orleansSerializationOptions)

Configures Orleans JSON serialization for types matching the specified namespace prefixes.

Parameters:

  • services: The service collection to configure
  • orleansSerializationOptions: Options specifying supported namespace prefixes

Returns: The service collection for method chaining

Automatically Supports:

  • All types in namespaces starting with "Ardalis.Result"
  • All types in namespaces matching configured prefixes

OrleansSerializationOptions

Properties
SupportedPrefixes
public List<string> SupportedPrefixes { get; }

List of namespace prefixes that should use JSON serialization. Types whose namespace starts with any of these prefixes will be JSON-serialized by Orleans.

How It Works

Serialization Selection

The library configures Orleans to use JSON serialization for specific types based on their namespace:

  1. Ardalis.Result Types: Always JSON-serialized (built-in support)
  2. Custom Types: JSON-serialized if their namespace starts with any configured prefix
  3. Other Types: Use Orleans' default serialization

Type Matching Logic

// Example internal logic
isSupported: type =>
{
    var ns = type.Namespace!;
    
    // Always support Ardalis.Result
    if (ns.StartsWith("Ardalis.Result"))
        return true;
    
    // Check configured prefixes
    foreach (var prefix in orleansSerializationOptions.SupportedPrefixes)
    {
        if (ns.StartsWith(prefix))
            return true;
    }
    
    return false;
}

Best Practices

Namespace Organization

Organize your serializable types in dedicated namespaces:

// Good: Organized by purpose
MyApp.Models.Dtos          // Data transfer objects
MyApp.Models.Commands      // Command objects
MyApp.Models.Queries       // Query objects
MyApp.Models.Events        // Event objects

// Configure with:
serializationOptions.SupportedPrefixes.Add("MyApp.Models");

Avoid Overly Broad Prefixes

// Bad: Too broad, includes everything
serializationOptions.SupportedPrefixes.Add("MyApp");

// Good: Specific to serializable types
serializationOptions.SupportedPrefixes.Add("MyApp.Contracts");
serializationOptions.SupportedPrefixes.Add("MyApp.Shared.Models");

Consistent Configuration

Ensure both client and silo use the same serialization configuration:

// Shared configuration method
public static class SerializationConfig
{
    public static OrleansSerializationOptions GetOptions()
    {
        var options = new OrleansSerializationOptions();
        options.SupportedPrefixes.Add("MyApp.Contracts");
        options.SupportedPrefixes.Add("MyApp.Shared");
        return options;
    }
}

// Use in both client and silo
services.AddOrleansSerialization(SerializationConfig.GetOptions());

Consider Performance

  • JSON Serialization: Slower than Orleans' binary serialization but more flexible
  • Use for DTOs: Apply to data transfer objects, commands, and queries
  • Avoid for High-Frequency Calls: Consider binary serialization for performance-critical grain calls

Why JSON Serialization?

Advantages

  1. Flexibility: Easy to version and evolve types
  2. Debugging: Human-readable serialized data
  3. Interoperability: Can integrate with non-.NET systems
  4. Result Pattern: Perfect for Ardalis.Result types with complex success/error states

When to Use

  • Data Transfer Objects (DTOs)
  • API request/response models
  • Configuration objects
  • Types shared across different services
  • Types that need frequent schema evolution

When to Use Binary Serialization

  • High-frequency grain calls
  • Large data structures
  • Performance-critical paths
  • Internal grain state (not crossing boundaries)

Troubleshooting

Serialization Errors

Issue: SerializationException when calling grain methods

Solution: Ensure the type's namespace is in SupportedPrefixes:

// If MyApp.Models.UserDto fails to serialize:
serializationOptions.SupportedPrefixes.Add("MyApp.Models");

Client/Silo Mismatch

Issue: Serialization works on silo but fails on client (or vice versa)

Solution: Ensure identical serialization configuration on both:

// Use shared configuration helper
var options = SerializationConfig.GetOptions();
services.AddOrleansSerialization(options);

Performance Issues

Issue: Grain calls are slow

Solution:

  1. Profile to identify if JSON serialization is the bottleneck
  2. Consider using Orleans' binary serialization for hot paths
  3. Use JSON serialization selectively for only necessary types

Integration with Other Libraries

With Nabs.Launchpad.Core.Context

// UserContext already uses Orleans serialization attributes
// But you can also use JSON serialization
serializationOptions.SupportedPrefixes.Add("Nabs.Launchpad.Core.Context");

With Nabs.Launchpad.Core.Dtos

// Enable JSON serialization for all DTOs
serializationOptions.SupportedPrefixes.Add("Nabs.Launchpad.Core.Dtos");

Testing

Testing Serialization Configuration

[Fact]
public void Serialization_ShouldSupportConfiguredNamespaces()
{
    // Arrange
    var services = new ServiceCollection();
    var options = new OrleansSerializationOptions();
    options.SupportedPrefixes.Add("MyApp.Models");
    
    // Act
    services.AddOrleansSerialization(options);
    var provider = services.BuildServiceProvider();
    
    // Assert
    var serializer = provider.GetService<ISerializer>();
    serializer.Should().NotBeNull();
}

Testing Grain Serialization

[Fact]
public async Task Grain_ShouldSerializeCustomTypes()
{
    // Arrange
    var cluster = await CreateTestCluster(options =>
    {
        options.SupportedPrefixes.Add("MyApp.Models");
    });
    
    var grain = cluster.GrainFactory.GetGrain<IUserGrain>("test-user");
    var profile = new UserProfile { Name = "Test" };
    
    // Act
    var result = await grain.UpdateProfileAsync(profile);
    
    // Assert
    result.IsSuccess.Should().BeTrue();
}

Dependencies

  • Microsoft.Orleans.Sdk: Orleans SDK for distributed applications
  • Microsoft.Orleans.Core.Abstractions: Core Orleans abstractions
  • Microsoft.Orleans.Serialization.Abstractions: Serialization abstractions
  • Microsoft.Orleans.Serialization.SystemTextJson: JSON serialization provider
  • Microsoft.Extensions.DependencyInjection.Abstractions: DI abstractions
  • Ardalis.Result: Result pattern library (automatically supported)
  • Nabs.Launchpad.Core.Context: Context objects with Orleans serialization
  • Nabs.Launchpad.Core.Silo: Orleans silo configuration
  • Nabs.Launchpad.Core.SiloClient: Orleans client configuration

Target Framework

  • .NET 10
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 (4)

Showing the top 4 NuGet packages that depend on Nabs.Launchpad.Core.Interfaces:

Package Downloads
Nabs.Launchpad.Core.Silo

Package Description

Nabs.Launchpad.Core.Portal

Package Description

Nabs.Launchpad.Core.SiloClient

Package Description

Nabs.Launchpad.Core.Testing.Silos

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.221 42 2/3/2026
10.0.220 59 1/14/2026
10.0.219 123 1/5/2026
10.0.218 128 1/4/2026
10.0.217 138 1/4/2026 10.0.217 is deprecated because it is no longer maintained.
10.0.216 137 1/4/2026 10.0.216 is deprecated because it is no longer maintained.
10.0.215 136 1/4/2026 10.0.215 is deprecated because it is no longer maintained.
10.0.214 137 1/1/2026 10.0.214 is deprecated because it is no longer maintained.
10.0.213 165 1/1/2026 10.0.213 is deprecated because it is no longer maintained.
10.0.212 135 1/1/2026 10.0.212 is deprecated because it is no longer maintained.
10.0.211 134 12/31/2025 10.0.211 is deprecated because it is no longer maintained.
10.0.210 139 12/30/2025 10.0.210 is deprecated because it is no longer maintained.
10.0.209 143 12/30/2025 10.0.209 is deprecated because it is no longer maintained.
10.0.208 141 12/30/2025 10.0.208 is deprecated because it is no longer maintained.
10.0.207 143 12/29/2025 10.0.207 is deprecated because it is no longer maintained.
10.0.206 144 12/29/2025 10.0.206 is deprecated because it is no longer maintained.
10.0.205 223 12/24/2025 10.0.205 is deprecated because it is no longer maintained.
10.0.204 218 12/21/2025 10.0.204 is deprecated because it is no longer maintained.
10.0.203 318 12/18/2025 10.0.203 is deprecated because it is no longer maintained.
10.0.202 330 12/17/2025 10.0.202 is deprecated because it is no longer maintained.
10.0.200 313 12/17/2025 10.0.200 is deprecated because it is no longer maintained.
10.0.199 485 12/10/2025 10.0.199 is deprecated because it is no longer maintained.
10.0.197 220 12/5/2025 10.0.197 is deprecated because it is no longer maintained.
10.0.196 727 12/3/2025 10.0.196 is deprecated because it is no longer maintained.
10.0.195 726 12/3/2025 10.0.195 is deprecated because it is no longer maintained.
10.0.194 721 12/3/2025 10.0.194 is deprecated because it is no longer maintained.
10.0.193 731 12/2/2025 10.0.193 is deprecated because it is no longer maintained.
10.0.192 226 11/28/2025 10.0.192 is deprecated because it is no longer maintained.
10.0.190 243 11/27/2025 10.0.190 is deprecated because it is no longer maintained.
10.0.189 226 11/23/2025 10.0.189 is deprecated because it is no longer maintained.
10.0.187 210 11/23/2025 10.0.187 is deprecated because it is no longer maintained.
10.0.186 197 11/23/2025 10.0.186 is deprecated because it is no longer maintained.
10.0.184 457 11/20/2025 10.0.184 is deprecated because it is no longer maintained.
10.0.181-rc3 335 11/11/2025 10.0.181-rc3 is deprecated because it is no longer maintained.
10.0.180 348 11/11/2025 10.0.180 is deprecated because it is no longer maintained.
10.0.179-rc2 268 11/11/2025 10.0.179-rc2 is deprecated because it is no longer maintained.
10.0.178-rc2 227 11/10/2025 10.0.178-rc2 is deprecated because it is no longer maintained.
10.0.177-rc2 224 11/10/2025 10.0.177-rc2 is deprecated because it is no longer maintained.
10.0.176-rc2 182 11/6/2025 10.0.176-rc2 is deprecated because it is no longer maintained.
10.0.175-rc2 187 11/6/2025 10.0.175-rc2 is deprecated because it is no longer maintained.
10.0.174-rc2 201 11/5/2025 10.0.174-rc2 is deprecated because it is no longer maintained.
10.0.173-rc2 204 11/3/2025 10.0.173-rc2 is deprecated because it is no longer maintained.
10.0.172-rc2 205 11/2/2025 10.0.172-rc2 is deprecated because it is no longer maintained.
10.0.170-rc2 191 11/1/2025 10.0.170-rc2 is deprecated because it is no longer maintained.
10.0.169-rc2 194 11/1/2025 10.0.169-rc2 is deprecated because it is no longer maintained.
10.0.168-rc2 191 10/31/2025 10.0.168-rc2 is deprecated because it is no longer maintained.
10.0.166-rc2 201 10/31/2025 10.0.166-rc2 is deprecated because it is no longer maintained.
10.0.164-rc2 251 10/28/2025 10.0.164-rc2 is deprecated because it is no longer maintained.
10.0.162-rc2 247 10/24/2025 10.0.162-rc2 is deprecated because it is no longer maintained.
9.0.151 276 10/17/2025 9.0.151 is deprecated because it is no longer maintained.
9.0.150 329 9/10/2025 9.0.150 is deprecated because it is no longer maintained.
9.0.146 288 8/15/2025 9.0.146 is deprecated because it is no longer maintained.
9.0.145 324 8/11/2025 9.0.145 is deprecated because it is no longer maintained.
9.0.144 338 8/8/2025 9.0.144 is deprecated because it is no longer maintained.
9.0.137 255 7/29/2025 9.0.137 is deprecated because it is no longer maintained.
9.0.136 267 7/29/2025 9.0.136 is deprecated because it is no longer maintained.
9.0.135 303 7/28/2025 9.0.135 is deprecated because it is no longer maintained.
9.0.134 323 7/9/2025 9.0.134 is deprecated because it is no longer maintained.
9.0.133 342 7/9/2025 9.0.133 is deprecated because it is no longer maintained.
9.0.132 342 7/9/2025 9.0.132 is deprecated because it is no longer maintained.
9.0.131 351 7/9/2025 9.0.131 is deprecated because it is no longer maintained.
9.0.130 350 7/7/2025 9.0.130 is deprecated because it is no longer maintained.