File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -185,10 +185,14 @@ public static MinimalActionEndpointConventionBuilder Map(
185
185
// Add MethodInfo as metadata to assist with OpenAPI generation for the endpoint.
186
186
builder . Metadata . Add ( action . Method ) ;
187
187
188
- // Methods defined in a top-level program are generated as statics so the delegate
189
- // target will be null. Inline lambdas are compiler generated properties so they can
190
- // be filtered that way.
191
- if ( action . Target == null || ! TypeHelper . IsCompilerGenerated ( action . Method . Name ) )
188
+ // We only add endpoint names for types that are not compiler generated since
189
+ // compiler generated types are mangled by default. This logic can be changed once
190
+ // https://github.com/dotnet/roslyn/issues/55651 is addressed. For now, this will
191
+ // not set the endpoint name metadata for:
192
+ // - Local functions
193
+ // - Inline lambdas
194
+ // - Static functions
195
+ if ( ! TypeHelper . IsCompilerGenerated ( action . Method . Name ) )
192
196
{
193
197
builder . Metadata . Add ( new EndpointNameMetadata ( action . Method . Name ) ) ;
194
198
}
Original file line number Diff line number Diff line change @@ -361,8 +361,9 @@ public void MapFallbackWithoutPath_BuildsEndpointWithLowestRouteOrder()
361
361
362
362
[ Fact ]
363
363
// This test scenario simulates methods defined in a top-level program
364
- // which are compiler generated.
365
- public void MapMethod_SetsEndpointNameForInnerMethod ( )
364
+ // which are compiler generated. This can be re-examined once
365
+ // https://github.com/dotnet/roslyn/issues/55651 is addressed.
366
+ public void MapMethod_DoesNotEndpointNameForInnerMethod ( )
366
367
{
367
368
var builder = new DefaultEndpointRouteBuilder ( new ApplicationBuilder ( new EmptyServiceProvdier ( ) ) ) ;
368
369
string InnerGetString ( ) => "TestString" ;
@@ -373,8 +374,7 @@ public void MapMethod_SetsEndpointNameForInnerMethod()
373
374
var endpoint = Assert . Single ( dataSource . Endpoints ) ;
374
375
375
376
var endpointName = endpoint . Metadata . GetMetadata < IEndpointNameMetadata > ( ) ;
376
- Assert . NotNull ( endpointName ) ;
377
- Assert . Equal ( "InnerGetString" , endpointName ? . EndpointName ) ;
377
+ Assert . Null ( endpointName ) ;
378
378
}
379
379
380
380
[ Fact ]
You can’t perform that action at this time.
0 commit comments