private IWidgetResult InvokeSyncCore(MethodInfo method, WidgetContext context)
{
var widget = CreateWidget(context);
object result = null;
var arguments = GetArgumentsAsync(context, method, context.Values).GetAwaiter().GetResult();
try
{
result = method.Invoke(widget, arguments);
var widgetResult = CoerceToWidgetResult(result);
return widgetResult;
}
catch (TargetInvocationException ex)
{
var exceptionInfo = ExceptionDispatchInfo.Capture(ex.InnerException);
exceptionInfo.Throw();
return null; // Unreachable
}
}