JSSoft.Modelora.Analyzers
1.0.0-preview.12
This is a prerelease version of JSSoft.Modelora.Analyzers.
dotnet add package JSSoft.Modelora.Analyzers --version 1.0.0-preview.12
NuGet\Install-Package JSSoft.Modelora.Analyzers -Version 1.0.0-preview.12
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.Analyzers" Version="1.0.0-preview.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JSSoft.Modelora.Analyzers" Version="1.0.0-preview.12" />
<PackageReference Include="JSSoft.Modelora.Analyzers" />
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.Analyzers --version 1.0.0-preview.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: JSSoft.Modelora.Analyzers, 1.0.0-preview.12"
#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.Analyzers@1.0.0-preview.12
#: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.Analyzers&version=1.0.0-preview.12&prerelease
#tool nuget:?package=JSSoft.Modelora.Analyzers&version=1.0.0-preview.12&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 was computed. 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 was computed. 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 was computed. 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 was computed. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. 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.0
- Microsoft.CodeAnalysis.Analyzers (>= 3.3.3)
- Microsoft.CodeAnalysis.CSharp (>= 4.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on JSSoft.Modelora.Analyzers:
| Package | Downloads |
|---|---|
|
JSSoft.Modelora
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 | 421 | 11/19/2025 |
| 1.0.0-preview.11 | 204 | 11/5/2025 |
| 1.0.0-preview.10 | 191 | 11/5/2025 |
| 1.0.0-preview.9 | 198 | 11/5/2025 |
| 1.0.0-preview.8 | 196 | 11/5/2025 |
| 1.0.0-preview.7 | 289 | 11/4/2025 |
| 1.0.0-preview.6 | 191 | 11/4/2025 |
| 1.0.0-preview.5 | 192 | 11/3/2025 |
| 1.0.0-pr.4 | 179 | 10/31/2025 |
| 1.0.0-pr.3 | 169 | 10/31/2025 |
| 1.0.0-pr.2 | 483 | 10/31/2025 |
| 1.0.0-pr.1 | 496 | 10/31/2025 |