JSSoft.Modelora
1.0.0-preview.11
See the version list below for details.
dotnet add package JSSoft.Modelora --version 1.0.0-preview.11
NuGet\Install-Package JSSoft.Modelora -Version 1.0.0-preview.11
<PackageReference Include="JSSoft.Modelora" Version="1.0.0-preview.11" />
<PackageVersion Include="JSSoft.Modelora" Version="1.0.0-preview.11" />
<PackageReference Include="JSSoft.Modelora" />
paket add JSSoft.Modelora --version 1.0.0-preview.11
#r "nuget: JSSoft.Modelora, 1.0.0-preview.11"
#:package JSSoft.Modelora@1.0.0-preview.11
#addin nuget:?package=JSSoft.Modelora&version=1.0.0-preview.11&prerelease
#tool nuget:?package=JSSoft.Modelora&version=1.0.0-preview.11&prerelease
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. |
-
.NETStandard 2.1
- JSSoft.Modelora.Analyzers (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net6.0
- JSSoft.Modelora.Analyzers (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
-
net7.0
- JSSoft.Modelora.Analyzers (>= 1.0.0-preview.11)
- System.Collections.Immutable (>= 8.0.0)
-
net8.0
- JSSoft.Modelora.Analyzers (>= 1.0.0-preview.11)
-
net9.0
- JSSoft.Modelora.Analyzers (>= 1.0.0-preview.11)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on JSSoft.Modelora:
| Package | Downloads |
|---|---|
|
JSSoft.Modelora.Json
Lightweight random data generator utilities for .NET. Generate primitives, collections, tuples, enums, text, time values, shuffle, and more—handy for tests, seeding, and demos. |
|
|
JSSoft.Modelora.Yaml
Lightweight random data generator utilities for .NET. Generate primitives, collections, tuples, enums, text, time values, shuffle, and more—handy for tests, seeding, and demos. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-preview.12 | 345 | 11/19/2025 |
| 1.0.0-preview.11 | 139 | 11/5/2025 |
| 1.0.0-preview.10 | 134 | 11/5/2025 |
| 1.0.0-preview.9 | 142 | 11/5/2025 |
| 1.0.0-preview.8 | 134 | 11/5/2025 |
| 1.0.0-preview.7 | 223 | 11/4/2025 |