/// <summary> /// Adds a forwarding method to the proxy based on the passed <see cref="MethodInfo"/>, using the passed <see cref="MethodAttributes"/>. /// </summary> /// <remarks> /// Note that this works for interface methods only, if the <see cref="MethodInfo"/> comes from the interface, not the /// type implementing the interface. /// </remarks> public IMethodEmitter AddForwardingMethodFromClassOrInterfaceMethodInfoCopy(MethodInfo methodInfo, MethodAttributes methodAttributes) { ArgumentUtility.CheckNotNull("methodInfo", methodInfo); IMethodEmitter methodEmitter; if (methodInfo.DeclaringType.IsInterface) { methodEmitter = _classEmitter.CreateMethodOverrideOrInterfaceImplementation( methodInfo, true, methodAttributes & MethodAttributes.MemberAccessMask); } else { // Note: Masking the attributes with MethodAttributes.MemberAccessMask below, would remove // desired attributes such as Final, Virtual and HideBySig. methodEmitter = _classEmitter.CreateMethod(methodInfo.Name, methodAttributes, methodInfo); } ImplementForwardingMethod(methodInfo, methodEmitter); // TODO: Test return type return(methodEmitter); }