TigerSan.CodeGenerator 1.0.1

dotnet add package TigerSan.CodeGenerator --version 1.0.1
                    
NuGet\Install-Package TigerSan.CodeGenerator -Version 1.0.1
                    
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="TigerSan.CodeGenerator" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TigerSan.CodeGenerator" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="TigerSan.CodeGenerator" />
                    
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 TigerSan.CodeGenerator --version 1.0.1
                    
#r "nuget: TigerSan.CodeGenerator, 1.0.1"
                    
#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 TigerSan.CodeGenerator@1.0.1
                    
#: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=TigerSan.CodeGenerator&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=TigerSan.CodeGenerator&version=1.0.1
                    
Install as a Cake Tool

1. Description:

A class library for code generation.

1. OperationUnit:

ReplaceOpts: Replacement operation collection.

ListOpts: List operation collection.

Operation: Sub operation unit.

2. ReplaceOperation:

Key: Target keyword. (Must be unique in the same list operation)

Value: Replacement value.

Values: Replacement value collection.

Do: The operations performed.

3. ListOperation:

ListName: List name. (Must be unique)

ReplaceOpts: Replacement operation collection.

Do: The operations performed.

4. OperationHelper:

GetListCount: Get the number of elements in the list.

GetListTemplate: Get the list template.

ReplaceList: Get the list template

GetListTemplate: The replacement content of list operation.

IsVariable: Determine whether it is a variable.

5. GenerateHelper:

GetTemplate: Get the template.

GetSetting: Get the configuration.

GenerateCodeToFile: Generate the code and write it to the file.

GenerateCode: Generate code.

2. Template grammar:

Identification of replacement operation: $Key$

Identification of list operation: $list_begin ListName, $list_end ListName

3. Implementation logic: (GenerateCode)

  1. If Operation is not empty, the child operation will be executed.
  2. Perform the replacement operation.
  3. Perform the list operation.

4. Example:

  1. Simple replacement:

Template:

#ifndef $title$_h
#define $title$_h

// Capital letters:
$list_begin ABC
#define $word$_$size$ {$data$}
$list_end ABC

// Lowercase letter:
$list_begin abc
#define $word$_$size$ {$data$}
$list_end abc

// Number:
$list_begin Num
#define $word$_$size$ {$data$}
$list_end Num

#endif

Configuration:

{
  "ReplaceOpts": [
    {
      "Key": "title",
      "Value": "Words3x6",
      "Values": []
    }
  ],
  "ListOpts": [
    {
      "ListName": "ABC",
      "ReplaceOpts": [
        {
          "Key": "word",
          "Value": "$word$",
          "Values": [
            "A",
            "B",
            "C"
          ]
        },
        {
          "Key": "size",
          "Value": "3x6",
          "Values": []
        },
        {
          "Key": "data",
          "Value": "$data$",
          "Values": [
            "1",
            "2",
            "3"
          ]
        }
      ]
    },
    {
      "ListName": "abc",
      "ReplaceOpts": [
        {
          "Key": "word",
          "Value": "$word$",
          "Values": [
            "a",
            "b",
            "c"
          ]
        },
        {
          "Key": "size",
          "Value": "3x6",
          "Values": []
        },
        {
          "Key": "data",
          "Value": "$data$",
          "Values": [
            "1",
            "2",
            "3"
          ]
        }
      ]
    },
    {
      "ListName": "Num",
      "ReplaceOpts": [
        {
          "Key": "word",
          "Value": "$word$",
          "Values": [
            "Num0",
            "Num1",
            "Num2"
          ]
        },
        {
          "Key": "size",
          "Value": "3x6",
          "Values": []
        },
        {
          "Key": "data",
          "Value": "$data$",
          "Values": [
            "1",
            "2",
            "3"
          ]
        }
      ]
    }
  ],
  "Operation": null
}

Output:

#ifndef Words3x6_h
#define Words3x6_h

// Capital letters:
#define A_3x6 {1}
#define B_3x6 {2}
#define C_3x6 {3}

// Lowercase letter:
#define a_3x6 {1}
#define b_3x6 {2}
#define c_3x6 {3}

// Number:
#define Num0_3x6 {1}
#define Num1_3x6 {2}
#define Num2_3x6 {3}

#endif
  1. List nesting:

Template:

#ifndef ListNesting_h
#define ListNesting_h

$list_begin Classes
class $ClassName$
{
private:
public:
$list_begin Fields
    int $FieldName$ = $FieldValue$;
$list_end Fields
};

$list_end Classes

#endif

Configuration:

{
  "ReplaceOpts": [],
  "ListOpts": [
    {
      "ListName": "Classes",
      "ReplaceOpts": [
        {
          "Key": "ClassName",
          "Value": "$ClassName$",
          "Values": [
            "ClassA",
            "ClassB",
            "ClassC"
          ]
        }
      ]
    }
  ],
  "Operation": {
    "ReplaceOpts": [],
    "ListOpts": [
      {
        "ListName": "Fields",
        "ReplaceOpts": [
          {
            "Key": "FieldName",
            "Value": "$FieldName$",
            "Values": [
              "FieldA",
              "FieldB",
              "FieldC"
            ]
          },
          {
            "Key": "FieldValue",
            "Value": "$FieldValue$",
            "Values": [
              "1",
              "2",
              "3"
            ]
          }
        ]
      }
    ],
    "Operation": null
  }
}

Output:

#ifndef ListNesting_h
#define ListNesting_h

class ClassA
{
private:
public:
    int FieldA = 1;
    int FieldB = 2;
    int FieldC = 3;
};

class ClassB
{
private:
public:
    int FieldA = 1;
    int FieldB = 2;
    int FieldC = 3;
};

class ClassC
{
private:
public:
    int FieldA = 1;
    int FieldB = 2;
    int FieldC = 3;
};

#endif
Product Compatible and additional computed target framework versions.
.NET 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 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. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 63 6/21/2025