Skip to content

Implement MintPlayer.AspNetCore.Endpoints library#27

Merged
PieterjanDeClippel merged 5 commits intomasterfrom
feature/endpoints-library
Mar 15, 2026
Merged

Implement MintPlayer.AspNetCore.Endpoints library#27
PieterjanDeClippel merged 5 commits intomasterfrom
feature/endpoints-library

Conversation

@PieterjanDeClippel
Copy link
Copy Markdown
Member

@PieterjanDeClippel PieterjanDeClippel commented Mar 15, 2026

Summary

  • Implements the class-per-endpoint mapping library as designed in the PRD (Add PRD for MintPlayer.AspNetCore.Endpoints library #26)
  • Abstractions: IEndpointBase, IEndpoint, IEndpoint<T>, IEndpoint<T,R>, convenience interfaces (GET/POST/PUT/DELETE/PATCH × 3 variants), IEndpointGroup + IMemberOf<TGroup>, attributes, EndpointDescriptor
  • Runtime: Abstract base class hierarchy — BodyEndpoint<T> with MVC input formatter content negotiation + JSON fallback, NonBodyEndpoint<T> with forced explicit binding, MapEndpoint<T>() manual registration
  • Generator: IIncrementalGenerator that discovers endpoints, generates partial class base declarations and MapXxxEndpoints() extension with factory caching, try/finally disposal, attribute transfer, route groups, and .Produces<TResponse>() for OpenAPI

Key design points

  • Static abstract interface members for compile-time route enforcement (no instance at startup)
  • Partial class trick: user writes partial class X : IPostEndpoint<T>, generator adds partial class X : PostEndpoint<T>
  • Generic helpers in generated code to access static abstract members through constraints
  • Content negotiation transparent to endpoint (JSON/XML/custom via MVC formatters)
  • Diagnostics: MPEP001 (non-partial), MPEP002 (base class conflict), MPEP003 (multiple groups)

Test plan

  • Build passes for all three projects (verified locally)
  • Full solution build succeeds with no new warnings
  • Create a sample app to validate source generator output (Phase 3)
  • Verify partial class generation, mapping extension, content negotiation, disposal, groups, attributes

🤖 Generated with Claude Code

PieterjanDeClippel and others added 5 commits March 15, 2026 21:44
Three-package implementation for class-per-endpoint mapping:

- Abstractions: interfaces (IEndpointBase, IEndpoint, IEndpoint<T>,
  IEndpoint<T,R>), convenience interfaces (IGet/Post/Put/Delete/Patch),
  IEndpointGroup + IMemberOf<T> for route groups, attributes, descriptor

- Runtime: abstract base class hierarchy (EndpointBase<T> -> BodyEndpoint<T>
  with MVC input formatter content negotiation + JSON fallback,
  NonBodyEndpoint<T> with forced explicit binding), concrete HTTP method
  classes, MapEndpoint<T> manual registration extension

- Generator: IIncrementalGenerator that discovers endpoints, generates
  partial class base declarations (Task A) and MapXxxEndpoints() extension
  method with factory caching, disposal, attribute transfer, group support,
  and .Produces<TResponse>() for OpenAPI (Task B)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Tools

- Rewrote generator to use IncrementalGenerator base class and Producer
  pattern with IndentedTextWriter/OpenBlock from MintPlayer.SourceGenerators.Tools
- Fixed ObjectFactory<T> type (was incorrectly using Func<...>)
- Removed Emitter.cs, replaced with EndpointGenerator.Producer.cs
- Added TestApp exercising all endpoint types:
  - Raw GET (HealthCheck)
  - POST with typed request+response in group (CreateUser)
  - GET with explicit binding in group (GetUser)
  - PUT with body parsing in group (UpdateUser)
  - DELETE with explicit binding in group (DeleteUser)
  - Raw GET in group (ListUsers)
  - Multi-method endpoint (PreflightEndpoint)
  - Route group with tags (UsersApi)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix BodyEndpoint content negotiation to guard on IModelMetadataProvider
- Apply [assembly: EndpointsMethodName] in test app
- Pack generator + dependencies into analyzers/dotnet/cs of runtime package
- Add comprehensive README.md included in NuGet package

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add GroupInfo model and second syntax provider for group-to-parent discovery
- Groups can implement IMemberOf<TParentGroup> for nesting
- Generator builds group tree and emits nested MapGroup calls
- Add ApiGroup, ProductsApi, and ListProducts to test app
- Update README with nested groups documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@PieterjanDeClippel PieterjanDeClippel merged commit 59eeda5 into master Mar 15, 2026
2 checks passed
@PieterjanDeClippel PieterjanDeClippel deleted the feature/endpoints-library branch March 15, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant