<?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>jaredpar's WebLog : Debugging</title><link>http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx</link><description>Tags: Debugging</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Why is LINQ absent from debugger windows?</title><link>http://blogs.msdn.com/jaredpar/archive/2009/08/26/why-no-linq-in-debugger-windows.aspx</link><pubDate>Wed, 26 Aug 2009 15:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9877055</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/9877055.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=9877055</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=9877055</wfw:comment><description>&lt;p&gt;As the owner of the VB.Net portion of the overall debugging experience, I frequently hear the request from customers to add LINQ support into the Watch / Immediate and Locals window.&amp;nbsp; Virtually every other type of expression is available in the debugger windows so why leave one of the most popular ones out? &lt;/p&gt;  &lt;p&gt;Quick Diversion: the specifics of this article are written from the point of view of the VB.Net expression evaluator.&amp;nbsp; However, the limitations blocking LINQ support (in both the architecture and overall design) are very similar between VB.Net and C#.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;As usual, the primary issue is cost and the cost for LINQ in the debugger windows is very high.&amp;nbsp; To understand why the cost is so high though, we must start by getting a better understanding how a language service interacts with the debugging services of Visual Studio and the general philosophy around compiler features in the debugger.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Languages in Visual Studio typically provide the following major components to support the debugging experience.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;p&gt;Expression Evaluator (EE): This is the language specific component which provides all of the data used in the watch, locals and immediate window, data tips, conditional breakpoints and several other components.&amp;nbsp; It’s primary input is an expression in string form which is converted to a value (typically an ICorDebugValue instance) and outputs a COM object capable of inspecting that value to the core debugger [1].&amp;nbsp;&amp;nbsp; Everything typed into the debugger windows goes through the EE.&lt;/p&gt;      &lt;p&gt;This component lives in the MTA of Visual Studio and has almost no interaction with the UI / STA thread. &lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;ENC Service: This is the component which is the work horse of ENC operations.&amp;nbsp; It provides rude edit detection, metadata differencing and metadata + IL generation&amp;nbsp;&amp;nbsp; .&lt;/p&gt;      &lt;p&gt;This component lives in the main STA of Visual Studio&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The important thing to understand about the expression evaluator is that it’s purpose is primarily to provide an expression evaluation and data inspection service.&amp;nbsp; How expression evaluation works is an article in itself but suffice it to say that it converts the string to a very low level AST then walks the nodes bottom up and evaluating the expressions using the ICorDebug APIs.&amp;nbsp; The EE component has no UI and is simply a data provider for the core debugger services.&amp;nbsp;&amp;nbsp; &lt;/p&gt;  &lt;p&gt;The design philosophy for Both VB.Net and C# is to have the highest level of fidelity between expressions evaluated in the EE and the actual running program.&amp;nbsp; To do otherwise would lead to extremely confusing results for users.&amp;nbsp; When spec’ing feature support in the VB.Net EE we start from the point of 100% fidelity, determine the problems with this design (if any) and then start the difficult process of making compromises.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;LINQ expressions are very different than any other expression previously allowed in the EE window because of the features interaction with metadata.&amp;nbsp; All LINQ expressions require the generation or manipulation of metadata to support the underlying lambda and/or closure.&amp;nbsp; Adding support for this is one of the biggest hurdles to getting LINQ (and other features) into the EE.&amp;nbsp;&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Evaluating a LINQ expression is actually much closer to an ENC operation than a traditional EE one.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Currently the EE’s have no capacity for generating metadata, only interpreting it.&amp;nbsp; Operations which mutate or generate metadata have traditionally only been allowed via the ENC service.&amp;nbsp; Getting LINQ to work in the EE with true fidelity would require at least a minimal amount of ENC feature work.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Without getting into too much detail, lets enumerate the&lt;b&gt; new&lt;/b&gt; major features necessary to evaluate a LINQ expression in the EE with true fidelity to the running program.&amp;nbsp; To simplify things, we’ll start by assuming there is no other LINQ expression used in the current method and the method is only being executed at most once at any given time in the process.&amp;nbsp;&amp;nbsp; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A metadata generation service to support the backing for closures and lambda expressions &lt;/li&gt;    &lt;li&gt;Convert expressions typed in the EE into IL [2] &lt;/li&gt;    &lt;li&gt;ENC support for metadata to push the new metadata for closures and lambdas into the currently executing assembly &lt;/li&gt;    &lt;li&gt;ENC support for method body IL to remove lifted variables from the current method and redirect the references inside the closure&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Issues #1 and #2 are for the most part internal architecture issues and can be solved via normal processes of code base refactoring and adding new features to an existing component.&amp;nbsp;&amp;nbsp; I don’t mean to imply these problems are cheap (in fact they are relatively expensive)&amp;nbsp; But fixing these is somewhat of an understood quantity.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Issues #3 and #4 are where the problems start.&amp;nbsp; As implemented EE’s do not have capability to create or modify metadata in the running process (that is the job of the ENC service).&amp;nbsp; EE’s do have access to the underlying CLR ENC APIs so it is possible to implement ENC operations in the EE.&amp;nbsp; It’s just simply not been done yet.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Wait!&amp;nbsp; Why not reuse our ENC implementation in the EE?&amp;nbsp; Unfortunately the ENC service is currently tied heavily to our in memory IDE compiler and many other IDE / STA features.&amp;nbsp; It in fact lives in a completely separate DLL, separate COM apartment and works on a different symbol table than the EE.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;More fundamental though is that it’s designed for a completely different purpose.&amp;nbsp; ENC is designed to track edits in live code, determining the differences and applying them to the running program.&amp;nbsp; The hypothetical EE feature would be tracking expressions that modify a running DLL for which code is not guaranteed (and not likely) to be available and applying the difference to the running program.&amp;nbsp; There are some similarities but the differences are significant enough to make code reuse have limited value.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Some people may wonder why it’s necessary to implement #4.&amp;nbsp; Couldn’t we just avoid removing the variable from the current method and make the feature cheaper?&amp;nbsp; This is possible but it would cause a significant fidelity difference in the feature.&amp;nbsp; Any mutations of the local variable within the LINQ expression would not be visible on the stack frame as it would if the LINQ expression was present in the original program.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;It’s easy to think of this ENC in the EE as just the same type of cost as #1 and #2 (in many ways it is).&amp;nbsp; However taking advantage of the CLR ENC APIs in the EE also means that we inherit it’s limitations as well.&amp;nbsp; ENC as as implemented in the CLR has many limitations which fly in the face of LINQ.&amp;nbsp; In particular the following ENC limitations present major problems (&lt;a mce_href="http://blogs.msdn.com/jmstall/archive/2005/02/19/376666.aspx" href="http://blogs.msdn.com/jmstall/archive/2005/02/19/376666.aspx"&gt;ENC limitations reference&lt;/a&gt;).&amp;nbsp; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Cannot add members to a value type.&amp;nbsp; This prevents evaluating LINQ when stopped in a value type method &lt;/li&gt;    &lt;li&gt;Cannot remove locals from a function.&amp;nbsp; This is an implementation of LINQ but we could work around this problem by changing the IL to simply no longer accessing the local variables. &lt;/li&gt;    &lt;li&gt;Cannot change anything in a generic type.&amp;nbsp; This prevents evaluating LINQ when stopped in a generic type.&amp;nbsp; &lt;/li&gt;    &lt;li&gt;Cannot specify an initial value for newly added fields. &lt;/li&gt;    &lt;li&gt;Allowable ENC operations differ between the top of the stack and operations elsewhere within the stack &lt;/li&gt;    &lt;li&gt;Modification of a non-top stack frame cannot significantly edit the current function call.&amp;nbsp; So if a LINQ expression captures a variable used in that call (think ref passing) it would likely be unable to be evaluated.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So even if we implemented everything possible on the language service side the resulting feature would be limited in several impactful ways.&amp;nbsp; Additionally these limitations are somewhat orthogonal to the current limitations EE’s face and would require a bit of user education.&amp;nbsp; And this is only for the most basic LINQ feature under unrealistic scenarios.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Lets now consider the problems of evaluating a LINQ expression when the current method already contains a LINQ expression that lifts at least 1 variable.&amp;nbsp; Evaluating a new expression at the same scope would require the modification of the current closure to maintain fidelity as opposed to generating a new one.&amp;nbsp; This brings along with it a couple more problems.&amp;nbsp; &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;p&gt;A lambda expression which uses 2 variables, 1 of which is captured in an existing lambda expression.&amp;nbsp; To maintain fidelity we would have to modify an existing closure signature to contain the new variable. &lt;/p&gt;      &lt;p&gt;&amp;nbsp;&lt;/p&gt;      &lt;p&gt;Often times generated closures are generic so we would run straight into ENC limitation #3. Additionally we would need the newly added field to have the same value as it has in the current method which runs us into ENC limitation #4. Now also consider that a closure instance can live much longer than the method in which it was created. For those closures no stack value is available so what value should we give fields in that instance?&amp;nbsp; Ideally it should have the value of the variable at the point the method exited but realistically that’s not possible.&amp;nbsp; &lt;/p&gt;      &lt;p&gt;&amp;nbsp;&lt;/p&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;p&gt;A lambda expression which uses 1 variable in a method where an existing lambda expression captures that same variable and another.&amp;nbsp; To maintain fidelity we would have to know about this and fake capture the second variable as well.&lt;/p&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Now consider all of the problems above and consider the scenario where there are multiple threads and multiple instances of the current method active in the program.&amp;nbsp; How to determine which closure instance belongs to which thread, and just as important which stack frame on which thread, with respect to initializing values?&lt;/p&gt;  &lt;p&gt;None of the issues are an unsolvable problem but they do represent a significant cost to the feature.&amp;nbsp; And once again even if we added all of these features to the EE, ENC limitations would significantly limit the usefulness of the resulting feature.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;Does this mean that LINQ, or any future metadata requiring expression, will never be added to the debugger window?&amp;nbsp; Absolutely not.&amp;nbsp; We’ve just hit the difficult stage of making compromises on the level of fidelity in the feature.&amp;nbsp; If you back off of true fidelity in a few small ways the resulting feature, while still very expensive, is significantly cheaper and removes many of the limitations imposed by ENC.&amp;nbsp;&amp;nbsp; This &lt;b&gt;hypothetical&lt;/b&gt; feature will be discussed in my next article.&amp;nbsp; &lt;/p&gt;  &lt;p&gt;[1] For those interested the returned interface is &lt;a mce_href="http://msdn.microsoft.com/en-us/library/bb161287(VS.80).aspx" href="http://msdn.microsoft.com/en-us/library/bb161287(VS.80).aspx"&gt;IDebugProperty2&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;[2] Right now expressions are converted to a tree form slightly above IL and they are interpreted using the ICorDebug APIs.&amp;nbsp; Converting all the way down to IL requires a lot more work&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9877055" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/VB/default.aspx">VB</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Closures/default.aspx">Closures</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Lambda/default.aspx">Lambda</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/LINQ/default.aspx">LINQ</category></item><item><title>Debugging F# list's</title><link>http://blogs.msdn.com/jaredpar/archive/2008/09/10/debugging-f-list-s.aspx</link><pubDate>Wed, 10 Sep 2008 15:00:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8938838</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/8938838.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=8938838</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=8938838</wfw:comment><description>&lt;p&gt;One of the lacking's of the latest F# CTP is debugger visualization support for the built-in list types.&amp;#160; Viewing a list in the debugger is decidedly tedious compared to the mscorlib collection classes.&amp;#160; Take the following quick code sample&lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;module &lt;/span&gt;Main =
    &lt;span style="color: blue"&gt;do
        let &lt;/span&gt;l1 = [0..4]
        &lt;span style="color: blue"&gt;let &lt;/span&gt;l2 = List.map (&lt;span style="color: blue"&gt;fun &lt;/span&gt;a &lt;span style="color: blue"&gt;-&amp;gt; &lt;/span&gt;a.ToString()) l1
        &lt;span style="color: blue"&gt;let &lt;/span&gt;l3 = &lt;span style="color: blue"&gt;new &lt;/span&gt;System.Collections.Generic.List&amp;lt;int&amp;gt;()
        List.iter (&lt;span style="color: blue"&gt;fun &lt;/span&gt;i &lt;span style="color: blue"&gt;-&amp;gt; &lt;/span&gt;l3.Add(i)) l1
        MainModuleTemp.Main()   &lt;span style="color: green"&gt;// Breakpoint here&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Hit F5 in a F# console application and you'll get the following display. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaredpar/WindowsLiveWriter/DebuggingFlists_129AA/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jaredpar/WindowsLiveWriter/DebuggingFlists_129AA/image_thumb.png" width="449" height="348" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Notice how the elements of the mscorlib List&amp;lt;&amp;gt; are immediately visible.&amp;#160; Getting to the data in a F# list is possible but it takes a lot more clicks than the mscorlib version.&amp;#160; This doesn't appear to be an oversight on the F# team either.&amp;#160; The expansion of mscorlib List&amp;lt;T&amp;gt; is controlled by the DebuggerTypeProxy attribute on the class definition.&amp;#160; If you fire up Reflector and dig into Fsharp.Core.dll and navigate to List&amp;lt;T&amp;gt; you'll notice it indeed has a DebuggerTypeProxy entry which is well formed and points to ListDebugView&amp;lt;T&amp;gt;.&amp;#160; &lt;/p&gt;

