Skip to content

Fix MapFallback handling in RDG#67562

Merged
Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/mapfallback
Jul 2, 2026
Merged

Fix MapFallback handling in RDG#67562
Youssef1313 merged 1 commit into
mainfrom
dev/ygerges/mapfallback

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

Fixes #65992

The second condition used && incorrectly. I'm reusing a local variable to reduce duplication as well.

@Youssef1313 Youssef1313 marked this pull request as ready for review July 2, 2026 14:59
Copilot AI review requested due to automatic review settings July 2, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Request Delegate Generator (RDG) bug where MapFallback(pattern, ...) could ignore the provided pattern (causing multiple fallback endpoints to share the default {*path:nonfile} pattern and potentially trigger ambiguous matches) when RDG is enabled.

Changes:

  • Fixes the pattern-selection logic in the RDG emitter by reusing a single hasPatternParameter condition (and avoiding the incorrect && behavior).
  • Adds a regression test ensuring MapFallback endpoints preserve distinct provided route patterns under RDG.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Http/Http.Extensions/test/RequestDelegateGenerator/RequestDelegateCreationTests.cs Adds a regression test that asserts two MapFallback calls produce two RouteEndpoints with the exact provided RoutePattern.RawText values.
src/Http/Http.Extensions/gen/Microsoft.AspNetCore.Http.RequestDelegateGenerator/RequestDelegateGenerator.Emitter.cs Fixes RDG interceptor emission so MapFallback(pattern, handler) correctly passes the user-provided pattern to MapCore (and only uses the default pattern for the delegate-only overload).

@Youssef1313 Youssef1313 merged commit 0977f16 into main Jul 2, 2026
28 checks passed
@Youssef1313 Youssef1313 deleted the dev/ygerges/mapfallback branch July 2, 2026 17:42
@BrennanConroy BrennanConroy added this to the 11.0-preview7 milestone Jul 2, 2026
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.

The "pattern" paramter of Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapFallback is ignored when EnableRequestDelegateGenerator is true

4 participants