Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Refactor RequestDelegateGenerator to use partial class pattern

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Restructure RequestDelegateGenerator to match ValidationsGenerator and OpenApiGenerator patterns

Description

Refactors RequestDelegateGenerator to use the same partial class structure as ValidationsGenerator (src/Validation/gen) and XmlCommentGenerator (src/OpenApi/gen).

Changes

  • RequestDelegateGenerator.cs — Now contains only the Initialize method (pipeline setup)
  • RequestDelegateGenerator.Parser.cs (new) — Parsing logic:
    • IsEndpointInvocation — Predicate for identifying Map* invocations
    • TransformEndpoint — Creates endpoint models from syntax contexts
  • RequestDelegateGenerator.Emitter.cs (new) — Emission logic:
    • EmitInterceptorDefinition — Generates interceptor method code
    • EmitHttpVerbs, EmitEndpointHelpers, EmitHelperTypes — Collect and emit supporting code
    • Emit — Final source output

Structure

Before:
  RequestDelegateGenerator.cs (300+ lines, all inline)

After:
  RequestDelegateGenerator.cs        (~60 lines, pipeline only)
  RequestDelegateGenerator.Parser.cs (~30 lines)
  RequestDelegateGenerator.Emitter.cs (~260 lines)

No functional changes — existing tests pass unchanged.

Original prompt

Rewrite the RequestDelegateGenerator implementation to mimic the structure of the ValidationsGenerator in src/Validation/gen and the OpenAPI generator in src/OpenApi/gen.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dotnet-policy-service
Copy link
Contributor

Greetings! You've submitted a PR that modifies code that is shared with https://github.com/dotnet/runtime . Please make sure you synchronize this code with the changes in that repo!

…alidationsGenerator and OpenApiGenerator

Co-authored-by: captainsafia <1857993+captainsafia@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor RequestDelegateGenerator structure to match ValidationsGenerator Refactor RequestDelegateGenerator to use partial class pattern Dec 12, 2025
Copilot AI requested a review from captainsafia December 12, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants