Skip to content

Commit ee13aad

Browse files
[RDG] Account of parameter name in signature comparison (#50064)
* [RDG] Account of parameter name in signature comparison * Update src/Http/Http.Extensions/test/RequestDelegateGenerator/CompileTimeCreationTests.cs Co-authored-by: Brennan <[email protected]> --------- Co-authored-by: Brennan <[email protected]>
1 parent 10bc40c commit ee13aad

File tree

5 files changed

+451
-8
lines changed

5 files changed

+451
-8
lines changed

src/Http/Http.Extensions/gen/StaticRouteHandlerModel/EndpointParameter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,11 @@ obj is EndpointParameter other &&
617617

618618
public bool SignatureEquals(object obj) =>
619619
obj is EndpointParameter other &&
620-
SymbolEqualityComparer.IncludeNullability.Equals(other.Type, Type);
620+
SymbolEqualityComparer.IncludeNullability.Equals(other.Type, Type) &&
621+
// The name of the parameter matters when we are querying for a specific parameter using
622+
// an indexer, like `context.Request.RouteValues["id"]` or `context.Request.Query["id"]`
623+
// and when generating log messages for required bodies or services.
624+
other.SymbolName == SymbolName;
621625

622626
public override int GetHashCode()
623627
{

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace Microsoft.AspNetCore.Http.Generated
162162
createRequestDelegate);
163163
}
164164

165-
[InterceptsLocation(@"TestMapActions.cs", 27, 5)]
165+
[InterceptsLocation(@"TestMapActions.cs", 26, 5)]
166166
internal static RouteHandlerBuilder MapPost1(
167167
this IEndpointRouteBuilder endpoints,
168168
[StringSyntax("Route")] string pattern,

0 commit comments

Comments
 (0)