You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning AD0001 : Analyzer 'Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer' NullReferenceException due to dynamic in method signature #61319
Warning is shown when building a webapp that uses a dynamic parameter in a minimal API endpoint.
AD0001: Analyzer 'Microsoft.AspNetCore.Analyzers.RouteHandlers.RouteHandlerAnalyzer' threw an exception of type 'System.NullReferenceException' with message 'Object reference not set to an instance of an object.'.
Expected Behavior
No warning.
Steps To Reproduce
A minimal API webapp, with the following type of endpoint:
endpointRouteBuilder.MapPost("/blah",async(
...variousparams ...[FromBody]dynamicsomeOtherThing)=>{
... do stuff ...});
The [FromBody] is not really important. Same thing if I remove it.
It seems to be the dynamic parameter that causes it.
I know that using a dynamic here is kinda strange, but I have configured the services (via services.ConfigureHttpJsonOptions) with a custom JSON converter than can convert data to a dynamic.
Weirdly, after seeing this warning, repeating the operation (e.g. dotnet build) completes without the warning. It seems to only occur once immediately after a code change.