Exemplo n.º 1
0
        private static MethodBase FindMethod(CSharpSyntaxNode node, Type type, ref MethodsOfType methods)
        {
            if (methods == null)
            {
                methods = new MethodsOfType(type);
            }

            // Here's a trick to keep the order of overloaded methods. The trick relies on an
            // implementation detail of Type.GetMembers() method, that it returns the methods
            // with the same order in declaration. So if we group by methods by their names,
            // and find them with the declaration order, we'll get the correct result without
            // comparing symbols to the methods.

            return(methods[GetMethodName(node)].Dequeue());
        }
Exemplo n.º 2
0
        private static TreeItem <MemberInfo> GetMemberItem(Type parentType, TreeItem <CSharpSyntaxNode> syntaxItem, ref MethodsOfType methods)
        {
            var syntax = syntaxItem.Value;

            var typeDecl = syntax as TypeDeclarationSyntax;

            if (typeDecl != null)
            {
                var type     = parentType.GetNestedType(GetTypeName(typeDecl), MemberBindingFlags);
                var children = CollectMembers(type, syntaxItem.Children);

                return(new TreeItem <MemberInfo>(type, children));
            }

            var method = FindMethod(syntax, parentType, ref methods);

            return(new TreeItem <MemberInfo>(method));
        }