Skip to content

Support BindAsync() without ParameterInfo for Minimal APIs #36415

@martincostello

Description

@martincostello

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)

Metadata

Metadata

Assignees

Labels

Priority:2Work that is important, but not critical for the releasearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions