This question is partly about delegates, and partly about generics.
Given the simplified code:
internal sealed class TypeDispatchProcessor
{
private
If you need to extend this to wrapping member invocations from classes without using Reflection.Emit you can do so by creating a series of compiler hints that can map a class and a function parameter list or return type.
Basically you need to create lambdas that take objects as parameters and return an object. Then use a generic function that the compiler sees AOT to create a cache of suitable methods to call the member and cast the parameters. The trick is to create open delegates and pass them through a second lamda to get to the underlying hint at runtime.
You do have to provide the hints for every class and signature (but not every method or property).
I've worked up a class here that does this, it's a bit too long to list out in this post.
In performance testing it's no where near as good as the example above, but it is generic which means it works in the circumstances I needed. Performance around 4.5x on reading a property compared to Invoke.