<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>AdamKrantz's WebLog</title><link>http://blogs.msdn.com/adamkrantz/default.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Macros for debugging</title><link>http://blogs.msdn.com/adamkrantz/archive/2004/06/29/168313.aspx</link><pubDate>Tue, 29 Jun 2004 07:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:168313</guid><dc:creator>AdamKrantz</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/adamkrantz/comments/168313.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adamkrantz/commentrss.aspx?PostID=168313</wfw:commentRss><description>&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;</description><category domain="http://blogs.msdn.com/adamkrantz/archive/tags/Debugger/default.aspx">Debugger</category></item><item><title>Let me introduce myself</title><link>http://blogs.msdn.com/adamkrantz/archive/2004/05/10/129404.aspx</link><pubDate>Tue, 11 May 2004 02:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:129404</guid><dc:creator>AdamKrantz</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/adamkrantz/comments/129404.aspx</comments><wfw:commentRss>http://blogs.msdn.com/adamkrantz/commentrss.aspx?PostID=129404</wfw:commentRss><description>&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;</description></item></channel></rss>