public override void VisitSimpleType(SimpleType simpleType) { TypeResolveResult rr; if ((rr = simpleType.Annotation <TypeResolveResult>()) == null) { base.VisitSimpleType(simpleType); return; } // HACK : ignore type names in attributes (TypeSystemAstBuilder doesn't handle them correctly) if (simpleType.Parent is Syntax.Attribute) { 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; } } simpleType.ReplaceWith(astBuilder.ConvertType(rr.Type)); }