Ejemplo n.º 1
0
        private void UpdateVisualization(AbstractAssemblyNode n)
        {
            if (n == null)
            {
                txtNewInfo.Clear();
            }
            else
            {
                if (n is ResourceNode)
                {
                    string resourceName  = ((ResourceNode)n).ResourceName;
                    byte[] resourceBytes = ((ResourceNode)n).GetStream().ReadToEnd();
                    resourcePane.SetResource(resourceName, resourceBytes);
                    resourcePane.Visible = true;
                    tabsCode.Visible     = false;

                    txtNewInfo.Clear();
                }
                else
                {
                    txtNewInfo.SetCodeBlocks(n.Visualization);

                    try
                    {
                        if (n is MethodNode)
                        {
                            diagram.LoadIL(((MethodNode)n).Method.GetILInstructions());
                        }
                        else if (n is ConstructorNode)
                        {
                            diagram.LoadIL(((ConstructorNode)n).Constructor.GetILInstructions());
                        }
                    }
                    catch (Exception)
                    {
                    }


                    tabsCode.Visible     = true;
                    resourcePane.Visible = false;
                }
                //UpdateILOffsets();
            }
        }
Ejemplo n.º 2
0
 void IAssemblyBrowser.OnNodeRightClicked(AbstractAssemblyNode n, Point pos, bool isFromBrowser)
 {
     if (n is MemberNode)
     {
         mnuMember.Show(Cursor.Position);
         mnuMember.Tag = ((MemberNode)n).Member;
     }
     else if (n is TypeNode)
     {
         mnuMember.Show(Cursor.Position);
         mnuMember.Tag = ((TypeNode)n).Type;
     }
     else if (n is BaseTypeNode)
     {
         mnuMember.Show(Cursor.Position);
         mnuMember.Tag = ((BaseTypeNode)n).Type;
     }
     mnuMember.UpdateAnalyzeTypeMenuEnabledStatus(isFromBrowser);
 }
Ejemplo n.º 3
0
        public void SelectType(Type t)
        {
            if (t == null)
            {
                return;
            }

            var assemblyNode = GetNodes().Where(n => n is AssemblyNode && ((AssemblyNode)n).Assembly == t.Assembly).FirstOrDefault();

            if (assemblyNode == null)
            {
                return;
            }

            assemblyNode.Populate(null);

            var namespaceNode = assemblyNode.GetNodes().Where(n => n is NamespaceNode && ((NamespaceNode)n).Namespace == t.Namespace).FirstOrDefault();

            if (namespaceNode == null)
            {
                return;
            }

            namespaceNode.Populate(null);


            AbstractAssemblyNode typeNode   = namespaceNode;
            List <Type>          pathToType = GetPathFromNonNestedTypeToType(t);

            foreach (var pathType in pathToType)
            {
                typeNode = typeNode.GetNodes().Where(n => n is TypeNode && ((TypeNode)n).Type.GUID == pathType.GUID).FirstOrDefault();

                if (typeNode == null)
                {
                    return;
                }
                typeNode.Populate(null);
            }

            typeNode.EnsureVisible();
            tvNodes.SelectedNode = typeNode;
        }
Ejemplo n.º 4
0
        public void SelectMember(MemberInfo member, int offset = -1)
        {
            Type t = member.DeclaringType;


            if (t == null)
            {
                System.Diagnostics.Debug.Assert(t != null, "Declaring type is null");
            }

            var assemblyNode = GetNodes().Where(n => n is AssemblyNode && ((AssemblyNode)n).Assembly == t.Assembly).FirstOrDefault();

            if (assemblyNode == null)
            {
                return;
            }

            assemblyNode.Populate(null);

            var namespaceNode = assemblyNode.GetNodes().Where(n => n is NamespaceNode && ((NamespaceNode)n).Namespace == t.Namespace).FirstOrDefault();

            if (namespaceNode == null)
            {
                return;
            }

            namespaceNode.Populate(null);

            AbstractAssemblyNode typeNode   = namespaceNode;
            List <Type>          pathToType = GetPathFromNonNestedTypeToType(t);

            foreach (var pathType in pathToType)
            {
                typeNode = typeNode.GetNodes().Where(n => n is TypeNode && ((TypeNode)n).Type.GUID == pathType.GUID).FirstOrDefault();

                if (typeNode == null)
                {
                    return;
                }
                typeNode.Populate(null);
            }


            var memberNode = typeNode.GetNodes().Where(n => n is MemberNode && ((MemberNode)n).Member.IsEqual(member))
                             .FirstOrDefault();

            if (memberNode == null)
            {
                var propNode = typeNode.GetNodes().Where(n =>
                {
                    if (n is PropertyNode)
                    {
                        var pNode     = ((PropertyNode)n);
                        var getMethod = pNode.Property.GetGetMethod(true);
                        if (getMethod != null && member.IsEqual(getMethod))
                        {
                            return(true);
                        }
                        var setMethod = pNode.Property.GetSetMethod(true);
                        if (setMethod != null && member.IsEqual(setMethod))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }).FirstOrDefault();

                if (propNode == null)
                {
                    return;
                }

                propNode.Populate(null);

                memberNode = propNode.GetNodes().Where(n => n is MemberNode && ((MemberNode)n).Member.IsEqual(member))
                             .FirstOrDefault();

                if (memberNode == null)
                {
                    return;
                }
            }

            memberNode.EnsureVisible();

            tvNodes.SelectedNode = memberNode;
            if (offset != -1)
            {
                codePane.ScrollToInstruction(offset);
            }
        }
Ejemplo n.º 5
0
        public static List <RunTimeDebuggers.Helpers.VisualizerHelper.CodeBlock> GetVisualisation(AbstractAssemblyNode node, MethodBase m)
        {
            var blocks = new List <VisualizerHelper.CodeBlock>();

            blocks.AddRange(VisualizerHelper.GetAttributesCodeBlocks(m.GetCustomAttributesDataInclSecurity()));
            blocks.Add(new VisualizerHelper.CodeBlock(Environment.NewLine));

            string il;

            try
            {
                Disassembler disAss = new Disassembler(m);
                disAss.BuildInstructions();
                //MethodBodyReader reader = new MethodBodyReader(m);
                il = disAss.ToRTFCode();
                blocks.AddRange(disAss.GetCodeBlocks());
            }
            catch (Exception ex)
            {
                il = "Error reading IL: " + ex.GetType().FullName + " - " + ex.Message;

                blocks.Add(new VisualizerHelper.CodeBlock("Error reading IL: " + ex.GetType().FullName + " - " + ex.Message + Environment.NewLine));
            }

            return(blocks);
            //return VisualizerHelper.RTFHeader.Replace("@BODY@", VisualizerHelper.GetAttributesRTF(CustomAttributeData.GetCustomAttributes(m)) + @"\line " + node.Text + @"\line " + il);
        }