JSSoft.Modelora.Yaml
1.0.0-preview.11
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
This is a prerelease version of JSSoft.Modelora.Yaml.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package JSSoft.Modelora.Yaml --version 1.0.0-preview.11
NuGet\Install-Package JSSoft.Modelora.Yaml -Version 1.0.0-preview.11
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="JSSoft.Modelora.Yaml" Version="1.0.0-preview.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JSSoft.Modelora.Yaml" Version="1.0.0-preview.11" />
<PackageReference Include="JSSoft.Modelora.Yaml" />
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 JSSoft.Modelora.Yaml --version 1.0.0-preview.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JSSoft.Modelora.Yaml, 1.0.0-preview.11"
#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 JSSoft.Modelora.Yaml@1.0.0-preview.11
#: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=JSSoft.Modelora.Yaml&version=1.0.0-preview.11&prerelease
#tool nuget:?package=JSSoft.Modelora.Yaml&version=1.0.0-preview.11&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Modelora
A high-performance model serialization and conversion library for .NET. Efficiently serialize and deserialize complex object models to binary, JSON, and YAML formats.
Supported Frameworks
This library is packaged as a multi-targeted NuGet package.
- .NET 9.0 (default target for development)
- .NET 8.0
- .NET 7.0
- .NET 6.0
- .NET Standard 2.1
Key Features
- High-performance binary serialization: Compact and fast binary format
- JSON support: JSON serialization based on System.Text.Json
- YAML support: YAML serialization based on YamlDotNet
- Type safety: Type safety guarantee through compile-time code generation
- Version compatibility: Model version management and compatibility support
- Custom converters: Support for user-defined type converters
Quick Start
Basic Usage
using JSSoft.Modelora;
// Define model class
[Model("Person", Version = 1)]
public partial class Person
{
[Property(0)]
public string Name { get; set; } = string.Empty;
[Property(1)]
public int Age { get; set; }
[Property(2)]
public DateTime BirthDate { get; set; }
}
// Binary serialization
var person = new Person { Name = "John Doe", Age = 30, BirthDate = new DateTime(1994, 1, 1) };
byte[] data = ModelSerializer.Serialize(person);
// Binary deserialization
var deserializedPerson = ModelSerializer.Deserialize<Person>(data);
JSON Serialization
using JSSoft.Modelora.Json;
// JSON serialization
string json = ModelJsonSerializer.Serialize(person);
// JSON deserialization
var personFromJson = ModelJsonSerializer.Deserialize<Person>(json);
YAML Serialization
using JSSoft.Modelora.Yaml;
// YAML serialization
string yaml = ModelYamlSerializer.Serialize(person);
// YAML deserialization
var personFromYaml = ModelYamlSerializer.Deserialize<Person>(yaml);
Advanced Features
Model Attributes
// Model with version management
[ModelHistory(Version = 1, Type = typeof(Version1_Person))]
[ModelHistory(Version = 2, Type = typeof(Version2_Person))]
[Model("Person", Version = 3)]
public sealed record class Person
{
public Person()
{
}
public Person(Version2_Person legacyModel)
{
Name = legacyModel.Name;
Age = legacyModel.Age;
Email = "default@example.com"; // Default value for newly added field
}
[Property(0)]
public string Name { get; set; } = string.Empty;
[Property(1)]
public int Age { get; set; }
[Property(2)]
public string Email { get; set; } = string.Empty;
}
// Legacy version models
[OriginModel(Type = typeof(Person))]
public sealed record class Version1_Person
{
[Property(0)]
public string Name { get; set; } = string.Empty;
}
[OriginModel(Type = typeof(Person))]
public sealed record class Version2_Person
{
public Version2_Person()
{
}
public Version2_Person(Version1_Person legacyModel)
{
Name = legacyModel.Name;
Age = 0; // Default value
}
[Property(0)]
public string Name { get; set; } = string.Empty;
[Property(1)]
public int Age { get; set; }
}
Scalar Value Definition
// Define scalar value type
[ModelScalar("hex_value", Kind = ModelScalarKind.Hex)]
public readonly partial record struct HexValue(in ImmutableArray<byte> Bytes)
: IEquatable<HexValue>, IComparable<HexValue>, IComparable
{
public HexValue(ReadOnlySpan<byte> bytes)
: this(bytes.ToImmutableArray())
{
}
public ImmutableArray<byte> Bytes => _bytes.IsDefault ? ImmutableArray.Create(Array.Empty<byte>()) : _bytes;
public static HexValue Parse(string hex)
{
ImmutableArray<byte> bytes = [.. ByteUtility.Parse(hex)];
return new HexValue(bytes);
}
public override string ToString() => ByteUtility.Hex(Bytes.AsSpan());
// Scalar conversion methods
internal byte[] ToScalarValue() => [.. Bytes];
internal static HexValue FromScalarValue(IServiceProvider serviceProvider, byte[] value)
=> new(value.ToImmutableArray());
}
Custom Converters
[ModelConverter(typeof(CustomConverter))]
public class CustomType
{
public string Value { get; set; } = string.Empty;
}
public class CustomConverter : IModelConverter<CustomType>
{
public CustomType Read(BinaryReader reader, ModelOptions options)
{
return new CustomType { Value = reader.ReadString() };
}
public void Write(BinaryWriter writer, CustomType value, ModelOptions options)
{
writer.Write(value.Value);
}
}
Package Structure
- JSSoft.Modelora: Core binary serialization library
- JSSoft.Modelora.Json: JSON serialization extension
- JSSoft.Modelora.Yaml: YAML serialization extension
- JSSoft.Modelora.Analyzers: Compile-time code generator
Installation
# Core library
dotnet add package JSSoft.Modelora
# JSON support
dotnet add package JSSoft.Modelora.Json
# YAML support
dotnet add package JSSoft.Modelora.Yaml
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 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 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
- JSSoft.Modelora (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.3.0)
-
net6.0
- JSSoft.Modelora (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.3.0)
-
net7.0
- JSSoft.Modelora (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.3.0)
-
net8.0
- JSSoft.Modelora (>= 1.0.0-preview.11)
- YamlDotNet (>= 16.3.0)
-
net9.0
- JSSoft.Modelora (>= 1.0.0-preview.11)
- YamlDotNet (>= 16.3.0)
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-preview.12 | 340 | 11/19/2025 |
| 1.0.0-preview.11 | 143 | 11/5/2025 |
| 1.0.0-preview.10 | 134 | 11/5/2025 |
| 1.0.0-preview.9 | 138 | 11/5/2025 |
| 1.0.0-preview.8 | 139 | 11/5/2025 |
| 1.0.0-preview.7 | 215 | 11/4/2025 |
| 1.0.0-preview.6 | 133 | 11/4/2025 |
| 1.0.0-preview.5 | 137 | 11/3/2025 |
| 1.0.0-pr.4 | 105 | 10/31/2025 |
| 1.0.0-pr.3 | 102 | 10/31/2025 |
| 1.0.0-pr.2 | 102 | 10/31/2025 |
| 1.0.0-pr.1 | 120 | 10/31/2025 |