ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
132 stars 49 forks source link

Enable code generation of DescriptionAttribute #292

Closed runerys closed 6 months ago

runerys commented 7 months ago

I actually have one more for you. I'm not really sure that this is needed, but I implemented it as a customization here about 2 years ago, and might as well offer it to you in case it is interesting.

It's actually 2 features:

1) Code Generate [DescriptionAttribute] When generating code, in addition to generating a summary comment - also generate a DescriptionAttribute (for class, field, properties and enums). It might not be strictly necessary, but it felt symmetric since the schema generation reads it from this attribute.

2) Add code generation test project Chr.Avro.Codegen.Tests This is quite fun, actually. When I wanted to test my customization of the code generation, I found a way to compile the generated code on-the-fly, load the types and assert that the description attributes was generated with correct content. I also assert that the generated type is compatible with the given Avro schema.

No hard feelings if this is overkill, and the PR is turned down :)

runerys commented 7 months ago

I've rolled back the tests from this branch now - and added an enable-parameter (default false) to the code generation.