Esempio n. 1
0
        static CorFieldInfo ReadFieldInfo(IMetaDataImport mdi, uint token, CorType type)
        {
            if (mdi == null)
            {
                return(null);
            }
            var name = MDAPI.GetFieldName(mdi, token);

            if (name == null)
            {
                return(null);
            }
            var fieldType = GetFieldTypeSig(mdi, token);

            if (fieldType == null)
            {
                return(null);
            }
            var  attrs       = MDAPI.GetFieldAttributes(mdi, token);
            var  constant    = MDAPI.GetFieldConstant(mdi, token, out var constantType);
            var  browseState = GetDebuggerBrowsableState(mdi, token);
            bool compilerGeneratedAttribute = GetCompilerGeneratedAttribute(mdi, token);

            return(new CorFieldInfo(type, token, name, fieldType, attrs, constant, constantType, browseState, compilerGeneratedAttribute));
        }
Esempio n. 2
0
        /// <summary>
        /// Finds fields
        /// </summary>
        /// <param name="name">Field name</param>
        /// <returns></returns>
        public IEnumerable <CorField> FindFields(string name, bool checkBaseClasses = true)
        {
            var mdi = Module?.GetMetaDataInterface <IMetaDataImport>();

            foreach (var fdToken in MDAPI.GetFieldTokens(mdi, token))
            {
                if (MDAPI.GetFieldName(mdi, fdToken) == name)
                {
                    yield return(new CorField(this, fdToken));
                }
            }
            if (checkBaseClasses)
            {
                var type = GetParameterizedType(CorElementType.Class);
                if (type != null)
                {
                    type = type.Base;
                }
                if (type != null)
                {
                    foreach (var func in type.FindFields(name, checkBaseClasses))
                    {
                        yield return(func);
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Finds fields
        /// </summary>
        /// <param name="name">Field name</param>
        /// <returns></returns>
        public IEnumerable <CorField> FindFields(string name, bool checkBaseClasses = true)
        {
            for (var type = this; type != null; type = type.Base)
            {
                if (!checkBaseClasses && (object)this != (object)type)
                {
                    break;
                }
                if (!type.HasClass)
                {
                    continue;
                }
                var cls = type.Class;
                if (cls == null)
                {
                    continue;
                }

                var mod = cls.Module;
                var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();
                foreach (var fdToken in MDAPI.GetFieldTokens(mdi, cls.Token))
                {
                    if (MDAPI.GetFieldName(mdi, fdToken) == name)
                    {
                        yield return(new CorField(cls, fdToken));
                    }
                }
            }
        }
Esempio n. 4
0
        public string GetName()
        {
            var mod = Module;
            var mdi = mod == null ? null : mod.GetMetaDataInterface <IMetaDataImport>();

            return(MDAPI.GetFieldName(mdi, Token));
        }
Esempio n. 5
0
        public DmdFieldDefCOMD(DmdComMetadataReader reader, uint rid, DmdType declaringType, DmdType reflectedType) : base(rid, declaringType, reflectedType)
        {
            this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
            reader.Dispatcher.VerifyAccess();

            uint token = 0x04000000 + rid;

            Attributes = MDAPI.GetFieldAttributes(reader.MetaDataImport, token);
            Name       = MDAPI.GetFieldName(reader.MetaDataImport, token) ?? string.Empty;
            FieldType  = reader.ReadFieldType_COMThread(MDAPI.GetFieldSignatureBlob(reader.MetaDataImport, token), DeclaringType.GetGenericArguments());
        }
Esempio n. 6
0
        public static List <TokenAndName> GetFields(IMetaDataImport mdi, uint token)
        {
            var fdTokens = MDAPI.GetFieldTokens(mdi, token);
            var list     = new List <TokenAndName>(fdTokens.Length);

            foreach (var fdToken in fdTokens)
            {
                var name = MDAPI.GetFieldName(mdi, fdToken);
                if (name == null)
                {
                    continue;
                }
                list.Add(new TokenAndName(name, fdToken));
            }

            return(list);
        }
Esempio n. 7
0
        static CorFieldInfo ReadFieldInfo(IMetaDataImport mdi, uint token, CorType type)
        {
            if (mdi == null)
            {
                return(null);
            }
            var name = MDAPI.GetFieldName(mdi, token);

            if (name == null)
            {
                return(null);
            }
            var fieldType = GetFieldTypeSig(mdi, token);

            if (fieldType == null)
            {
                return(null);
            }
            var attrs    = MDAPI.GetFieldAttributes(mdi, token);
            var constant = MDAPI.GetFieldConstant(mdi, token, out var constantType);

            return(new CorFieldInfo(type, token, name, fieldType, attrs, constant));
        }
Esempio n. 8
0
        void InitNameAndAttrs_NoLock()
        {
            var  mdi   = readerModule.MetaDataImport;
            uint token = OriginalToken.Raw;

            Name            = Utils.GetUTF8String(MDAPI.GetUtf8Name(mdi, OriginalToken.Raw), MDAPI.GetFieldName(mdi, token) ?? string.Empty);
            this.Attributes = origAttrs = MDAPI.GetFieldAttributes(mdi, token);
        }
Esempio n. 9
0
 public string GetName() => MDAPI.GetFieldName(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);