&lt;p&gt;ListDebugView&amp;lt;T&amp;gt; is essentially identical to the one for mscorlib List&amp;lt;T&amp;gt;.&amp;#160; So what gives?&amp;#160; The bug appears to be in the accessibility of the constructor.&amp;#160; Even though it's not explicit in the documentation of DebuggerTypeProxy, it appears that the target type must have a single argument constructor which is public.&amp;#160; The one for ListDebugView&amp;lt;T&amp;gt; is internal.&amp;#160; &lt;/p&gt;

&lt;p&gt;Normally this would be an easy enough problem to work around.&amp;#160; Add an assembly level attribute of type DebuggerTypeProxy pointing to List&amp;lt;T&amp;gt; and a modified version of ListDebugView.&amp;#160; Unfortunately that will not work in this case.&amp;#160; The debugger will prefer DebuggerTypeProxy instances added directly to a type over ones defined at an assembly level.&amp;#160; &lt;/p&gt;

&lt;p&gt;That is, except for two cases.&amp;#160; The debugger will give precedence to assembly level attributes which are defined in an assembly named autoexp.dll and placed in one of the following two locations&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Visualizers folder for the current user.&amp;#160; One my machine it is C:\Users\jaredp\Documents\Visual Studio 2008\Visualizers&lt;/li&gt;

  &lt;li&gt;Devenv global visualizer folder. C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers\Original&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you navigate to either of these directories you will find both the default autoexp.dll and the source code used to compile it.&amp;#160; It's got quite a few entries you may want to add in a modified version.&amp;#160; Adding a new ListDebugView&amp;lt;T&amp;gt; here is possible but lets do it in F# instead.&lt;/p&gt;

