public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)
        {
            IReturnType type;

            if (string.IsNullOrEmpty(memberReferenceExpression.MemberName))
            {
                // NRefactory creates this "dummy" fieldReferenceExpression when it should
                // parse a primitive type name (int, short; Integer, Decimal)
                if (memberReferenceExpression.TargetObject is TypeReferenceExpression)
                {
                    type = TypeVisitor.CreateReturnType(((TypeReferenceExpression)memberReferenceExpression.TargetObject).TypeReference, resolver);
                    return(CreateTypeResolveResult(type));
                }
            }
            ResolveResult targetRR = Resolve(memberReferenceExpression.TargetObject);

            if (targetRR == null)
            {
                return(null);
            }
            type = targetRR.ResolvedType;
            if (targetRR is NamespaceResolveResult)
            {
                return(ResolveMemberInNamespace(((NamespaceResolveResult)targetRR).Name, memberReferenceExpression));
            }
            else if (type != null)
            {
                TypeResolveResult typeRR = targetRR as TypeResolveResult;
                if (typeRR != null && typeRR.ResolvedClass != null)
                {
                    foreach (IClass c1 in typeRR.ResolvedClass.ClassInheritanceTree)
                    {
                        foreach (IClass c in c1.InnerClasses)
                        {
                            if (resolver.IsSameName(memberReferenceExpression.MemberName, c.Name) &&
                                c.TypeParameters.Count == memberReferenceExpression.TypeArguments.Count)
                            {
                                return(CreateTypeResolveResult(resolver.ConstructType(c.DefaultReturnType, memberReferenceExpression.TypeArguments)));
                            }
                        }
                    }
                }
                return(resolver.ResolveMember(type, memberReferenceExpression.MemberName,
                                              memberReferenceExpression.TypeArguments,
                                              NRefactoryResolver.IsInvoked(memberReferenceExpression),
                                              typeRR == null,                                    // allow extension methods only for non-static method calls
                                              targetRR is BaseResolveResult ? (bool?)true : null // allow calling protected members using "base."
                                              ));
            }
            return(null);
        }
        bool ReplaceWithInvocation(Expression expression, ResolveResult rr)
        {
            // replace with invocation if rr is a method
            // and were not taking the address and it's not already being invoked
            MethodGroupResolveResult mgrr = rr as MethodGroupResolveResult;

            if (mgrr != null &&
                mgrr.Methods.Any(g => g.Count > 0) &&
                !(expression.Parent is AddressOfExpression) &&
                !(NRefactoryResolver.IsInvoked(expression)))
            {
                InvocationExpression ie = new InvocationExpression(expression);
                ReplaceCurrentNode(ie);
                return(true);
            }
            return(false);
        }
        public override object VisitPointerReferenceExpression(PointerReferenceExpression pointerReferenceExpression, object data)
        {
            ResolveResult targetRR = Resolve(pointerReferenceExpression.TargetObject);

            if (targetRR == null || targetRR.ResolvedType == null)
            {
                return(null);
            }
            PointerReturnType type = targetRR.ResolvedType.CastToDecoratingReturnType <PointerReturnType>();

            if (type != null)
            {
                return(resolver.ResolveMember(type.BaseType, pointerReferenceExpression.MemberName,
                                              pointerReferenceExpression.TypeArguments,
                                              NRefactoryResolver.IsInvoked(pointerReferenceExpression),
                                              true, null
                                              ));
            }
            return(null);
        }