-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
I have an aspnetcore code which registers new endpoint handlers via MapGet
or MapPost
with enabled Request Delegate Generator (RDG). To support AOT scenarios, I've enabled:
<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.Http.Generated</InterceptorsNamespaces>
<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
However, dotnet format
(which is enabled in the CI) blocks the PR from merging reporting
/app/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.cs(84,9): error IL2026: Using member 'Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapGet(IEndpointRouteBuilder, String, Delegate)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. This API may perform reflection on the supplied delegate and its parameters. These types may be trimmed if not directly referenced. [/app/dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Microsoft.Agents.AI.Hosting.OpenAI.csproj]
To Reproduce
- git clone https://github.com/microsoft/agent-framework.git
- cd agent-framework
- git checkout -b dmkorolev/openai-responses origin/dmkorolev/openai-responses (or main if custom branch does not exist)
- dotnet format .\dotnet\src\Microsoft.Agents.AI.Hosting.OpenAI\Microsoft.Agents.AI.Hosting.OpenAI.csproj
It will add:
[RequiresDynamicCode("Calls Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapPost(String, Delegate)")]
[RequiresUnreferencedCode("Calls Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapPost(String, Delegate)")]
however it should not, because the RDG interceptor logic is replacing the calls to MapGet
and MapPost
Expected Behavior
dotnet format
should not report IL2026 and IL3050 because AOT is being correctly supported via RDG.