Files
git.stella-ops.org/docs/features/checked/router/roslyn-endpoint-source-generator.md
2026-02-14 09:11:48 +02:00

1.3 KiB

Roslyn Endpoint Source Generator (AOT-Compatible)

Module

Router

Status

IMPLEMENTED

Description

Roslyn incremental source generator that detects [StellaEndpoint] attributes at compile time and generates AOT-compatible endpoint registration code, eliminating runtime reflection for endpoint discovery. Supports Native AOT deployment scenarios.

Implementation Details

  • Modules: src/Router/__Libraries/StellaOps.Microservice.SourceGen/
  • Key Classes:
    • StellaEndpointGenerator (src/Router/__Libraries/StellaOps.Microservice.SourceGen/StellaEndpointGenerator.cs) - Roslyn incremental source generator detecting [StellaEndpoint] attributes and generating StellaEndpoints registration class
  • Interfaces: IIncrementalGenerator (Roslyn API)
  • Source: batch_52/file_10.md

E2E Test Plan

  • Compile a project with [StellaEndpoint] attributes and verify the source generator produces registration code
  • Verify generated code is AOT-compatible: publish with Native AOT and confirm endpoints are discoverable without reflection
  • Verify the generated StellaEndpoints class registers all annotated endpoints
  • Add a new [StellaEndpoint] and verify incremental generation updates the output
  • Verify compile-time diagnostics: use invalid attribute parameters and confirm helpful error messages