Ejemplo n.º 1
0
        public void TestShowCallStackOnCodeMap()
        {
            using (var app = new VisualStudioApp()) {
                var project = OpenDebuggerProjectAndBreak(app, "SteppingTest3.py", 2);

                app.Dte.ExecuteCommand("Debug.ShowCallStackonCodeMap");

                // Got the CodeMap Graph displaying.  Now we need to save, or at least make it have a version in temp.
                app.WaitForInputIdle();
                app.Dte.Documents.SaveAll();

                // VS is saving a temp version of the codemap in the Local AppData Temp directory. We will compare to that for verification.
                var tempFiles = Directory.GetFiles(Environment.ExpandEnvironmentVariables("%temp%"), "*.dgml", SearchOption.TopDirectoryOnly);
                var dgmlFile  = (from x in tempFiles orderby File.GetCreationTime(x) descending select x).First();

                // These are the lines of interest in the DGML File.  If these match, the correct content should be displayed in the code map.
                List <string> LinesToMatch = new List <string>()
                {
                    @"<Node Id=""\(Name=f @1 IsUnresolved=True\)"" Category=""CodeSchema_CallStackUnresolvedMethod"" Bounds=""[0-9,\.]+"" Label=""f"">",
                    @"<Node Id=""@2"" Category=""CodeSchema_CallStackUnresolvedMethod"" Bounds=""[0-9,\.]+"" Label=""SteppingTest3 module"">",
                    @"<Node Id=""ExternalCodeRootNode"" Category=""ExternalCallStackEntry"" Bounds=""[0-9,\.]+"" Label=""External Code"">",
                    @"<Link Source=""@2"" Target=""\(Name=f @1 IsUnresolved=True\)"" Category=""CallStackDirectCall"">",
                    @"<Alias n=""1"" Uri=""Assembly=SteppingTest3"" />",
                    @"<Alias n=""2"" Id=""\(Name=&quot;SteppingTest3 module&quot; @1 IsUnresolved=True\)"" />"
                };

                var fileText = File.ReadAllText(dgmlFile);

                foreach (var line in LinesToMatch)
                {
                    Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(fileText, line), "Expected:\r\n{0}\r\nsActual:\r\n{1}", line, fileText);
                }
            }
        }
Ejemplo n.º 2
0
        public void ShowCallStackOnCodeMap(VisualStudioApp app, DotNotWaitOnNormalExit optionSetter)
        {
            var project = OpenDebuggerProjectAndBreak(app, "SteppingTest3.py", 2);

            app.Dte.ExecuteCommand("Debug.ShowCallStackonCodeMap");

            // Got the CodeMap Graph displaying, but it may not have finished processing
            app.WaitForInputIdle();

            var dgmlKind = "{295A0962-5A59-4F4F-9E12-6BC670C15C3B}";

            Document dgmlDoc = null;

            for (int i = 1; i <= app.Dte.Documents.Count; i++)
            {
                var doc = app.Dte.Documents.Item(i);
                if (doc.Kind == dgmlKind)
                {
                    dgmlDoc = doc;
                    break;
                }
            }

            Assert.IsNotNull(dgmlDoc, "Could not find dgml document");

            var dgmlFile = Path.GetTempFileName();

            try {
                // Save to a temp file. If the code map is not ready, it
                // may have template xml but no data in it, so give it
                // some more time and try again.
                string fileText = string.Empty;
                for (int i = 0; i < 10; i++)
                {
                    dgmlDoc.Save(dgmlFile);

                    fileText = File.ReadAllText(dgmlFile);
                    if (fileText.Contains("SteppingTest3"))
                    {
                        break;
                    }

                    Thread.Sleep(250);
                }

                // These are the lines of interest in the DGML File.  If these match, the correct content should be displayed in the code map.
                List <string> LinesToMatch = new List <string>()
                {
                    @"<Node Id=""\(Name=f @1 IsUnresolved=True\)"" Category=""CodeSchema_CallStackUnresolvedMethod"" Label=""f"">",
                    @"<Node Id=""@2"" Category=""CodeSchema_CallStackUnresolvedMethod"" Label=""SteppingTest3 module"">",
                    @"<Node Id=""ExternalCodeRootNode"" Category=""ExternalCallStackEntry"" Label=""External Code"">",
                    @"<Link Source=""@2"" Target=""\(Name=f @1 IsUnresolved=True\)"" Category=""CallStackDirectCall"">",
                    @"<Alias n=""1"" Uri=""Assembly=SteppingTest3"" />",
                    @"<Alias n=""2"" Id=""\(Name=&quot;SteppingTest3 module&quot; @1 IsUnresolved=True\)"" />"
                };

                foreach (var line in LinesToMatch)
                {
                    Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(fileText, line), "Expected:\r\n{0}\r\nsActual:\r\n{1}", line, fileText);
                }
            } finally {
                File.Delete(dgmlFile);
            }
        }
Ejemplo n.º 3
0
        public void TestShowCallStackOnCodeMap() {
            using (var app = new VisualStudioApp()) {
                var project = OpenDebuggerProjectAndBreak(app, "SteppingTest3.py", 2);
 
                app.Dte.ExecuteCommand("Debug.ShowCallStackonCodeMap");

                // Got the CodeMap Graph displaying.  Now we need to save, or at least make it have a version in temp.
                app.WaitForInputIdle();
                app.Dte.Documents.SaveAll();

                // VS is saving a temp version of the codemap in the Local AppData Temp directory. We will compare to that for verification.
                var tempFiles = Directory.GetFiles(Environment.ExpandEnvironmentVariables("%temp%"), "*.dgml", SearchOption.TopDirectoryOnly);
                var dgmlFile = (from x in tempFiles orderby File.GetCreationTime(x) descending select x).First();

                // These are the lines of interest in the DGML File.  If these match, the correct content should be displayed in the code map.
                List<string> LinesToMatch = new List<string>() {
                    @"<Node Id=""\(Name=f @1 IsUnresolved=True\)"" Category=""CodeSchema_CallStackUnresolvedMethod"" Bounds=""[0-9,\.]+"" Label=""f"">",
                    @"<Node Id=""@2"" Category=""CodeSchema_CallStackUnresolvedMethod"" Bounds=""[0-9,\.]+"" Label=""SteppingTest3 module"">",
                    @"<Node Id=""ExternalCodeRootNode"" Category=""ExternalCallStackEntry"" Bounds=""[0-9,\.]+"" Label=""External Code"">",
                    @"<Link Source=""@2"" Target=""\(Name=f @1 IsUnresolved=True\)"" Category=""CallStackDirectCall"">",
                    @"<Alias n=""1"" Uri=""Assembly=SteppingTest3"" />",
                    @"<Alias n=""2"" Id=""\(Name=&quot;SteppingTest3 module&quot; @1 IsUnresolved=True\)"" />"
                };

                var fileText = File.ReadAllText(dgmlFile);

                foreach (var line in LinesToMatch) {
                    Assert.IsTrue(System.Text.RegularExpressions.Regex.IsMatch(fileText, line), "Expected:\r\n{0}\r\nsActual:\r\n{1}", line, fileText);
                }
            }
        }