Skip to content

Improving Developer Experience: C# Source Generator #330

@davidngjy

Description

@davidngjy

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:

  1. A NuGet package that contains .avsc files, using AdditionalFiles to include them as part of the build process.
  2. A NuGet package that discovers any available .avsc files and generates the corresponding C# models.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions