Skip to content

Replace Spyglass reflection-based discovery with compile-time code generation  #494

@qodo-free-for-open-source-projects

Description

Description

  • The current Spyglass API uses runtime reflection to discover aggregates and states, which is slow and incompatible with AOT compilation
  • Need to shift discovery to compile-time using Roslyn incremental source generators
  • Must support both traditional aggregates and standalone state types for functional command services
  • Generated code should auto-register via module initializers with no DI setup required

Deliverables

  • Generator Implementation — Create SpyglassGenerator incremental source generator that discovers Aggregate<T> and State<T> types at compile-time
  • Registry System — Implement static SpyglassRegistry to hold discovered types and their metadata (methods, events, load delegates)
  • API Refactoring — Update SpyglassApi endpoints to query registry instead of using reflection-based InsidePeek
  • Standalone States — Support registration of state-only types without aggregates for functional patterns
  • Comprehensive Tests — Add unit tests for generator discovery logic and integration tests for API endpoints

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions