Skip to content

Commit 039733c

Browse files
authored
Update check in BindAsync and Mvc.ApiExplorer test
1 parent 0e8360e commit 039733c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ private static Expression BindParameterFromBindAsync(ParameterInfo parameter, Fa
816816
{
817817
// We reference the boundValues array by parameter index here
818818
var nullability = NullabilityContext.Create(parameter);
819-
var isOptional = parameter.HasDefaultValue || nullability.ReadState == NullabilityState.Nullable;
819+
var isOptional = IsOptionalParameter(parameter);
820820

821821
// Get the BindAsync method
822822
var body = TryParseMethodCache.FindBindAsyncMethod(parameter.ParameterType)!;

src/Mvc/Mvc.ApiExplorer/test/EndpointMetadataApiDescriptionProviderTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public void AddsMultipleParameters()
340340
Assert.Equal(typeof(InferredJsonClass), fromBodyParam.Type);
341341
Assert.Equal(typeof(InferredJsonClass), fromBodyParam.ModelMetadata.ModelType);
342342
Assert.Equal(BindingSource.Body, fromBodyParam.Source);
343-
Assert.True(fromBodyParam.IsRequired);
343+
Assert.False(fromBodyParam.IsRequired); // Reference type in oblivious nullability context
344344
}
345345

346346
[Fact]

0 commit comments

Comments
 (0)