Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/usausa/common-code-generator
Common code generator.
https://github.com/usausa/common-code-generator
codegenerator csharp dotnet source-generator source-generators sourcegenerator
Last synced: 24 days ago
JSON representation
Common code generator.
- Host: GitHub
- URL: https://github.com/usausa/common-code-generator
- Owner: usausa
- License: mit
- Created: 2024-03-03T12:18:05.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-16T12:40:11.000Z (26 days ago)
- Last Synced: 2024-11-16T13:06:49.781Z (26 days ago)
- Topics: codegenerator, csharp, dotnet, source-generator, source-generators, sourcegenerator
- Language: C#
- Homepage:
- Size: 38.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/usausa/common-code-generator
README
# CommonCodeGenerator
[![NuGet](https://img.shields.io/nuget/v/CommonCodeGenerator.svg)](https://www.nuget.org/packages/CommonCodeGenerator)
## Reference
Add reference to CommonCodeGenerator and CommonCodeGenerator.SourceGenerator to csproj.
```xml
all
runtime; build; native; contentfiles; analyzers; buildtransitive
```## ToString
### Source
```csharp
[GenerateToString]
public partial class Data
{
public int Id { get; set; }public string Name { get; set; } = default!;
public int[] Values { get; set; } = default!;
[IgnoreToString]
public int Ignore { get; set; }
}
```### Result
```csharp
var data = new Data { Id = 123, Name = "xyz", Values = [1, 2] };
var str = data.ToString();
Assert.Equal("{ Id = 123, Name = xyz, Values = [1, 2] }", str);
```