Esempio n. 1
0
        /// <summary>
        /// This performs a more diligent Import-like operation. The standard Import method can sometimes fail unpredictably when generics are involved.
        /// Note that it's possible yourMethodRef will be mutated, so don't use it.
        /// </summary>
        /// <param name="yourMethodRef">A reference to your method.</param>
        /// <returns></returns>
        private MethodReference ManualImportMethod(MethodReference yourMethodRef)
        {
            //the following is required due to a workaround.
            var newRef = yourMethodRef.IsGenericInstance ? yourMethodRef : yourMethodRef.CloneReference();

            foreach (var param in newRef.Parameters) {
                param.ParameterType = FixTypeReference(param.ParameterType);
            }
            if (!newRef.ReturnType.IsVarOrMVar()) {
                newRef.ReturnType = FixTypeReference(yourMethodRef.ReturnType);
            }

            return newRef;
        }