schema 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package schema --version 0.0.3                
NuGet\Install-Package schema -Version 0.0.3                
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="schema" Version="0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add schema --version 0.0.3                
#r "nuget: schema, 0.0.3"                
#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.
// Install schema as a Cake Addin
#addin nuget:?package=schema&version=0.0.3

// Install schema as a Cake Tool
#tool nuget:?package=schema&version=0.0.3                

Schema

GitHub Nuget Nuget Unit tests Coverage Status

Overview

Library for converting classes to and from binary. Provides a C# Roslyn generator that automatically implements conversion logic for simple classes.

Credits

  • @jefffhaynes, as their BinarySerializer attribute library inspired the schema attributes for configuring how binary data is read.
  • @Sergio0694, as their BinaryPack generator inspired the schema source generator used to generate read/write methods.

Usage

Implementing binary schema classes

To write a binary schema class, you must first do the following steps:

  1. Mark it as partial.
  2. Have it implement the IBinaryConvertible interface (a combination of the IBinarySerializable and IBinaryDeserializable interfaces).

Then, based on how complicated your schema class is, you can either choose to automatically or manually implement Read()/Write() methods.

Automatically

For most schema classes, you should be able to use the automatic code generator.

All you have to do is annotate the schema class with the [BinarySchema] attribute; this will flag to the generator that it should implement read/write methods for this class. It will then look into all fields/properties in the schema class, and attempt to implement read/write logic in the same order that the fields/properties appear.

Any nested schema classes will be automatically read/written as expected.

Some types require additional attributes in order to clarify any ambiguity. For example, booleans require a [IntegerFormat(SchemaIntegerType.###)] attribute to know what type of integer to read, which it will then compare to 0.

Any readonly primitives will treated as assertions, which is useful for validating things like magic text or padding.

Manually

For complicated schema classes, such as ones that use decompression logic or pointers, you'll need to implement the read/write logic manually.

Specifically, you'll need to implement both a Read(IEndianBinaryReader er) and Write(ISubEndianBinaryWriter ew) method. The EndianBinaryReader and EndianBinaryWriter classes provide many helpful methods for reading/writing a number of different primitive formats, including basic ones such as byte/int/float, but also more complex/unique ones such as Half (two-byte float) and un16 (unsigned normalized 16-bit float).

Similar to the automatic process, you can nest schema classes and manually read/write them by calling their Read()/Write() methods. This can allow you to automatically generate subsections, so only the most complex logic needs to be manually written.

How to use a binary schema class

To convert a given schema class to or from binary, simply instantiate an EndianBinaryReader or EndianBinaryWriter and pass it into the corresponding Read() or Write() methods in the schema class. You must use the EndianBinaryReader/EndianBinaryWriter defined within this project, as this adds more functionality.

Product 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. 
.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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on schema:

Repository Stars
MeltyPlayer/FinModelUtility
Model viewer and command-line tools for extracting models from various GCN/3DS/PC games en-masse.
Version Downloads Last updated
0.6.1 55 12/1/2024
0.6.0 105 11/26/2024
0.5.20 49 11/25/2024
0.5.19 53 11/25/2024
0.5.18 49 11/25/2024
0.5.17 62 11/20/2024
0.5.16 77 11/20/2024
0.5.15 63 11/20/2024
0.5.14 67 11/15/2024
0.5.13 60 11/15/2024
0.5.12 85 11/11/2024
0.5.11 73 11/11/2024
0.5.10 66 11/9/2024
0.5.9 98 10/23/2024
0.5.8 76 10/21/2024
0.5.7 61 10/21/2024
0.5.6 78 10/20/2024
0.5.5 163 8/13/2024
0.5.4 203 7/9/2024
0.5.3 51 7/9/2024
0.5.2 378 5/18/2024
0.5.1 145 5/5/2024
0.5.0 96 4/29/2024
0.4.20 90 4/26/2024
0.4.19 85 4/24/2024
0.4.18 85 4/24/2024
0.4.17 80 4/24/2024
0.4.16 93 4/23/2024
0.4.15 76 4/23/2024
0.4.14 84 4/23/2024
0.4.13 88 4/22/2024
0.4.12 89 4/21/2024
0.4.11 91 4/21/2024
0.4.10 96 4/21/2024
0.4.9 84 4/18/2024
0.4.8 84 4/18/2024
0.4.7 96 4/17/2024
0.4.6 78 4/17/2024
0.4.5 76 4/17/2024
0.4.4 83 4/17/2024
0.4.3 80 4/17/2024
0.4.2 83 4/17/2024
0.4.1 76 4/17/2024
0.4.0 76 4/17/2024
0.3.17 94 4/17/2024
0.3.16 78 4/17/2024
0.3.15 91 4/17/2024
0.3.14 91 4/15/2024
0.3.12 121 3/16/2024
0.3.11 203 1/13/2024
0.3.10 261 11/4/2023
0.3.9 99 11/4/2023
0.3.8 79 11/3/2023
0.3.7 175 10/23/2023
0.3.6 114 10/20/2023
0.3.5 108 10/17/2023
0.3.4 103 10/17/2023
0.3.3 109 10/17/2023
0.3.2 137 10/11/2023
0.3.1 101 10/11/2023
0.3.0 134 10/3/2023
0.2.3 236 8/26/2023
0.2.2 207 8/6/2023
0.2.1 128 8/6/2023
0.2.0 124 8/6/2023
0.1.12 139 8/2/2023
0.1.11 162 8/1/2023
0.1.10 143 8/1/2023
0.1.9 146 7/30/2023
0.1.8 137 7/30/2023
0.1.7 141 7/30/2023
0.1.6 140 7/30/2023
0.1.5 152 7/29/2023
0.1.4 130 7/29/2023
0.1.3 138 7/29/2023
0.1.2 139 7/29/2023
0.1.1 158 7/28/2023
0.1.0 126 7/28/2023
0.0.15 169 7/23/2023
0.0.14 149 7/17/2023
0.0.13 146 7/17/2023
0.0.12 143 7/17/2023
0.0.11 145 7/15/2023
0.0.10 143 7/15/2023
0.0.9 185 6/14/2023
0.0.8 159 6/11/2023
0.0.7 208 5/30/2023
0.0.6 157 5/22/2023
0.0.5 145 5/21/2023
0.0.4 142 5/19/2023
0.0.3 147 5/13/2023
0.0.2 144 5/13/2023
0.0.1 168 5/13/2023