Hi,

I can't figure out why this keeps throwing an exception--am I missing
something here?

Here's the code:

public static void SetReturnType(this MethodDefinition method, Type
returnType)
        {
            var declaringType = method.DeclaringType;
            ModuleDefinition module = declaringType.Module;

            var returnTypeRef = module.Import(returnType);
            TypeReference actualReturnType = GetDeclaringType
(returnTypeRef);
            if (returnType.IsGenericParameter)
            {
                actualReturnType = method.AddGenericParameter
(actualReturnType.Name);
            }
            else
            {
                actualReturnType = module.Import(actualReturnType);
            }

            method.ReturnType.ReturnType = actualReturnType;
        }

...and if the return type is set to an open generic type of List<T>,
the Import() method throws an exception. Is there something I have to
do with Cecil and the returnType parameter before calling the import
method?
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to