Example #1
0
        internal static RuntimeMethodInfo AssignAssociates(int tkMethod, RuntimeTypeHandle declaredTypeHandle, RuntimeTypeHandle reflectedTypeHandle)
        {
            if (MetadataToken.IsNullToken(tkMethod))
            {
                return(null);
            }
            bool flag = !declaredTypeHandle.Equals(reflectedTypeHandle);
            RuntimeMethodHandle methodHandle = declaredTypeHandle.GetModuleHandle().ResolveMethodHandle(tkMethod, declaredTypeHandle.GetInstantiation(), new RuntimeTypeHandle[0]);
            MethodAttributes    attributes   = methodHandle.GetAttributes();
            bool flag2 = (attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private;
            bool flag3 = (attributes & MethodAttributes.Virtual) != MethodAttributes.PrivateScope;

            if (flag)
            {
                if (flag2)
                {
                    return(null);
                }
                if (flag3 && ((declaredTypeHandle.GetAttributes() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.AnsiClass))
                {
                    int slot = methodHandle.GetSlot();
                    methodHandle = reflectedTypeHandle.GetMethodAt(slot);
                }
            }
            MethodAttributes  attributes2 = attributes & MethodAttributes.MemberAccessMask;
            RuntimeMethodInfo methodBase  = RuntimeType.GetMethodBase(reflectedTypeHandle, methodHandle) as RuntimeMethodInfo;

            if (methodBase == null)
            {
                methodBase = reflectedTypeHandle.GetRuntimeType().Module.ResolveMethod(tkMethod, null, null) as RuntimeMethodInfo;
            }
            return(methodBase);
        }
Example #2
0
        internal override bool CacheEquals(object o)
        {
            MdFieldInfo mdFieldInfo = o as MdFieldInfo;

            if (mdFieldInfo == null || mdFieldInfo.m_tkField != this.m_tkField)
            {
                return(false);
            }
            RuntimeTypeHandle typeHandleInternal = this.m_declaringType.GetTypeHandleInternal();
            ModuleHandle      moduleHandle1      = typeHandleInternal.GetModuleHandle();
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            ModuleHandle& local = @moduleHandle1;

            typeHandleInternal = mdFieldInfo.m_declaringType.GetTypeHandleInternal();
            ModuleHandle moduleHandle2 = typeHandleInternal.GetModuleHandle();

            // ISSUE: explicit reference operation
            return((^ local).Equals(moduleHandle2));
        }
        private unsafe void PopulateEvents(RuntimeType.RuntimeTypeCache.Filter filter, RuntimeTypeHandle declaringTypeHandle, Hashtable csEventInfos, List <RuntimeEventInfo> list)
        {
            int token = declaringTypeHandle.GetToken();

            if (!MetadataToken.IsNullToken(token))
            {
                MetadataImport metadataImport = declaringTypeHandle.GetModuleHandle().GetMetadataImport();
                int            count          = metadataImport.EnumEventsCount(token);
                int *          result         = stackalloc int[count]; //result.AllocatedUntil = count
                metadataImport.EnumEvents(token, result, count);
                this.PopulateEvents(filter, declaringTypeHandle, metadataImport, result, count, csEventInfos, list);
                //Ensures that result.AllocatedUntil >= count!
            }
        }
Example #4
0
        public void GetArgIterator(object a, __arglist)
        {
            RuntimeArgumentHandle handle = __arglist;

            GetArgIterator(1, __arglist(handle));
            ArgIterator       args = new ArgIterator(handle);
            TypedReference    tr   = args.GetNextArg();
            RuntimeTypeHandle runtimeTypeHandle = TypedReference.TargetTypeToken(tr);
            ModuleHandle      mh    = runtimeTypeHandle.GetModuleHandle();
            IntPtr            mhPtr = runtimeTypeHandle.Value;

            var targetType  = TypedReference.GetTargetType(tr);
            var typedObject = TypedReference.ToObject(tr);



            args.End();
        }
        [Category("NotDotNet")]          // it crashes the runtime on MS.NET
        public void GetModuleHandle_Of_Empty_Handle()
        {
            RuntimeTypeHandle handle = new RuntimeTypeHandle();

            handle.GetModuleHandle();
        }