C#C
C#4y ago
ero

Creating and using an incremental source generator

I wanna create an incremental source generator for my web API project, but I cannot for the life of me understand how to create a source generator at all. I'm even having a hard time understanding the documentation that does exist. Is there anyone that's able to help?

I have a pretty clear idea of what I wanna do: I have a collection of HTTP endpoints in one class, which get turned into controllers, commands, and DTOs.

namespace Endpoints;

[GenerateHttpEndpoints] // better name ideas?
public partial class User
{
  [HttpPost("/api/users")]
  public async Task<ActionResult<Entities.User>> Create(
    string name,
    string email,
    string password)
  {
    // ...

    return Ok(createdUser);
  }
}

UserEndpoints.g.cs
file record CreateUserDto(
  string Name,
  string Email,
  string Password);

// other things related to handling the command
Was this page helpful?