I am currently trying to extent an existing application that uses reflection (ILGenerator) to create a dynamic method.
I currently have an object on the stack, this method needs to convert the object to the same type as 'parameterType'. I want to provide the same conversion functionality that we get when using Expression.Convert
public override void EmitParameterResolution(ILGenerator il, Type parameterType)
{
// il.Emit - Not sure what to do here...
// Expression.Convert(obj, parameterType)
}
You probably want Castclass:
You might also think about just Call, put parameterType on the stack after obj and then do something like this: