-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Hi,
I’d like to suggest a way to improve the developer experience when converting schemas to C# models. As I'm aware, there is currently a CLI tool to generate the C# model, which can be checked in manually or automated via a pipeline.
(If there are any other approaches I'm unaware of, please let me know!)
With the advent of C# source generators and more recently incremental source generators, I see an opportunity for the C# model to be generated at compile time from the .avsc
file (as long as it's discoverable by the project – for example, by including it as part of the build).
This approach could greatly enhance the developer experience, as the C# model would be automatically available once the .avsc
file is discovered by the source generator, with the proper annotations in place as well (making it foolproof).
The Idea:
- A NuGet package that contains .avsc files, using AdditionalFiles to include them as part of the build process.
- A NuGet package that discovers any available .avsc files and generates the corresponding C# models.
- A host (web, console, etc.) project that references both NuGet packages, making the generated C# models available.
Note: It’s possible to skip step (1) if the service isn’t sharing schemas and has them included as part of the host project.
Does this feature align with the vision of the library? I'd be happy to contribute! I have a small proof of concept that works, though it has limited support for types. If you're interested, I’d be glad to share it for the discussion.