SboxSuperuser/Engine/CommandDiscovery/HandlerSignature4.cs

A generic handler signature validator for commands that take four parameters. It verifies that a MethodDescription can be bound to either a synchronous Func<T1,T2,T3,T4,CommandResult> or an asynchronous Func<T1,T2,T3,T4,Task<CommandResult>> delegate without invoking the method.

Reflection
namespace SboxSuperuser.Engine.CommandDiscovery;

internal sealed class HandlerSignature4<T1, T2, T3, T4> : 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, T4, CommandResult>>();
		}
		else
		{
			_ = method.CreateDelegate<Func<T1, T2, T3, T4, Task<CommandResult>>>();
		}
	}
}