mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 16:58:01 +01:00
Tweaks
This commit is contained in:
@@ -69,29 +69,47 @@ public static class ExampleRunner
|
||||
}
|
||||
|
||||
ParameterInfo [] parameters = entryPoint.GetParameters ();
|
||||
object? result = null;
|
||||
|
||||
if (parameters.Length == 0)
|
||||
Task executionTask = Task.Run (() =>
|
||||
{
|
||||
result = entryPoint.Invoke (null, null);
|
||||
}
|
||||
else if (parameters.Length == 1 && parameters [0].ParameterType == typeof (string []))
|
||||
{
|
||||
result = entryPoint.Invoke (null, [Array.Empty<string> ()]);
|
||||
}
|
||||
else
|
||||
object? result = null;
|
||||
|
||||
if (parameters.Length == 0)
|
||||
{
|
||||
result = entryPoint.Invoke (null, null);
|
||||
}
|
||||
else if (parameters.Length == 1 && parameters [0].ParameterType == typeof (string []))
|
||||
{
|
||||
result = entryPoint.Invoke (null, [Array.Empty<string> ()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException ("Entry point has unsupported signature");
|
||||
}
|
||||
|
||||
// If entry point returns Task, wait for it
|
||||
if (result is Task task)
|
||||
{
|
||||
task.GetAwaiter ().GetResult ();
|
||||
}
|
||||
});
|
||||
|
||||
bool completed = executionTask.Wait (context.TimeoutMs);
|
||||
|
||||
if (!completed)
|
||||
{
|
||||
// reset terminal
|
||||
Console.Clear ();
|
||||
return new ()
|
||||
{
|
||||
Success = false,
|
||||
ErrorMessage = "Entry point has unsupported signature"
|
||||
TimedOut = true
|
||||
};
|
||||
}
|
||||
|
||||
// If entry point returns Task, wait for it
|
||||
if (result is Task task)
|
||||
if (executionTask.Exception is { })
|
||||
{
|
||||
task.GetAwaiter ().GetResult ();
|
||||
throw executionTask.Exception.GetBaseException ();
|
||||
}
|
||||
|
||||
return new ()
|
||||
|
||||
Reference in New Issue
Block a user