Nemesis.TextParsers.CodeGen 2.6.2

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

// Install Nemesis.TextParsers.CodeGen as a Cake Tool
#tool nuget:?package=Nemesis.TextParsers.CodeGen&version=2.6.2

Contains various parser optimized for speed and no allocation
     This package was built from the source at /tree/

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has 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
2.9.2 171 1/3/2024
2.9.1 108 1/1/2024
2.8.2 102 12/19/2023
2.7.2 142 7/16/2023
2.7.1 124 7/14/2023
2.7.0 123 7/14/2023
2.6.3 424 5/30/2022
2.6.2 330 3/1/2021
2.6.1 309 2/25/2021
2.6.0 316 2/25/2021
0.0.0-alpha.0.335 46 1/1/2024

Release v2.6.2
Add code gen package

Add code generation package that automatically generates necessary transformers
## C# 9.0 Code generation
With introduction of new code-gen engine, you can opt to have your transformer generated automatically without any imperative code.
```csharp
//1. use specially provided (via code-gen) Auto.AutoDeconstructable attribute
[Auto.AutoDeconstructable]
//2. provide deconstructable aspect options or leave this attribute out - default options will be engaged
[DeconstructableSettings('_', '∅', '%', '〈', '〉')]
readonly partial /*3. partial modifier is VERY important - you need this cause generated code is placed in different file*/ struct StructPoint3d
{
   public double X { get; }
   public double Y { get; }
   public double Z { get; }

   //4. specify constructor and matching deconstructor
   public StructPoint3d(double x, double y, double z) { X = x; Y = y; Z = z; }

   public void Deconstruct(out double x, out double y, out double z) { x = X; y = Y; z = Z; }
}

//5. sit back, relax and enjoy - code-gen will do the job for you :-)
```

This in turn might generate the following (parts of code ommited for brevity)
```csharp
using /* ... */;
[Transformer(typeof(StructPoint3dTransformer))]
readonly partial struct StructPoint3d { }

sealed class StructPoint3dTransformer : TransformerBase<StructPoint3d>
{
   private readonly ITransformer<double> _transformer_x = TextTransformer.Default.GetTransformer<double>();
   /* specify remaining transformers... */
   private const int ARITY = 3;
   private readonly TupleHelper _helper = new TupleHelper('_', '∅', '%', '〈', '〉');

   protected override StructPoint3d ParseCore(in ReadOnlySpan<char> input)
   {
       var enumerator = _helper.ParseStart(input, ARITY);
       var t1 = _helper.ParseElement(ref enumerator, _transformer_x);        
       /* parse Y and Z... */
       _helper.ParseEnd(ref enumerator, ARITY);
       return new StructPoint3d(t1, t2, t3);
   }

   public override string Format(StructPoint3d element)
   {
       Span<char> initialBuffer = stackalloc char[32];
       var accumulator = new ValueSequenceBuilder<char>(initialBuffer);
       try
       {
            _helper.StartFormat(ref accumulator);
            var (x, y, z) = element;
           _helper.FormatElement(_transformer_x, x, ref accumulator);
           /* format Y and Z... */
           _helper.EndFormat(ref accumulator);
           return accumulator.AsSpan().ToString();
       }
       finally { accumulator.Dispose(); }
   }
}
```
### Code gen diagnositcs
Various diagnositcs exist to guide end user in creation of proper types that can be consumed by automatic generation. They might for example:
1. check if types decorated with Auto* attributes are declared partial (prerequisite for additive code generation)
2. validate settings passed via declarative syntax
3. validate internal structure of type (i.e. check if constructor has matching Deconstruct method)
4. check if external dependencies are included