&lt;p&gt;Since autoexp.dll has predecence all we need to do is build a new version which has the appropriate debugger attributes for the F# collections.&amp;#160; Fire up a new class library project named autoexp and have it output to either of the directories listed above.&amp;#160; Below is a sample definition to get you started.&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;#light
open &lt;/span&gt;System.Diagnostics

&lt;span style="color: blue"&gt;module &lt;/span&gt;Main =
    &lt;span style="color: blue"&gt;type &lt;/span&gt;ListProxy&amp;lt;'a&amp;gt;(l:List&amp;lt;'a&amp;gt;) =
        [&amp;lt;DebuggerBrowsableAttribute(DebuggerBrowsableState.RootHidden)&amp;gt;]
        &lt;span style="color: blue"&gt;member &lt;/span&gt;this.Items = 
            Array.of_list l
            
    [&amp;lt;assembly: DebuggerDisplayAttribute(&lt;span style="color: maroon"&gt;&amp;quot;{Length}&amp;quot;&lt;/span&gt;, Target=typeof&amp;lt;List&amp;lt;int&amp;gt;&amp;gt;)&amp;gt;]
    [&amp;lt;assembly: DebuggerTypeProxyAttribute(typeof&amp;lt;ListProxy&amp;lt;int&amp;gt;&amp;gt;, Target=typeof&amp;lt;List&amp;lt;int&amp;gt;&amp;gt;)&amp;gt;]
    &lt;span style="color: blue"&gt;do 
        &lt;/span&gt;()
        &lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Don't be alarmed at the typeof&amp;lt;List&amp;lt;int&amp;gt;&amp;gt;.&amp;#160; The visualizer will work for any generic binding of List&amp;lt;T&amp;gt;.&amp;#160; In fact, reflector confirms that this attribute will be emitted with the type pointing at the unbound List&amp;lt;T&amp;gt; instead of List&amp;lt;int&amp;gt;. My lack of F# skills is failing me as to why.&amp;#160; I'd love to cry bug but I've found crying bug at a compiler is usually ... wrong.&amp;#160; &lt;/p&gt;

&lt;p&gt;In either case, once you build this and place in the appropriate folder, you should find the visualizations for List&amp;lt;&amp;gt; much more accessible.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaredpar/WindowsLiveWriter/DebuggingFlists_129AA/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/jaredpar/WindowsLiveWriter/DebuggingFlists_129AA/image_thumb_1.png" width="478" height="349" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8938838" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/F_2300_/default.aspx">F#</category></item><item><title>Disabling JIT optimizations while debugging</title><link>http://blogs.msdn.com/jaredpar/archive/2008/08/29/disabling-jit-optimizations-while-debugging.aspx</link><pubDate>Fri, 29 Aug 2008 15:00:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8896637</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/8896637.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=8896637</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=8896637</wfw:comment><description>&lt;p&gt;If you've ever been debugging a managed app, only to be unable to evaluate any of the locals or parameters because the code was &amp;quot;optimized&amp;quot;, check out the article below.&amp;#160; It shows a quick trick to disable optimizations by way of a .ini file.&amp;#160; This is great because it doesn't force you to recompile the application and takes only seconds to implement. &lt;/p&gt;  &lt;p&gt;The short version is create an .ini file (i.e. myapp.ini) with the following contents. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;pre&gt;[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0&lt;/pre&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;This has really saved me time debugging recently.&amp;#160; It's been blogged about by several others but given that I've had to search for this solution 3 times in as many weeks, I figured blogging about it would make it easier to find next time :)&lt;/p&gt;

&lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/library/9dd8z24x.aspx" href="http://msdn.microsoft.com/en-us/library/9dd8z24x.aspx"&gt;http://msdn.microsoft.com/en-us/library/9dd8z24x.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8896637" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/CLR/default.aspx">CLR</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Debugging PowerShell</title><link>http://blogs.msdn.com/jaredpar/archive/2007/10/15/debugging-powershell.aspx</link><pubDate>Mon, 15 Oct 2007 18:46:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5462416</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/5462416.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=5462416</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=5462416</wfw:comment><description>&lt;p&gt;Debugging PowerShell can be extremely frustrating because it often turns into a session of debugging your own thought process.&amp;nbsp; Often when I hit a PowerShell script issue I find myself feeling like everything is right and I'm just missing something basic.&amp;nbsp; IMHO, this is because I spend the majority of my day programming in compiled languages and don't completely come out of that box when I'm programming in PowerShell.&lt;/p&gt; &lt;p&gt;For instance the other day I added one of Lee Holme's scripts to my default profile.&amp;nbsp; The script is used to create a Generic object inside of PowerShell.&lt;/p&gt; &lt;p&gt;&lt;a title="http://www.leeholmes.com/blog/CreatingGenericTypesInPowerShell.aspx" href="http://www.leeholmes.com/blog/CreatingGenericTypesInPowerShell.aspx"&gt;http://www.leeholmes.com/blog/CreatingGenericTypesInPowerShell.aspx&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The syntax is very clean.&amp;nbsp; It is the same as new-object but requires the additional type parameters. &lt;/p&gt;&lt;pre&gt;$PS&amp;gt;new-genericobject Collections.Generic.List int
$PS&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The only problem was I couldn't get the script to return an object.&amp;nbsp; I tried a couple of operations like passing the output to get-member and seeing what exactly I was creating.&amp;nbsp; I kept getting errors like "No object has been specified ...".&amp;nbsp; My mind kept saying "It's there, it's non-null, why doesn't it have any members!!!".&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Frustrated I turned to some internal aliases and eventually Lee helped me out.&amp;nbsp; Nothing above is in error.&amp;nbsp; The problem is PowerShell will unroll collection classes.&amp;nbsp; In this case I've created an empty collection so there is nothing to output or pass to get-member.&amp;nbsp;&amp;nbsp; My issues is that I kept thinking it terms of compiled languages instead of PowerShell's collection unrolling semantics (which I will add, I quite like).&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Sadly any other object creating would have quickly lead me to this solution &lt;/p&gt;&lt;pre&gt;C:\Users\jaredpar\winconfig\PowerShell&amp;gt; new-genericobject collections.generic.Ke
yValuePair int,int

                                    Key                                   Value
                                    ---                                   -----
                                      0                                       0
