Esempio n. 1
0
            public override void VisitSimpleType(SimpleType simpleType)
            {
                TypeResolveResult rr;

                if ((rr = simpleType.Annotation <TypeResolveResult>()) == null)
                {
                    base.VisitSimpleType(simpleType);
                    return;
                }
                astBuilder.NameLookupMode = simpleType.GetNameLookupMode();
                if (astBuilder.NameLookupMode == NameLookupMode.Type)
                {
                    AstType outermostType = simpleType;
                    while (outermostType.Parent is AstType)
                    {
                        outermostType = (AstType)outermostType.Parent;
                    }
                    if (outermostType.Parent is TypeReferenceExpression)
                    {
                        // ILSpy uses TypeReferenceExpression in expression context even when the C# parser
                        // wouldn't know that it's a type reference.
                        // Fall back to expression-mode lookup in these cases:
                        astBuilder.NameLookupMode = NameLookupMode.Expression;
                    }
                }
                if (simpleType.Parent is Syntax.Attribute)
                {
                    simpleType.ReplaceWith(astBuilder.ConvertAttributeType(rr.Type));
                }
                else
                {
                    simpleType.ReplaceWith(astBuilder.ConvertType(rr.Type));
                }
            }