<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">AdamKrantz's WebLog</title><subtitle type="html" /><id>http://blogs.msdn.com/adamkrantz/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/adamkrantz/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/adamkrantz/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2004-05-10T19:24:00Z</updated><entry><title>Macros for debugging</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/adamkrantz/archive/2004/06/29/168313.aspx" /><id>http://blogs.msdn.com/adamkrantz/archive/2004/06/29/168313.aspx</id><published>2004-06-29T07:14:00Z</published><updated>2004-06-29T07:14:00Z</updated><content type="html">&lt;P&gt;I'm sitting here writing some macros to help test a new feature I've implemented in the debugger. Doing so is always an interesting experience. There is quite a lot of functionality available via automation, but it isn't always straightforward how to access it.&amp;nbsp;It makes&amp;nbsp;me wonder how many people use&amp;nbsp;macros and automation, especially with the debugger.&lt;/P&gt;
&lt;P&gt;Many things are very easy. To load the solution, I just call:&lt;/P&gt;
&lt;P&gt;DTE.Solution.Open(&amp;#8220;MyApp.sln&amp;#8221;)&lt;/P&gt;
&lt;P&gt;To start debugging, it just takes:&lt;/P&gt;
&lt;P&gt;DTE.Debugger.Go()&lt;/P&gt;
&lt;P&gt;But then to figure out how to set the caret in the document is not so intuitive. &lt;/P&gt;
&lt;P&gt;It's pretty easy to figure out that DTE.ActiveDocument.Selection gives the selection, but statement completion doesn't provide any methods or properties to set the selection. I finally figured out that you have to assign the selection to a TextSelection object. This has a MoveToPoint method, which takes a TextPoint. However, I can't just create a &amp;#8220;New TextPoint()&amp;#8221;. It took some more time to realize that you can't create these from scratch, but have to create them from an existing EditPoint. Here's my final solution:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;FONT size=2&gt; SetCaretPosition(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; Line &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;ByVal&lt;/FONT&gt;&lt;FONT size=2&gt; Column &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Integer&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Not&lt;/FONT&gt;&lt;FONT size=2&gt; DTE.ActiveDocument &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Is&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Nothing&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Then&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; selection &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; TextSelection = DTE.ActiveDocument.Selection&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; point &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; EnvDTE.EditPoint = selection.ActivePoint.CreateEditPoint()&lt;/P&gt;
&lt;P&gt;point.MoveToLineAndOffset(Line, Column)&lt;/P&gt;
&lt;P&gt;selection.MoveToPoint(point)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;If&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Catch&lt;/FONT&gt;&lt;FONT size=2&gt; ex &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; System.Exception&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;TestOutput("Unable to set caret position. " + ex.ToString)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Try&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Sub&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#000000&gt;&lt;FONT size=3&gt;Now after moving the caret, I can change the current statement by calling DTE.ExecuteStatement(&amp;#8220;Debug.SetNextStatement&amp;#8220;). &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;Mission accomplished.&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=168313" width="1" height="1"&gt;</content><author><name>AdamKrantz</name><uri>http://blogs.msdn.com/members/AdamKrantz.aspx</uri></author><category term="Debugger" scheme="http://blogs.msdn.com/adamkrantz/archive/tags/Debugger/default.aspx" /></entry><entry><title>Let me introduce myself</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/adamkrantz/archive/2004/05/10/129404.aspx" /><id>http://blogs.msdn.com/adamkrantz/archive/2004/05/10/129404.aspx</id><published>2004-05-11T02:24:00Z</published><updated>2004-05-11T02:24:00Z</updated><content type="html">&lt;P&gt;My name is Adam Krantz. I am a developer at Microsoft on the Visual Studio debugger team. My focus is on the user interface, and how to make the various debugger features work well for all the different languages, scenarios, and types of users. I'm looking forward to discussing these features, providing insights into how and why things work the way they do,&amp;nbsp;and&amp;nbsp;getting&amp;nbsp;feedback&amp;nbsp;from users about what they want from their debugger.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=129404" width="1" height="1"&gt;</content><author><name>AdamKrantz</name><uri>http://blogs.msdn.com/members/AdamKrantz.aspx</uri></author></entry></feed>