Skip to content

Commit 5696438

Browse files
author
Mirroring
committed
Merge commit 'cec987b5a685cd43478df7abf5a78893a8f2c765'
2 parents c6a133e + cec987b commit 5696438

File tree

7 files changed

+111
-4
lines changed

7 files changed

+111
-4
lines changed

.azure/pipelines/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ extends:
138138
os: windows
139139
spotBugs:
140140
enabled: false
141+
policheck:
142+
enabled: true
143+
tsa:
144+
enabled: true
141145
containers:
142146
alpine319WithNode:
143147
image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PropertyGroup Label="Version settings">
99
<AspNetCoreMajorVersion>8</AspNetCoreMajorVersion>
1010
<AspNetCoreMinorVersion>0</AspNetCoreMinorVersion>
11-
<AspNetCorePatchVersion>10</AspNetCorePatchVersion>
11+
<AspNetCorePatchVersion>11</AspNetCorePatchVersion>
1212
<PreReleaseVersionIteration>
1313
</PreReleaseVersionIteration>
1414
<ValidateBaseline>false</ValidateBaseline>

eng/targets/Helix.Common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<HelixAvailableTargetQueue Include="$(HelixQueueArmDebian12)" Platform="Linux" />
5050

5151
<!-- Mac -->
52-
<HelixAvailableTargetQueue Include="OSX.1100.Amd64.Open" Platform="OSX" />
52+
<HelixAvailableTargetQueue Include="OSX.1200.Amd64.Open" Platform="OSX" />
5353

5454
<!-- Windows -->
5555
<HelixAvailableTargetQueue Include="Windows.Amd64.Server2022.Open" Platform="Windows" />

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ private static Expression MapHandlerReturnTypeToValueTask(Expression methodCall,
533533
}
534534
else
535535
{
536+
if (returnType.IsValueType)
537+
{
538+
return Expression.Call(WrapObjectAsValueTaskMethod, Expression.Convert(methodCall, typeof(object)));
539+
}
540+
536541
return Expression.Call(WrapObjectAsValueTaskMethod, methodCall);
537542
}
538543
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Http;
5+
using Microsoft.AspNetCore.Testing;
6+
7+
namespace Microsoft.AspNetCore.Routing.Internal;
8+
9+
public partial class RequestDelegateFactoryTests : LoggedTest
10+
{
11+
public static object[][] ValueTypeReturningDelegates =>
12+
[
13+
[(Func<HttpContext, int>)((HttpContext httpContext) => 42)],
14+
[(Func<HttpContext, char>)((HttpContext httpContext) => 'b')],
15+
[(Func<HttpContext, bool>)((HttpContext httpContext) => true)],
16+
[(Func<HttpContext, float>)((HttpContext httpContext) => 4.2f)],
17+
[(Func<HttpContext, double>)((HttpContext httpContext) => 4.2)],
18+
[(Func<HttpContext, decimal>)((HttpContext httpContext) => 4.2m)],
19+
[(Func<HttpContext, long>)((HttpContext httpContext) => 42)],
20+
[(Func<HttpContext, short>)((HttpContext httpContext) => 42)],
21+
[(Func<HttpContext, byte>)((HttpContext httpContext) => 42)],
22+
[(Func<HttpContext, uint>)((HttpContext httpContext) => 42)],
23+
[(Func<HttpContext, ulong>)((HttpContext httpContext) => 42)],
24+
[(Func<HttpContext, ushort>)((HttpContext httpContext) => 42)],
25+
[(Func<HttpContext, sbyte>)((HttpContext httpContext) => 42)]
26+
];
27+
28+
[Theory]
29+
[MemberData(nameof(ValueTypeReturningDelegates))]
30+
public void Create_WithEndpointFilterOnBuiltInValueTypeReturningDelegate_Works(Delegate @delegate)
31+
{
32+
var invokeCount = 0;
33+
34+
RequestDelegateFactoryOptions options = new()
35+
{
36+
EndpointBuilder = CreateEndpointBuilderFromFilterFactories(
37+
[
38+
(routeHandlerContext, next) =>
39+
{
40+
invokeCount++;
41+
return next;
42+
},
43+
(routeHandlerContext, next) =>
44+
{
45+
invokeCount++;
46+
return next;
47+
},
48+
]),
49+
};
50+
51+
var result = RequestDelegateFactory.Create(@delegate, options);
52+
Assert.Equal(2, invokeCount);
53+
}
54+
55+
public static object[][] NullableValueTypeReturningDelegates =>
56+
[
57+
[(Func<HttpContext, int?>)((HttpContext httpContext) => 42)],
58+
[(Func<HttpContext, char?>)((HttpContext httpContext) => 'b')],
59+
[(Func<HttpContext, bool?>)((HttpContext httpContext) => true)],
60+
[(Func<HttpContext, float?>)((HttpContext httpContext) => 4.2f)],
61+
[(Func<HttpContext, double?>)((HttpContext httpContext) => 4.2)],
62+
[(Func<HttpContext, decimal?>)((HttpContext httpContext) => 4.2m)],
63+
[(Func<HttpContext, long?>)((HttpContext httpContext) => 42)],
64+
[(Func<HttpContext, short?>)((HttpContext httpContext) => 42)],
65+
[(Func<HttpContext, byte?>)((HttpContext httpContext) => 42)],
66+
[(Func<HttpContext, uint?>)((HttpContext httpContext) => 42)],
67+
[(Func<HttpContext, ulong?>)((HttpContext httpContext) => 42)],
68+
[(Func<HttpContext, ushort?>)((HttpContext httpContext) => 42)],
69+
[(Func<HttpContext, sbyte?>)((HttpContext httpContext) => 42)]
70+
];
71+
72+
[Theory]
73+
[MemberData(nameof(NullableValueTypeReturningDelegates))]
74+
public void Create_WithEndpointFilterOnNullableBuiltInValueTypeReturningDelegate_Works(Delegate @delegate)
75+
{
76+
var invokeCount = 0;
77+
78+
RequestDelegateFactoryOptions options = new()
79+
{
80+
EndpointBuilder = CreateEndpointBuilderFromFilterFactories(
81+
[
82+
(routeHandlerContext, next) =>
83+
{
84+
invokeCount++;
85+
return next;
86+
},
87+
(routeHandlerContext, next) =>
88+
{
89+
invokeCount++;
90+
return next;
91+
},
92+
]),
93+
};
94+
95+
var result = RequestDelegateFactory.Create(@delegate, options);
96+
Assert.Equal(2, invokeCount);
97+
}
98+
}

0 commit comments

Comments
 (0)