Code/SboxSuperuser/Engine/CommandDiscovery/HandlerSignature2.cs

A small internal class that validates a method can be bound to a closed delegate with two generic parameters T1 and T2. It checks the method's return type and attempts to create either a Func<T1, T2, CommandResult> or a Func<T1, T2, Task<CommandResult>> delegate using Sandbox.MethodDescription.CreateDelegate, without invoking the method.

Reflection
namespace SboxSuperuser.Engine.CommandDiscovery;

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