Exemplo n.º 1
0
        DmdMethodDef GetResolvedMethod(bool throwOnError)
        {
            if ((object)__resolvedMethod_DONT_USE != null)
            {
                return(__resolvedMethod_DONT_USE);
            }

            DmdMethodDef newResolvedMethod = null;
            var          declType          = declaringTypeRef.Resolve(throwOnError);

            if ((object)declType != null)
            {
                var nonGenericInstDeclType       = declType.IsGenericType ? declType.GetGenericTypeDefinition() : declType;
                var nonGenericInstDeclTypeMethod = nonGenericInstDeclType?.GetMethod(Name, rawMethodSignature, throwOnError: false) as DmdMethodDef;
                if ((object)nonGenericInstDeclTypeMethod != null)
                {
                    newResolvedMethod = (object)nonGenericInstDeclTypeMethod.DeclaringType == declType ?
                                        nonGenericInstDeclTypeMethod :
                                        declType.GetMethod(nonGenericInstDeclTypeMethod.Module, nonGenericInstDeclTypeMethod.MetadataToken) as DmdMethodDef;
                    Debug.Assert((object)newResolvedMethod != null);
                }
            }
            if ((object)newResolvedMethod != null)
            {
                Interlocked.CompareExchange(ref __resolvedMethod_DONT_USE, newResolvedMethod, null);
                Debug.Assert(DmdMemberInfoEqualityComparer.DefaultMember.Equals(__resolvedMethod_DONT_USE.ReflectedType, declaringTypeRef));
                return(__resolvedMethod_DONT_USE);
            }
            if (throwOnError)
            {
                throw new MethodResolveException(this);
            }
            return(null);
        }
Exemplo n.º 2
0
 public DmdMethodSpec(DmdMethodDef genericMethodDefinition, IList <DmdType> genericArguments)
 {
     this.genericMethodDefinition = genericMethodDefinition ?? throw new ArgumentNullException(nameof(genericMethodDefinition));
     methodSignature       = genericMethodDefinition.GetMethodSignature(genericArguments);
     this.genericArguments = ReadOnlyCollectionHelpers.Create(genericArguments);
 }