Reputation: 480
When building my ASP.NET core Web API project, I'm getting the following warning:
1>CSC : warning AD0001: Analyzer 'Microsoft.AspNetCore.Mvc.Api.Analyzers.ApiConventionAnalyzer' threw an exception of type 'System.ArgumentNullException' with message 'Value cannot be null. (Parameter 'target')'.
I'm using Rider to build the application. Any thoughts on what this error might mean? Or where to look for these "Value cannot be null" instances.
What does analyzer do, and how does it report these errors?
Upvotes: 0
Views: 1287
Reputation: 480
The error was caused by returning null from a controller method expecting to return an ActionResult.
It’s a good idea to keep IncludeOpenAPIAnalyzers as true, this helps you with hints to add a response type corresponding to the helper method used. For example: BadRequest().
The error I received wasn’t too helpful when figuring out where was that warning being raised.
Upvotes: 1