Path: redb-route/redb.Route.Controllers/ActionInvoker.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Controllers/ActionInvoker.cs
----
using System.Reflection;
using System.Runtime.ExceptionServices;
namespace redb.Route.Controllers;
///
/// Invokes a controller action and turns what it returned into the value the reply carries. Every dispatcher and
/// the direct-invoke DSL overloads go through here, so an action behaves the same behind every transport.
///
internal static class ActionInvoker
{
///
/// Calls on , awaits it when it is asynchronous, and
/// returns its result: null for void, and .
///
/// The shape is read from the method's DECLARED return type, as ASP.NET Core's ObjectMethodExecutor
/// does. The run-time type cannot tell: an async Task method returns a Task<VoidTaskResult>,
/// whose runtime-internal result then reached the reply as a body; and a is a
/// struct that is not a at all, so it reached the reply unawaited.
///
///
/// An exception the action throws synchronously arrives wrapped in by
/// ; exactly that one wrapper is removed and the action's own
/// exception is rethrown with its stack trace. An asynchronous action's exception comes out of the awaited
/// task as it is. Nothing below that level is unwrapped.
///
///
internal static async Task