Skip to content

Introduce interface with static abstract BindAsync method for custom bound parameters of route handler delegates #40927

@DamianEdwards

Description

@DamianEdwards

C# 11 introduces support for static abstract interface members. We should update the support for custom parameter binding via a static BindAsync method in Minimal APIs to discover and invoke the BindAsync method via a newly defined interface (see below). We would continue to support the existing discovery and invocation via reflection approach we introduced in .NET 6 to maintain backwards compatibility.

public interface IBindableFromHttpContext<TSelf>
    where TSelf : class, IBindableFromHttpContext<TSelf>
{
    static abstract ValueTask<TSelf?> BindAsync(HttpContext context, ParameterInfo parameter);
}

I welcome additional interface name suggestions 😄

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcblockedThe work on this issue is blocked due to some dependencyfeature-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