-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is your feature request related to a problem? Please describe.
If a user wishes to use custom data binding for Minimal APIs using the BindAsync() pattern but does not require the ParameterInfo parameter when using Visual Studio, the IDE will warn about the unused parameter argument with IDE0060. I would assume that other static analyzers would produce similar warnings, though I haven't tested/validated this.
While these warnings can be ignored/suppressed on an ad-hoc basis, they create noise. Static analysis tools will not warn about such unused parameters when a method is implementing a contract using an abstract method or an interface, but as neither use case applies here, the warning fires.
Omitting the parameter breaks the contract for custom binding with Minimal APIs, so it cannot be removed without stopping the feature from working.
Describe the solution you'd like
Minimal APIs considers the ParameterInfo to be "optional" (not an optional parameter as in the formal C# language specification), so that if the parameter is not needed by the developer/implementation, it can be omitted and the custom binding behaviour will still work.
public static ValueTask<PagingData?> BindAsync(HttpContext context)