https://github.com/usausa/common-code-generator
🐰Common code generator.
https://github.com/usausa/common-code-generator
codegenerator source-generator source-generators sourcegenerator
Last synced: about 1 month 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 (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-10T04:07:08.000Z (4 months ago)
- Last Synced: 2025-05-03T17:48:42.707Z (about 2 months ago)
- Topics: codegenerator, source-generator, source-generators, sourcegenerator
- Language: C#
- Homepage:
- Size: 106 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
[](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);
```