Skip to content

Commit 6f9111e

Browse files
Reduce dependency onto dynamic runtime binder (#821)
1 parent e4c7cca commit 6f9111e

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

Modules/Reflection/MethodHandler.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,17 @@ public ValueTask PrepareAsync()
244244
}
245245

246246
var type = result.GetType();
247-
248-
if (type == typeof(ValueTask) || type == typeof(Task))
249-
{
250-
dynamic task = result;
251-
252-
await task;
253247

254-
return null;
255-
}
256-
257-
if (type.IsAsyncGeneric())
248+
if (!type.IsAsync())
258249
{
259-
dynamic task = result;
260-
261-
await task;
262-
263-
return type.IsGenericallyVoid() ? null : task.Result;
264-
250+
return result;
265251
}
266252

267-
return result;
253+
await (result as dynamic);
254+
255+
var resultProperty = result.GetType().GetProperty("Result");
256+
257+
return resultProperty?.GetValue(result);
268258
}
269259

270260
private static async ValueTask<IResponse?> RenderCompilationErrorAsync(IRequest request, CodeGenerationException error)

Playground/GenHTTP.Playground.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@
4949
<ProjectReference Include="..\Testing\Acceptance\GenHTTP.Testing.Acceptance.csproj" />
5050

5151
</ItemGroup>
52-
52+
5353
</Project>

0 commit comments

Comments
 (0)