Exemplo n.º 1
0
        static bool IsTypeForwarder(DmdType type)
        {
            var nonNested = DmdTypeUtilities.GetNonNestedType(type);

            if ((object)nonNested == null)
            {
                return(false);
            }
            return(nonNested.TypeScope.Kind == DmdTypeScopeKind.AssemblyRef);
        }
Exemplo n.º 2
0
        DmdType ReadType(bool readAssemblyReference)
        {
            IncrementRecursionCounter();
            DmdType?result;

            SkipWhite();
            if (PeekChar() == '!')
            {
                var currentSig = ReadGenericSig();
                var tspecs     = ReadTSpecs();
                ReadOptionalAssemblyRef();
                result = CreateTypeSig(tspecs, currentSig);
            }
            else
            {
                var typeNames = ReadTypeRefAndNestedNoAssembly('+');
                var tspecs    = ReadTSpecs();

                IDmdAssemblyName?asmRef;
                if (typeDefResolver is null)
                {
                    Debug.Assert(!(ownerModule is null));
                    var typeRef          = CreateTypeRef(typeNames);
                    var nonNestedTypeRef = (DmdParsedTypeRef)DmdTypeUtilities.GetNonNestedType(typeRef) !;
                    if (readAssemblyReference)
                    {
                        asmRef = ReadOptionalAssemblyRef() ?? FindAssemblyRef(nonNestedTypeRef);
                    }
                    else
                    {
                        asmRef = FindAssemblyRef(nonNestedTypeRef);
                    }
                    nonNestedTypeRef.SetTypeScope(new DmdTypeScope(asmRef ?? new DmdReadOnlyAssemblyName(string.Empty)));
                    result = Resolve(asmRef, typeRef) ?? typeRef;
                }
                else
                {
                    asmRef = readAssemblyReference ? ReadOptionalAssemblyRef() : null;
                    result = typeDefResolver.GetTypeDef(asmRef, typeNames);
                    if (result is null)
                    {
                        throw new TypeNameParserException("Couldn't find the type def");
                    }
                }

                if (tspecs.Count != 0)
                {
                    result = CreateTypeSig(tspecs, result);
                }
            }

            DecrementRecursionCounter();
            return(result);
        }