Femur.Serialization 0.0.31

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

Femur.Serialization

Femur.Serialization is a flexible and extensible serialization library for .NET, designed to support asynchronous serialization and deserialization of objects across various content types. With built-in support for JSON, it provides a pattern and guide for standardizing serializers based on web and REST content types.

Note: This project is not a complete serialization library but rather a framework to establish a consistent approach to serialization and deserialization for various content types, emphasizing extensibility and adherence to web standards.

Features

  • Asynchronous support for serialization and deserialization.
  • Extensible architecture allowing additional serializers for different content types.
  • Built-in JSON serialization using System.Text.Json.
  • Strongly typed interfaces for better type safety.

Getting Started

Installation

You can install the Femur.Serialization library via NuGet Package Manager:

dotnet add package Femur.Serialization

Usage

To start using the Femur.Serialization library in your project, follow these steps:

  1. Set Up Dependency Injection: Use a ServiceCollection to register the serializers for your application. You can use the provided extension methods to add serializers easily.

  2. Register Serializers: Register your desired serializers using the extension method AddSerializer<T>(). You can also add a default JSON serializer, using the extension method AddDefaultJsonSerializer(JsonSerializerOptions? options).

  3. Resolve the Serializer Factory: Retrieve the IAsyncSerializerFactory from the service provider to perform serialization or deserialization.

Example

Here’s a sample implementation demonstrating these steps:

using Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;
using System.Threading.Tasks;
using Femur.Serialization;

public class Example
{
    public async Task RunExample()
    {
        // Set up the service collection and configure the serializer
        var services = new ServiceCollection();
        services.AddDefaultJsonSerializer(); // Register the default JSON serializer
        var serviceProvider = services.BuildServiceProvider();

        // Resolve the IAsyncSerializerFactory
        var factory = serviceProvider.GetRequiredService<IAsyncSerializerFactory>();

        var myObject = new TestClass { Name = "Test" };
        using var stream = new MemoryStream();

        // Serialize to JSON
        await factory.SerializeAsync(stream, myObject, "application/json");

        // Reset stream position for reading
        stream.Position = 0; 

        // Deserialize from JSON
        var result = await factory.DeserializeAsync<TestClass>(stream, "application/json");
        Console.WriteLine(result?.Name);  // Output: Test
    }

    private class TestClass
    {
        public string Name { get; set; } = default!;
    }
}

In this example, the ServiceCollection is configured to register the default JSON serializer. You can then resolve the IAsyncSerializerFactory from the service provider to handle the serialization and deserialization tasks easily.

Running Tests

The library includes a comprehensive set of unit tests to ensure reliability. To run the tests, utilize the following command:

dotnet test

Contributing

Contributions are welcome! If you have suggestions or improvements, feel free to open an issue or submit a pull request.

Product 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 is compatible.  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 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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Femur.Serialization:

Package Downloads
Femur

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.31 158 3/30/2026
0.0.30 215 1/25/2026
0.0.29 166 1/19/2026
0.0.28 222 12/5/2025
0.0.27 703 12/3/2025
0.0.26 736 12/3/2025
0.0.25 707 12/2/2025
0.0.24 709 12/2/2025
0.0.23 707 12/2/2025
0.0.21 716 12/2/2025
0.0.20 234 11/24/2025
0.0.16 339 10/6/2025
0.0.15 230 10/1/2025
0.0.14 262 9/20/2025
0.0.13 262 9/19/2025
0.0.11 596 3/24/2025
0.0.6 261 3/6/2025