-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Milestone
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
KennethHoff, Ramstad, jofford, madskonradsen, erwinkramer and 3 more
Metadata
Metadata
Assignees
Labels
analyzerIndicates an issue which is related to analyzer experienceIndicates an issue which is related to analyzer experiencearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc