Exemple #1
0
        private string?ReadData()
        {
            if (!_helpers.ReadProperties(Parent, Token, out string?name, out _attributes, out SigParser sigParser))
            {
                return(null);
            }

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

            if (name != null)
            {
                if (options == StringCaching.Intern)
                {
                    _name = string.Intern(name);
                }
                else if (options == StringCaching.Cache)
                {
                    _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)
            {
                return(name);
            }

            _type = ClrmdField.GetTypeForFieldSig(_helpers.Factory, sigParser, Parent.Heap, Parent.Module);
            return(name);
        }
Exemple #2
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);
        }