TigerSan.CodeGenerator
1.0.1
dotnet add package TigerSan.CodeGenerator --version 1.0.1
NuGet\Install-Package TigerSan.CodeGenerator -Version 1.0.1
<PackageReference Include="TigerSan.CodeGenerator" Version="1.0.1" />
<PackageVersion Include="TigerSan.CodeGenerator" Version="1.0.1" />
<PackageReference Include="TigerSan.CodeGenerator" />
paket add TigerSan.CodeGenerator --version 1.0.1
#r "nuget: TigerSan.CodeGenerator, 1.0.1"
#:package TigerSan.CodeGenerator@1.0.1
#addin nuget:?package=TigerSan.CodeGenerator&version=1.0.1
#tool nuget:?package=TigerSan.CodeGenerator&version=1.0.1
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
)
- If
Operation
is not empty, the child operation will be executed. - Perform the replacement operation.
- Perform the list operation.
4. Example:
- 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
- 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 | Versions 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. |
-
net8.0
- TigerSan.CsvLog (>= 1.1.0)
- TigerSan.JsonConfig (>= 1.1.0)
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 |