Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

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);
```