https://github.com/windperson/democodegencs
Demo using CodeGenCS to generate custom C# code
https://github.com/windperson/democodegencs
code-generation codegencs csharp dotnet
Last synced: 3 months ago
JSON representation
Demo using CodeGenCS to generate custom C# code
- Host: GitHub
- URL: https://github.com/windperson/democodegencs
- Owner: windperson
- Created: 2023-07-23T13:52:11.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-24T04:43:58.000Z (almost 3 years ago)
- Last Synced: 2025-01-27T11:12:49.791Z (over 1 year ago)
- Topics: code-generation, codegencs, csharp, dotnet
- Language: C#
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# CodeGenCS Demo
This is a test repository for using [CodeGenCS](https://github.com/CodegenCS/CodegenCS) to generate a const value class code.
1. Restore [dotnet-codegencs command line](https://github.com/CodegenCS/CodegenCS/blob/master/src/Tools/dotnet-codegencs/README.md):
```
dotnet tool restore
```
2. Run `dotnet-codegencs` command line to generate code as:
```
dotnet dotnet-codegencs template run .\ClassLibrary1\codegen_templates\GenerateConstTemplate.cs defineConst name=foo1 value=bar1 name=foo2 value=bar2 --File .\ClassLibrary1\test.cs
```
So you would get a file `test.cs` in `ClassLibrary1` project as:
```csharp
// This file is generated by CodegenCS( https://github.com/CodegenCS/CodegenCS )
namespace Generated;
///
/// Auto generated class, do not edit it directly.
///
public static class GeneratedConst
{
public const string foo1 = "bar1";
public const string foo2 = "bar2";
}
```