MethodReference InflateMethod(TypeReference inflatedDeclaringType, MethodDefinition openMethod)
        {
            var git = inflatedDeclaringType as GenericInstanceType;

            if (git == null)
            {
                return(openMethod);
            }

            var inflatedReturnType = TypeReferenceExtensions.InflateGenericType(git, openMethod.ReturnType);
            var mr = new MethodReference(openMethod.Name, inflatedReturnType, git);

            if (openMethod.HasParameters)
            {
                for (int i = 0; i < openMethod.Parameters.Count; i++)
                {
                    var inflatedParameterType = TypeReferenceExtensions.InflateGenericType(git, openMethod.Parameters [i].ParameterType);
                    var p = new ParameterDefinition(openMethod.Parameters [i].Name, openMethod.Parameters [i].Attributes, inflatedParameterType);
                    mr.Parameters.Add(p);
                }
            }
            return(mr);
        }
Exemplo n.º 2
0
 public static bool IsValueType(this TypeReference typeReference) =>
 TypeReferenceExtensions.IsValueType(typeReference);
Exemplo n.º 3
0
 public static bool TypeImplements(this TypeReference typeReference, Type interfaceType) =>
 TypeReferenceExtensions.TypeImplements(typeReference, interfaceType);
Exemplo n.º 4
0
 public bool TestInheritsFromOrImplements(Type typeRef, Type baseClass)
 {
     return(TypeReferenceExtensions.InheritsFromOrImplements(module.ImportReference(typeRef), module.ImportReference(baseClass)));
 }