SboxSuperuser/Engine/CommandDiscovery/HandlerSignature3.cs

A generic command handler signature validator for handlers taking three typed parameters. It checks that a provided MethodDescription can be closed into a delegate either returning CommandResult or Task<CommandResult> by attempting to create the corresponding delegate without invoking it.

Reflection
namespace SboxSuperuser.Engine.CommandDiscovery;

internal sealed class HandlerSignature3<T1, T2, T3> : IHandlerSignature
{
	/// <summary>Checks closed delegate binding without executing the handler.</summary>
	public void Validate( Sandbox.MethodDescription method )
	{
		if ( method.ReturnType == typeof( CommandResult ) )
		{
			_ = method.CreateDelegate<Func<T1, T2, T3, CommandResult>>();
		}
		else
		{
			_ = method.CreateDelegate<Func<T1, T2, T3, Task<CommandResult>>>();
		}
	}
}