-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
Priority:2Work that is important, but not critical for the releaseWork that is important, but not critical for the releasearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-minimal-actionsController-like actions for endpoint routingController-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*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Today, if you want to support an optional parameter with BindAsync, you cannot use a nullable struct. Instead you must use a reference type.
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// cloudEvent will be inferred to come from a Json request body because no BindAsync method will
// be found on Nullable<CloudEventStruct> and RequestDelegateFactory doesn't try to unwrap the nullable.
app.MapGet("/webhook", (CloudEventStruct? cloudEvent) =>
{
redis.Publish(cloudEvent);
});
app.Run();
public struct CloudEventStruct
{
// This will NOT be matched because it returns returns a ValueTask<CloudEventStruct?>
// instead of ValueTask<CloudEventStruct>
public static async ValueTask<CloudEventStruct?> BindAsync(HttpContext context, ParameterInfo parameter)
{
return await CloudEventParser.ReadEventAsync(context, parameter.Name);
}
}This tracks adding support for nullable-struct parameters and nullable-struct-returning BindAsync methods.
Metadata
Metadata
Labels
Priority:2Work that is important, but not critical for the releaseWork that is important, but not critical for the releasearea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-minimal-actionsController-like actions for endpoint routingController-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*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels