Chrysalis.Codec.CodeGen 1.2.3-alpha

This is a prerelease version of Chrysalis.Codec.CodeGen.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Chrysalis.Codec.CodeGen --version 1.2.3-alpha
                    
NuGet\Install-Package Chrysalis.Codec.CodeGen -Version 1.2.3-alpha
                    
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="Chrysalis.Codec.CodeGen" Version="1.2.3-alpha">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chrysalis.Codec.CodeGen" Version="1.2.3-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Chrysalis.Codec.CodeGen">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
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 Chrysalis.Codec.CodeGen --version 1.2.3-alpha
                    
#r "nuget: Chrysalis.Codec.CodeGen, 1.2.3-alpha"
                    
#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 Chrysalis.Codec.CodeGen@1.2.3-alpha
                    
#: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=Chrysalis.Codec.CodeGen&version=1.2.3-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Chrysalis.Codec.CodeGen&version=1.2.3-alpha&prerelease
                    
Install as a Cake Tool

Overview of Rules

Type Attributes

[CborSerializable] - this attribute is used to tell the source generator that this type needs a cbor serializer [CborList] [CborMap] [CborConstr] [CborUnion] [CborTag] - a helper attribute to assist source gen in determining the code to generate

Property Attributes

[CborOrder(int)] - used for properties within a [CborList] or [CborConstr] to preserve the ordering of properties [CborProperty(int/string)] - used for properties within a [CborMap] to specify the key to serialize/deserialize [CborSize(int)] - used to specify that the type has definite size. byte[] support will be initially supported [CborNullable] - used to specify if a property can be serialized into null [CborIndefinite] - by default, arrays and maps will be serialized into definite length, this tells the source generator to serialize into indefinite length

Special Types

  1. CborEncodedValue - a special type for serializing data with encoding tag
  2. Nested record for Union types
  3. Open generic types, for example CborDefiniteList<T>

Primitive Types

int long ulong double decimal string byte[] - with special handling since [CborSize(int)] can be used for this type

Collection Types

in order to not complicate things, we will only support these 2 types for now

IEnumerable<T>
Dictionary<TKey, TValue>

Special Rules

ICborValidator<T> - is an interface with one function Validate() to tell generator that a type must be validated after deserialization or before serialization ICborRaw - is an interface with no function, this just helps the source gen to know if a validate function must be called or not CborBase - is base abstract type that contains the Raw property and Name which is a helper for union types. All custom types must inherit from CborBase in order for serialization to work properly

Development Checklist

Base Code

[] Create Chrysalis.Cbor.CodeGen dotnet project

Metadata Gathering

[] Create a file CborSerializerCodeGen.Metadata.cs which will contain the metadata types [] Define a type to hold the metadata for the type CborSerializableTypeMetadata which includes typeName, namespace, attributes, interfaces [] Create a file CborSerializerCodeGen.Parser.cs which will contain the logic on how to extract the metadata [] Create CborSerializerCodeGen.cs class which will be the starting point of the generator [] Emit a file per type that contains the metadata for debugging

Code Generation

[] Create a file CborSerializerCodeGen.Emitter.cs that contains the logic for generating code, depending on the rules, this will contain the emitters for primitive types and collection types [CborList] [CborMap] [CborConstr] [CborUnion] will have their own reusable emitters. [CborTag] [CborNullable] [CborSize] [CborIndefinite] emitter helpers will be on the generic emitter file [] Create a folder Emitters that has ICborEmitter interface that has 2 methods GenerateSerializer and GenerateDeserializer [] Create primitive type emitter and make sure they work with test types [] Create collection type (IEnumerable, Dictionary<TKey, TValue>) emitters with support for closed generics and make sure it works with test types [] Create [CborList] ICborEmitter and test with test types [] Create [CborConstr] ICborEmitter and test with test types [] Create [CborMap] ICborEmitter and test with test types [] Create [CborUnion] ICborEmitter and test with test types [] Open Generic handling for example CborDefiniteList<T>

Testing and debugging

Basic

[] Primitive [] List [] Map [] Nullable [] Indefinite [] Bounded Bytes [] Cbor Tag

Complex Types

[] Container [] Constr [] Custom List [] Custom Map [] Union Type [] Generic Type

Cardano Types

[] Block [] Header [] TransactionBody [] WitnessSet [] AuxDataSet [] InvalidTransactions

[] Alonzo Block [] Babbage Block [] Conway Block

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

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.5.0-alpha 0 3/14/2026
1.4.0-alpha 31 3/12/2026
1.3.0-alpha 34 3/11/2026
1.2.3-alpha 33 3/9/2026
1.2.2-alpha 32 3/9/2026