Ejemplo n.º 1
0
        private string?ReadData()
        {
            if (!_helpers.ReadProperties(ContainingType, Token, out string?name, out _attributes, out SigParser sigParser))
            {
                return(null);
            }

            StringCaching options = ContainingType.Heap.Runtime.DataTarget?.CacheOptions.CacheFieldNames ?? StringCaching.Cache;

            if (name != null)
            {
                if (options == StringCaching.Intern)
                {
                    name = string.Intern(name);
                }

                if (options != StringCaching.None)
                {
                    _name = name;
                }
            }

            // We may have to try to construct a type from the sigParser if the method table was a bust in the constructor
            if (_type == null)
            {
                if (sigParser.GetCallingConvInfo(out int sigType) && sigType == SigParser.IMAGE_CEE_CS_CALLCONV_FIELD)
                {
                    sigParser.SkipCustomModifiers();
                    _type = _helpers.Factory.GetOrCreateTypeFromSignature(ContainingType.Module, sigParser, ContainingType.EnumerateGenericParameters(), Array.Empty <ClrGenericParameter>());
                }
            }

            return(name);
        }