Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
AspNetCore Analyzer throws warning due to usage of generics in minimal API:
1>CSC: Warning AD0001 : Analyzer 'Microsoft.AspNetCore.Analyzers.RouteHandlers.Route HandlerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Expected Behavior
This all works fine when running it, the analyzer is just not pleased with the usage of generics. Switching TEndpointInput to a concrete type such as DummyEndpointInput of course also make the warning disappear.
Steps To Reproduce
Or simply:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
static void UseEndpoint<TEndpointInput>(WebApplication app) where TEndpointInput : class
{
app.MapPost("/test", (TEndpointInput data) => Results.Ok(data));
}
UseEndpoint<DummyEndpointInput>(app);
app.Run();
public class DummyEndpointInput
{
}
Exceptions (if any)
No response
.NET Version
8.0.303
Anything else?
No response