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: 2 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 (8 months ago)
- Default Branch: main
- Last Pushed: 2024-09-29T10:07:44.000Z (about 1 month ago)
- Last Synced: 2024-11-06T04:40:37.669Z (5 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 Badge](https://buildstats.info/nuget/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);
```