&lt;/pre&gt;
&lt;p&gt;Another way to figure out this problem would be to bypass the collection unrolling in pipelines and directly specify the object to get-member.&lt;/p&gt;&lt;pre&gt;C:\Users\jaredpar\winconfig\PowerShell&amp;gt; gm -inputobject $col


   TypeName: System.Collections.Generic.List`1[[System.Int32, mscorlib, Version
=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
...
&lt;/pre&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5462416" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/PowerShell/default.aspx">PowerShell</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>.Net Framework Source Code</title><link>http://blogs.msdn.com/jaredpar/archive/2007/10/03/net-framework-source-code.aspx</link><pubDate>Wed, 03 Oct 2007 21:58:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5266568</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/5266568.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=5266568</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=5266568</wfw:comment><description>&lt;p&gt;If you haven't heard the news yet, you can read the full article on &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx"&gt;ScottGu's Blog&lt;/a&gt;.&amp;nbsp; &lt;/p&gt; &lt;p&gt;In summary Microsoft has released the source code for the .Net Framework in such a way that you can step into the Framework while debugging.&amp;nbsp; IMHO this is great for users because it allows us to get a lot of insight into parts of the API that are tricky or not well documented.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Take a look at his blog for the full details of hooking this up into the debugger.&amp;nbsp; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5266568" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/DotNet/default.aspx">DotNet</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Customizing Displays in the Debugger for System Types</title><link>http://blogs.msdn.com/jaredpar/archive/2007/09/28/customzing-displays-in-the-debugger-for-system-types.aspx</link><pubDate>Fri, 28 Sep 2007 23:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5192207</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/5192207.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=5192207</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=5192207</wfw:comment><description>&lt;P&gt;We've heard feedback from several customers regarding the way certain types are displayed in the Debugger.&amp;nbsp; Many of the displays exist to maintain the user experience between versions of Visual Studio.&amp;nbsp; We constantly evaluate if this is the correct choice for a given version of the product.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Starting with VS2008, you don't have to wait for us any longer.&amp;nbsp; In VS2008, VB added full support for many of the debugging features it lacked compared to C# in 2005.&amp;nbsp; In particular we've added full support for the &lt;A href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.aspx"&gt;DebuggerDisplayAttribute&lt;/A&gt;.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;By attributing a class or member with this attribute you can control how it is displayed in the debugger.&amp;nbsp; For each column (name, value and type) you can provide an alternate string or expression to display.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The best part about this attribute is you can target types that exist in different libraries.&amp;nbsp; You don't even need the source for them.&amp;nbsp; One of the members in the Type field which species the target type.&amp;nbsp; Customizing a type in a separate library requires slightly more work than customizing a type you have the source for.&amp;nbsp; For a source project you can just apply the attribute directly to the type or member and it will display.&amp;nbsp; For a type in another library you need to do the following.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Define a class library and include all of the &lt;A href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.aspx"&gt;DebuggerDisplayAttribute&lt;/A&gt; you want.&amp;nbsp; Make sure to apply the attributes to the assembly and specify the &lt;A href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.type.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggerdisplayattribute.type.aspx"&gt;Type&lt;/A&gt; member.&amp;nbsp; Ex.&lt;/LI&gt;&lt;/UL&gt;
&lt;BLOCKQUOTE&gt;&lt;PRE class=code&gt;&amp;lt;Assembly: DebuggerDisplay(&lt;SPAN style="COLOR: rgb(163,21,21)"&gt;"{ToString}"&lt;/SPAN&gt;, Target:=&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;GetType&lt;/SPAN&gt;(Guid))&amp;gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;
&lt;UL&gt;
&lt;LI&gt;Place the built library under the folder "Visual Studio 2008\Visualizers" which is under your my documents folder.&amp;nbsp; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;After doing this any Guid type will now show up as the actual Guid String ("10f3c4eb-7c0f-41b1-ae83-8838ff2f4f70") instead of {System.Guid} &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5192207" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/VB/default.aspx">VB</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>DebuggerNonUserCode and Properties</title><link>http://blogs.msdn.com/jaredpar/archive/2007/08/29/debuggernonusercode-and-properties.aspx</link><pubDate>Wed, 29 Aug 2007 19:45:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4631229</guid><dc:creator>Jared Parsons</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaredpar/comments/4631229.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaredpar/commentrss.aspx?PostID=4631229</wfw:commentRss><wfw:comment>http://blogs.msdn.com/jaredpar/rsscomments.aspx?PostID=4631229</wfw:comment><description>&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/system.diagnostics.debuggernonusercodeattribute.aspx"&gt;DebuggerNonUserCode&lt;/a&gt;&amp;nbsp;is an attribute that tells the debugger that&amp;nbsp;the target item is not code typed by the user.&amp;nbsp; It can be added to classes, structs, methods, constructors and properties.&amp;nbsp; &lt;/p&gt; &lt;p&gt;The benefits of this attribute is that it allows the compiler and designers to distinguish user code from generated code.&amp;nbsp; As such the debugging experience can be altered.&amp;nbsp; When this attribute is present and "Just My Code" (JMC) is on the debugger will not step into or break in these methods for normal cases.&amp;nbsp; Instead it will treat it is if it was a call to a framework assembly.&amp;nbsp; &lt;/p&gt; &lt;p&gt;However if you type code like the following you won't get the behavior you probably expect.&amp;nbsp; &lt;/p&gt;&lt;pre class="code"&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt; C1
        &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_f1 &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer

&lt;/span&gt;        &amp;lt;DebuggerNonUserCode()&amp;gt; _
        &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; P1() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;                &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_f1
            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &lt;span style="color: rgb(0,0,255)"&gt;Set&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; value)
                m_f1 = value
            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Set
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;While investigating a recent bug I found that I could step into the get/set method of properties annotated with DebuggerNonUserCode.&amp;nbsp; The reason why is a bit unexpected.&amp;nbsp; The attribute is applied to the property, not the get/set method.&amp;nbsp; The debugger will only check the actual methods involved.&amp;nbsp; It doesn't special case properties in any fashion.&amp;nbsp; If you want to get the expected behavior, you have to annotate the get/set method directly.&lt;/p&gt;&lt;pre class="code"&gt;    &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt; C1
        &lt;span style="color: rgb(0,0,255)"&gt;Private&lt;/span&gt; m_f1 &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer

&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;Property&lt;/span&gt; P1() &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer
&lt;/span&gt;            &amp;lt;DebuggerNonUserCode()&amp;gt; _
            &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;                &lt;span style="color: rgb(0,0,255)"&gt;Return&lt;/span&gt; m_f1
            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Get
&lt;/span&gt;            &amp;lt;DebuggerNonUserCode()&amp;gt; _
            &lt;span style="color: rgb(0,0,255)"&gt;Set&lt;/span&gt;(&lt;span style="color: rgb(0,0,255)"&gt;ByVal&lt;/span&gt; value &lt;span style="color: rgb(0,0,255)"&gt;As&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Integer&lt;/span&gt;)
                m_f1 = value
            &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Set
&lt;/span&gt;        &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Property
&lt;/span&gt;    &lt;span style="color: rgb(0,0,255)"&gt;End&lt;/span&gt; &lt;span style="color: rgb(0,0,255)"&gt;Class&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;I'm not saying this is the best solution but it will work for both VS 2005 and VS 2008.&amp;nbsp; IMHO ideally this attribute when applied to a property would affect both the get and set method.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4631229" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaredpar/archive/tags/VB/default.aspx">VB</category><category domain="http://blogs.msdn.com/jaredpar/archive/tags/Debugging/default.aspx">Debugging</category></item></channel></rss>