/// <summary>
/// Overrides the target <paramref name="method"/> with a method that throws a <see cref="NotImplementedException"/>.
/// </summary>
/// <param name="type">The target type.</param>
/// <param name="module">The host module.</param>
/// <param name="overrider">The <see cref="MethodOverrider"/> that will be used to override the target method.</param>
/// <param name="method">The target method.</param>
/// <returns>The stubbed method.</returns>
private static MethodDefinition CreateMethodStub(TypeDefinition type, ModuleDefinition module, MethodOverrider overrider, MethodInfo method)
{
// Import the NotImplementedException type
var notImplementedCtor = module.ImportConstructor<NotImplementedException>();
var currentMethod = overrider.AddOverrideFor(method, type);
// Create the method stub
var body = currentMethod.Body;
var il = body.GetILProcessor();
il.Emit(OpCodes.Newobj, notImplementedCtor);
il.Emit(OpCodes.Throw);
return currentMethod;
}