An open API service indexing awesome lists of open source software.

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

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";
}
```