@@ -275,7 +275,6 @@ private static RequestDelegateFactoryContext CreateFactoryContext(RequestDelegat
275
275
EndpointBuilder = endpointBuilder ,
276
276
MetadataAlreadyInferred = metadataResult is not null ,
277
277
JsonSerializerOptions = jsonSerializerOptions ,
278
- JsonSerializerOptionsExpression = Expression . Constant ( jsonSerializerOptions , typeof ( JsonSerializerOptions ) ) ,
279
278
} ;
280
279
281
280
return factoryContext ;
@@ -1000,23 +999,20 @@ private static Expression AddResponseWritingToMethodCall(Expression methodCall,
1000
999
ExecuteAwaitedReturnMethod ,
1001
1000
methodCall ,
1002
1001
HttpContextExpr ,
1003
- factoryContext . JsonSerializerOptionsExpression ,
1004
1002
Expression . Constant ( factoryContext . JsonSerializerOptions . GetReadOnlyTypeInfo ( typeof ( object ) ) , typeof ( JsonTypeInfo < object > ) ) ) ;
1005
1003
}
1006
1004
else if ( returnType == typeof ( ValueTask < object > ) )
1007
1005
{
1008
1006
return Expression . Call ( ExecuteValueTaskOfObjectMethod ,
1009
1007
methodCall ,
1010
1008
HttpContextExpr ,
1011
- factoryContext . JsonSerializerOptionsExpression ,
1012
1009
Expression . Constant ( factoryContext . JsonSerializerOptions . GetReadOnlyTypeInfo ( typeof ( object ) ) , typeof ( JsonTypeInfo < object > ) ) ) ;
1013
1010
}
1014
1011
else if ( returnType == typeof ( Task < object > ) )
1015
1012
{
1016
1013
return Expression . Call ( ExecuteTaskOfObjectMethod ,
1017
1014
methodCall ,
1018
1015
HttpContextExpr ,
1019
- factoryContext . JsonSerializerOptionsExpression ,
1020
1016
Expression . Constant ( factoryContext . JsonSerializerOptions . GetReadOnlyTypeInfo ( typeof ( object ) ) , typeof ( JsonTypeInfo < object > ) ) ) ;
1021
1017
}
1022
1018
else if ( AwaitableInfo . IsTypeAwaitable ( returnType , out _ ) )
@@ -1068,7 +1064,6 @@ private static Expression AddResponseWritingToMethodCall(Expression methodCall,
1068
1064
ExecuteTaskOfTMethod . MakeGenericMethod ( typeArg ) ,
1069
1065
methodCall ,
1070
1066
HttpContextExpr ,
1071
- factoryContext . JsonSerializerOptionsExpression ,
1072
1067
Expression . Constant ( jsonTypeInfo , typeof ( JsonTypeInfo < > ) . MakeGenericType ( typeArg ) ) ) ;
1073
1068
}
1074
1069
}
@@ -1109,7 +1104,6 @@ private static Expression AddResponseWritingToMethodCall(Expression methodCall,
1109
1104
ExecuteValueTaskOfTMethod . MakeGenericMethod ( typeArg ) ,
1110
1105
methodCall ,
1111
1106
HttpContextExpr ,
1112
- factoryContext . JsonSerializerOptionsExpression ,
1113
1107
Expression . Constant ( jsonTypeInfo , typeof ( JsonTypeInfo < > ) . MakeGenericType ( typeArg ) ) ) ;
1114
1108
}
1115
1109
}
@@ -1154,7 +1148,6 @@ private static Expression AddResponseWritingToMethodCall(Expression methodCall,
1154
1148
JsonResultWriteResponseOfTAsyncMethod . MakeGenericMethod ( returnType ) ,
1155
1149
HttpResponseExpr ,
1156
1150
methodCall ,
1157
- factoryContext . JsonSerializerOptionsExpression ,
1158
1151
Expression . Constant ( jsonTypeInfo , typeof ( JsonTypeInfo < > ) . MakeGenericType ( returnType ) ) ) ;
1159
1152
}
1160
1153
}
@@ -2107,39 +2100,39 @@ private static MemberInfo GetMemberInfo<T>(Expression<T> expr)
2107
2100
// if necessary and restart the cycle until we've reached a terminal state (unknown type).
2108
2101
// We currently don't handle Task<unknown> or ValueTask<unknown>. We can support this later if this
2109
2102
// ends up being a common scenario.
2110
- private static Task ExecuteValueTaskOfObject ( ValueTask < object > valueTask , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < object > jsonTypeInfo )
2103
+ private static Task ExecuteValueTaskOfObject ( ValueTask < object > valueTask , HttpContext httpContext , JsonTypeInfo < object > jsonTypeInfo )
2111
2104
{
2112
- static async Task ExecuteAwaited ( ValueTask < object > valueTask , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < object > jsonTypeInfo )
2105
+ static async Task ExecuteAwaited ( ValueTask < object > valueTask , HttpContext httpContext , JsonTypeInfo < object > jsonTypeInfo )
2113
2106
{
2114
- await ExecuteAwaitedReturn ( await valueTask , httpContext , options , jsonTypeInfo ) ;
2107
+ await ExecuteAwaitedReturn ( await valueTask , httpContext , jsonTypeInfo ) ;
2115
2108
}
2116
2109
2117
2110
if ( valueTask . IsCompletedSuccessfully )
2118
2111
{
2119
- return ExecuteAwaitedReturn ( valueTask . GetAwaiter ( ) . GetResult ( ) , httpContext , options , jsonTypeInfo ) ;
2112
+ return ExecuteAwaitedReturn ( valueTask . GetAwaiter ( ) . GetResult ( ) , httpContext , jsonTypeInfo ) ;
2120
2113
}
2121
2114
2122
- return ExecuteAwaited ( valueTask , httpContext , options , jsonTypeInfo ) ;
2115
+ return ExecuteAwaited ( valueTask , httpContext , jsonTypeInfo ) ;
2123
2116
}
2124
2117
2125
- private static Task ExecuteTaskOfObject ( Task < object > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < object > jsonTypeInfo )
2118
+ private static Task ExecuteTaskOfObject ( Task < object > task , HttpContext httpContext , JsonTypeInfo < object > jsonTypeInfo )
2126
2119
{
2127
- static async Task ExecuteAwaited ( Task < object > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < object > jsonTypeInfo )
2120
+ static async Task ExecuteAwaited ( Task < object > task , HttpContext httpContext , JsonTypeInfo < object > jsonTypeInfo )
2128
2121
{
2129
- await ExecuteAwaitedReturn ( await task , httpContext , options , jsonTypeInfo ) ;
2122
+ await ExecuteAwaitedReturn ( await task , httpContext , jsonTypeInfo ) ;
2130
2123
}
2131
2124
2132
2125
if ( task . IsCompletedSuccessfully )
2133
2126
{
2134
- return ExecuteAwaitedReturn ( task . GetAwaiter ( ) . GetResult ( ) , httpContext , options , jsonTypeInfo ) ;
2127
+ return ExecuteAwaitedReturn ( task . GetAwaiter ( ) . GetResult ( ) , httpContext , jsonTypeInfo ) ;
2135
2128
}
2136
2129
2137
- return ExecuteAwaited ( task , httpContext , options , jsonTypeInfo ) ;
2130
+ return ExecuteAwaited ( task , httpContext , jsonTypeInfo ) ;
2138
2131
}
2139
2132
2140
- private static Task ExecuteAwaitedReturn ( object obj , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < object > jsonTypeInfo )
2133
+ private static Task ExecuteAwaitedReturn ( object obj , HttpContext httpContext , JsonTypeInfo < object > jsonTypeInfo )
2141
2134
{
2142
- return ExecuteHandlerHelper . ExecuteReturnAsync ( obj , httpContext , options , jsonTypeInfo ) ;
2135
+ return ExecuteHandlerHelper . ExecuteReturnAsync ( obj , httpContext , jsonTypeInfo ) ;
2143
2136
}
2144
2137
2145
2138
private static Task ExecuteTaskOfTFast < T > ( Task < T > task , HttpContext httpContext , JsonTypeInfo < T > jsonTypeInfo )
@@ -2159,21 +2152,21 @@ static async Task ExecuteAwaited(Task<T> task, HttpContext httpContext, JsonType
2159
2152
return ExecuteAwaited ( task , httpContext , jsonTypeInfo ) ;
2160
2153
}
2161
2154
2162
- private static Task ExecuteTaskOfT < T > ( Task < T > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < T > jsonTypeInfo )
2155
+ private static Task ExecuteTaskOfT < T > ( Task < T > task , HttpContext httpContext , JsonTypeInfo < T > jsonTypeInfo )
2163
2156
{
2164
2157
EnsureRequestTaskNotNull ( task ) ;
2165
2158
2166
- static async Task ExecuteAwaited ( Task < T > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < T > jsonTypeInfo )
2159
+ static async Task ExecuteAwaited ( Task < T > task , HttpContext httpContext , JsonTypeInfo < T > jsonTypeInfo )
2167
2160
{
2168
- await WriteJsonResponse ( httpContext . Response , await task , options , jsonTypeInfo ) ;
2161
+ await WriteJsonResponse ( httpContext . Response , await task , jsonTypeInfo ) ;
2169
2162
}
2170
2163
2171
2164
if ( task . IsCompletedSuccessfully )
2172
2165
{
2173
- return WriteJsonResponse ( httpContext . Response , task . GetAwaiter ( ) . GetResult ( ) , options , jsonTypeInfo ) ;
2166
+ return WriteJsonResponse ( httpContext . Response , task . GetAwaiter ( ) . GetResult ( ) , jsonTypeInfo ) ;
2174
2167
}
2175
2168
2176
- return ExecuteAwaited ( task , httpContext , options , jsonTypeInfo ) ;
2169
+ return ExecuteAwaited ( task , httpContext , jsonTypeInfo ) ;
2177
2170
}
2178
2171
2179
2172
private static Task ExecuteTaskOfString ( Task < string ? > task , HttpContext httpContext )
@@ -2264,19 +2257,19 @@ static async Task ExecuteAwaited(ValueTask<T> task, HttpContext httpContext, Jso
2264
2257
return ExecuteAwaited ( task , httpContext , jsonTypeInfo ) ;
2265
2258
}
2266
2259
2267
- private static Task ExecuteValueTaskOfT < T > ( ValueTask < T > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < T > jsonTypeInfo )
2260
+ private static Task ExecuteValueTaskOfT < T > ( ValueTask < T > task , HttpContext httpContext , JsonTypeInfo < T > jsonTypeInfo )
2268
2261
{
2269
- static async Task ExecuteAwaited ( ValueTask < T > task , HttpContext httpContext , JsonSerializerOptions options , JsonTypeInfo < T > jsonTypeInfo )
2262
+ static async Task ExecuteAwaited ( ValueTask < T > task , HttpContext httpContext , JsonTypeInfo < T > jsonTypeInfo )
2270
2263
{
2271
- await WriteJsonResponse ( httpContext . Response , await task , options , jsonTypeInfo ) ;
2264
+ await WriteJsonResponse ( httpContext . Response , await task , jsonTypeInfo ) ;
2272
2265
}
2273
2266
2274
2267
if ( task . IsCompletedSuccessfully )
2275
2268
{
2276
- return WriteJsonResponse ( httpContext . Response , task . GetAwaiter ( ) . GetResult ( ) , options , jsonTypeInfo ) ;
2269
+ return WriteJsonResponse ( httpContext . Response , task . GetAwaiter ( ) . GetResult ( ) , jsonTypeInfo ) ;
2277
2270
}
2278
2271
2279
- return ExecuteAwaited ( task , httpContext , options , jsonTypeInfo ) ;
2272
+ return ExecuteAwaited ( task , httpContext , jsonTypeInfo ) ;
2280
2273
}
2281
2274
2282
2275
private static Task ExecuteValueTaskOfString ( ValueTask < string ? > task , HttpContext httpContext )
@@ -2328,9 +2321,9 @@ private static async Task ExecuteResultWriteResponse(IResult? result, HttpContex
2328
2321
private static Task WriteJsonResponseFast < T > ( HttpResponse response , T value , JsonTypeInfo < T > jsonTypeInfo )
2329
2322
=> HttpResponseJsonExtensions . WriteAsJsonAsync ( response , value , jsonTypeInfo , default ) ;
2330
2323
2331
- private static Task WriteJsonResponse < T > ( HttpResponse response , T ? value , JsonSerializerOptions options , JsonTypeInfo < T > jsonTypeInfo )
2324
+ private static Task WriteJsonResponse < T > ( HttpResponse response , T ? value , JsonTypeInfo < T > jsonTypeInfo )
2332
2325
{
2333
- return ExecuteHandlerHelper . WriteJsonResponseAsync ( response , value , options , jsonTypeInfo ) ;
2326
+ return ExecuteHandlerHelper . WriteJsonResponseAsync ( response , value , jsonTypeInfo ) ;
2334
2327
}
2335
2328
2336
2329
private static NotSupportedException GetUnsupportedReturnTypeException ( Type returnType )
0 commit comments