public Signature(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
 {
     SignatureStruct signature = new SignatureStruct();
     GetSignature(ref signature, null, 0, fieldHandle.Value, null, declaringType);
     GC.KeepAlive(fieldHandle);
     this.m_signature = signature;
 }
Exemple #2
0
 [System.Security.SecurityCritical]  // auto-generated
 public Signature(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
 {
     GetSignature(null, 0, fieldHandle.Value, null, declaringType);
     GC.KeepAlive(fieldHandle);
 }
Exemple #3
0
        [System.Security.SecurityCritical]  // auto-generated
        private RuntimeFieldHandle(SerializationInfo info, StreamingContext context)
        {
            if(info==null)
                throw new ArgumentNullException("info");
            Contract.EndContractBlock();
            
            FieldInfo f =(RuntimeFieldInfo) info.GetValue("FieldObj", typeof(RuntimeFieldInfo));
            
            if( f == null)
                throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));

            m_ptr = f.FieldHandle.m_ptr;

            if (m_ptr == null)
                throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
        }
Exemple #4
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static RuntimeType GetApproxDeclaringType(IRuntimeFieldInfo field)
 {
     RuntimeType type = GetApproxDeclaringType(field.Value);
     GC.KeepAlive(field);
     return type;
 }
Exemple #5
0
 internal RuntimeFieldHandle(IRuntimeFieldInfo fieldInfo)
 {
     m_ptr = fieldInfo;
 }
Exemple #6
0
 private static extern IntPtr OffsetOfHelper(IRuntimeFieldInfo f);
Exemple #7
0
        public override FieldInfo?ResolveField(int metadataToken, Type[]?genericTypeArguments, Type[]?genericMethodArguments)
        {
            try
            {
                MetadataToken tk = new MetadataToken(metadataToken);

                if (!MetadataImport.IsValidToken(tk))
                {
                    throw new ArgumentOutOfRangeException(nameof(metadataToken),
                                                          SR.Format(SR.Argument_InvalidToken, tk, this));
                }

                RuntimeTypeHandle[]? typeArgs   = null;
                RuntimeTypeHandle[]? methodArgs = null;
                if (genericTypeArguments?.Length > 0)
                {
                    typeArgs = ConvertToTypeHandleArray(genericTypeArguments);
                }
                if (genericMethodArguments?.Length > 0)
                {
                    methodArgs = ConvertToTypeHandleArray(genericMethodArguments);
                }

                ModuleHandle moduleHandle = new ModuleHandle(this);
                if (!tk.IsFieldDef)
                {
                    if (!tk.IsMemberRef)
                    {
                        throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this),
                                                    nameof(metadataToken));
                    }

                    unsafe
                    {
                        ConstArray sig = MetadataImport.GetMemberRefProps(tk);

                        if (*(MdSigCallingConvention *)sig.Signature != MdSigCallingConvention.Field)
                        {
                            throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this),
                                                        nameof(metadataToken));
                        }
                    }
                }

                IRuntimeFieldInfo fieldHandle = moduleHandle.ResolveFieldHandle(metadataToken, typeArgs, methodArgs).GetRuntimeFieldInfo();

                RuntimeType declaringType = RuntimeFieldHandle.GetApproxDeclaringType(fieldHandle.Value);

                if (declaringType.IsGenericType || declaringType.IsArray)
                {
                    int tkDeclaringType = ModuleHandle.GetMetadataImport(this).GetParentToken(metadataToken);
                    declaringType = (RuntimeType)ResolveType(tkDeclaringType, genericTypeArguments, genericMethodArguments);
                }

                return(RuntimeType.GetFieldInfo(declaringType, fieldHandle));
            }
            catch (MissingFieldException)
            {
                return(ResolveLiteralField(metadataToken, genericTypeArguments, genericMethodArguments));
            }
            catch (BadImageFormatException e)
            {
                throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e);
            }
        }
Exemple #8
0
 internal RuntimeFieldHandle(IRuntimeFieldInfo fieldInfo)
 {
     this.m_ptr = fieldInfo;
 }
		private RuntimeFieldHandle(SerializationInfo info, StreamingContext context)
		{
			if (info == null)
			{
				throw new ArgumentNullException("info");
			}
			FieldInfo fieldInfo = (RuntimeFieldInfo)info.GetValue("FieldObj", typeof(RuntimeFieldInfo));
			if (fieldInfo == null)
			{
				throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
			}
			this.m_ptr = fieldInfo.FieldHandle.m_ptr;
			if (this.m_ptr == null)
			{
				throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState"));
			}
		}
Exemple #10
0
 public unsafe Signature(IRuntimeFieldInfo fieldHandle, RuntimeType declaringType)
 {
     this.GetSignature((void *)null, 0, fieldHandle.Value, (IRuntimeMethodInfo)null, declaringType);
     GC.KeepAlive((object)fieldHandle);
 }