From 71f968c1388130b55b218dd397d30d0d2d93fadb Mon Sep 17 00:00:00 2001 From: mergehez Date: Fri, 25 Oct 2024 00:01:08 +0200 Subject: [PATCH] fix: async function delegates not being awaited --- InertiaNetCore/Models/InertiaProps.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/InertiaNetCore/Models/InertiaProps.cs b/InertiaNetCore/Models/InertiaProps.cs index 03a90e8..cac94c9 100644 --- a/InertiaNetCore/Models/InertiaProps.cs +++ b/InertiaNetCore/Models/InertiaProps.cs @@ -19,14 +19,18 @@ internal async Task ToProcessedProps(bool isPartial, List if(isPartial && value is not IAlwaysProp && !partials.Contains(key, StringComparer.InvariantCultureIgnoreCase)) continue; - props.Add(key, value switch + var computed = value switch { - Func> f => await f.Invoke(), Func f => f.Invoke(), Delegate d => d.DynamicInvoke(), IInvokableProp l => await l.InvokeToObject(), _ => value - }); + }; + + if (computed is Task task) + props.Add(key, await (task as dynamic)); // TODO: find a solution to avoid dynamic + else + props.Add(key, computed); } return props;