<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Sree's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sreekarc/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sreekarc/feed.xml</link>
    <description>Blog about C# debugging and compiler features i helped implement</description>
    <lastBuildDate>Tue, 16 Apr 2019 05:29:59 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Joining Halo Team</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/joining-halo-team</link>
      <pubDate>Sat, 05 Sep 2009 17:05:09 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2009/09/05/joining-halo-team/</guid>
      <description><![CDATA[After spending 4 years in the C# compiler team, i have decided its time for me to try something new....]]></description>
      <content:encoded><![CDATA[<p>After spending 4 years in the C# compiler team, i have decided its time for me to try something new. A few weeks back i joined in the Halo team and have started my exciting journey there.</p>  <p>I won’t be posting anything new about C# in the near future and the don’t know what shareable halo info i will have. Thanks to all the people who read my blog and kept it entertaining, please feel free to ask me any questions. I will certainly try to answer ( or redirect to my ex-colleagues in C#).</p>  <p>Moving on to Halo, i hope you have seen this <a href="https://xbox360.ign.com/dor/objects/852871/bungie-project-2/videos/haloodst_liveaction_trl_090409.html">ODST trailer</a> if not check it out, ODST has a band of brothers kind of feel and connects at a visceral level.</p>]]></content:encoded>
    </item>
    <item>
      <title>Why Can’t Extension methods on Value Type be curried</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/why-cant-extension-methods-on-value-type-be-curried</link>
      <pubDate>Thu, 25 Jun 2009 13:02:01 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2009/06/25/why-cant-extension-methods-on-value-type-be-curried/</guid>
      <description><![CDATA[This is a followup to an post Extension Methods and Curried delegates. I have been recently asked if...]]></description>
      <content:encoded><![CDATA[<p>This is a followup to an post <a href="https://blogs.msdn.com/sreekarc/archive/2007/05/01/extension-methods-and-delegates.aspx">Extension Methods and Curried delegates</a>. I have been recently asked if why Error CS1113: “Extension methods '<em>Name</em>' defined on value type '<em>typename</em>' cannot be used to create delegates” was added and what does it mean ?</p>  <p>Here is the sort version of the story, basically the there is no direct translation to IL that would be correct for the operation( an extension method defined on a value type to be current as an instance method and assigned to a delegate).</p>  <p>To try this out one can generated IL like this</p>  <p>IL_0006: nop</p>  <p>IL_0007: ldc.i4.s 10</p>  <p>IL_0009: stloc.0</p>  <p>IL_000a: ldloc.0</p>  <p>IL_000b: box [mscorlib]System.Int32</p>  <p>IL_0010: ldftn int32 Test.Extension::func(int32)</p>  <p>IL_0016: newobj instance void Test.d1::.ctor(object,native int)</p>  <p>here the value of the int passed to the extension method is something like 205XXXXX</p>  <p>The problem is that value type methods (with the exception of the virtuals inherited from System.Object) are typically called with a reference to the value type, not a boxed version of the value type (this allows meaningful mutation of the value type for instance). (When a non-virtual method on a boxed value type is called directly the JIT and runtime actually conspire to route the call through a thunk called an “unboxing stub” which essentially adjusts the this pointer downwards to make it look like a value type reference so we can call the real value type method implementation).</p>  <p>Delegates essentially force you to box any bound parameter you supply (since the .ctor signature takes an Object and internally we store and report this value as an object reference). So straightaway you have a potential semantic problem: by forcing the value type reference into a box you lose any identity (i.e. if a mutating method is called on the boxed value it will mutate the boxed copy, not the original).</p>  <p>But then there’s an additional problem. On the invocation side there are three potential ways a boxed value type argument could be processed:</p>  <p>1. The boxed value is passed in directly. That’s what you want if it’s intended to be the first argument of a static method which is typed as Object or ValueType, or if you’re calling one of the System.Object virtuals on a value type. For instance “static void someType.foo(Object)” or “override String valueType.ToString()”.</p>  <p>2. The boxed value is unboxed and passed in. That’s what you want if calling a static method that with a first argument typed specifically as your value type. For instance “static void someType.foo(int32)”.</p>  <p>3. A reference to the value type stored inside the boxed value is passed in. This is what you want if you’re calling a non-virtual instance method on the value type. E.g. “instance void valueType.Foo()”.</p>  <p>I believe CLR handles cases 1 and 3, but not case 2 (which is the case above). There’s a technical problem with the implementation here, This has to do with the way CLR implements delegates to get the fastest invocation speed possible.</p>  <p><strong>One way I can think to overcome this problem is to create a stub our selfs</strong>. That is we could leverage the lambda implementation to create a lambda that calls the static method and then use the lambda as the delegate value. </p>  <p>For anyone Searching the web for this, Hope this helps :)</p>]]></content:encoded>
    </item>
    <item>
      <title>Debugging Dynamic objects in C# Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/debugging-dynamic-objects-in-c-part-1</link>
      <pubDate>Tue, 24 Feb 2009 16:01:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2009/02/24/debugging-dynamic-objects-in-c-part-1/</guid>
      <description><![CDATA[After a long time spent working on dev 10 features and fixing the may big and small things i have...]]></description>
      <content:encoded><![CDATA[<P>After a long time spent working on dev 10 features and fixing the may big and small things i have finally had the time to cobble togather&nbsp;a post.</P>
<H3><FONT color=#800000>What’s this post about ?</FONT></H3>
<P>To begin with i will be talking about debugging dynamic objects. </P>
<P>With C# 4.0 we can instantiate and perform operations on objects&nbsp; from dynamic languages like iron python, Iron ruby by using the dynamic keyword. In this post i will show you the tools added to&nbsp; inspection these objects and how one can reuse this for debugging COM objects. </P>
<H3><FONT color=#800000>Introduction to Dynamic</FONT></H3>
<P>Basically the dynamic keyword can be used to define the type of a local, field, return type or parameter. By doing so the user allows the compiler to defers the binding of calls and member accesses to run-time. In order to do this the compiler does some code generation that may or may be interesting to you ( i will briefly touch on this later), but what is sure to pop to ones mind is “ What’s this good for ? ”.</P>
<P>The primary use of this to bridge the gap between the .Net type system and its set of strongly typed languages and other alternate type systems that are in use by the developer to get his/her job one ( think COM, Scripting runtimes , DOM etc). The compiler does this by packaging all the information about the call in a payload and generates a call to the DLR&nbsp; (dynamic language runtime). This call is executed at runtime where the DLR takes charge of routing the call to the correct provider (IronPython, COM, IronRuby) of the object. This provider&nbsp; then tries to bind the call and execute it. </P>
<H3><FONT color=#800000>What’s the Problem with Debugging this ?</FONT></H3>
<P>Consider the following code</P><PRE class=csharpcode><SPAN class=kwrd>using</SPAN> System;
<SPAN class=kwrd>using</SPAN> Microsoft.Scripting;<SPAN style="BACKGROUND: white; COLOR: green">//requires reference to Microsoft.Scripting.dll and IronPython.dll</SPAN>
<SPAN class=kwrd>using</SPAN> IronPython.Compiler;
<SPAN class=kwrd>using</SPAN> IronPython.Hosting;

<SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> C
{
    <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>void</SPAN> Main(<SPAN class=kwrd>string</SPAN>[] args)
    {
        var sr = Python.CreateEngine();
        <SPAN class=rem>// similar overload exists for an file instead of a inline string</SPAN>
        var code = sr.CreateScriptSourceFromString(<SPAN class=str>@"   
class x(object):
 class_val = 5
 def some_method(self): pass
 def meth1(self, foo): 
   return foo
a = x()
a.val = 3
a.Name = 'Sree'"</SPAN>, SourceCodeKind.Statements);
        var scope = sr.CreateScope();
        code.Execute(scope);
        <SPAN class=kwrd>dynamic</SPAN> y = scope.GetVariable(<SPAN class=str>"a"</SPAN>);
        System.Diagnostics.Debugger.Break();

    }
}</PRE><PRE class=csharpcode>&nbsp;</PRE>
<P>Try inspecting y, </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_4.png"><IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=168 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_1.png" width=880 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_1.png"></A> </P>
<P>since we are talking about dynamic objects by nature they don’t have a strong type that representaion the structure of the object. In this case i am using Iron python, which happens to represent the members in a hash table.</P>
<P>In the case of COM the structure of the object is actually in an alternate type system. </P><PRE class=csharpcode><SPAN class=kwrd>dynamic</SPAN> XlApplication = <SPAN class=kwrd>new</SPAN> Microsoft.Office.Interop.Excel.Application();
<SPAN class=kwrd>dynamic</SPAN> thisWorkbook = XlApplication.Workbooks.Add();
<SPAN class=kwrd>dynamic</SPAN> xlSheet = thisWorkbook.Worksheets.Add(After: thisWorkbook.ActiveSheet);
System.Diagnostics.Debugger.Break();</PRE>
<STYLE type=text/css>


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</STYLE>

<P>Try inspecting xlSheet,</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_2.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_2.png"><IMG title=image style="BORDER-TOP-WIDTH: 0px; DISPLAY: inline; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=166 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb.png" width=860 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb.png"></A> </P>
<P>In either case the basic debugging tools in VS fail as they have no way of discovering this and only end showing the most basic information, which in almost every case is useless.</P>
<P>In Conclusion </P>
<OL>
<LI>Dynamic languages such as IronRuby or IronPython do not have strong types that represent the members they contain </LI>
<LI>COM support is limited to Interop assembly generated and quickly one can fall of the cliff with no type information. </LI>
<LI>The IntelliSense® tool does not show any of the dynamic members ( since it’s driven by the static type system). </LI></OL>
<P>debugging can be hampered by an inability to query the state of the object while stepping though code. </P><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"></A>
<H3><FONT color=#800000>So what does the solution look like ?</FONT></H3>
<H4>Dynamic View</H4>
<P>In addition to the static view, the C#&nbsp;expression evaluator will add a special node for&nbsp;</P>
<OL>
<LI>Objects implementing IDynamicObject</LI>
<LI>COM objects with out a PIA or strong type (Primary interop Assembly)</LI></OL>
<P>named “Dynamic View”. This is similar to the&nbsp;“Results View” node that was added for LINQ debugging, where the user could see the results of the lazy evaluated queries of linq.&nbsp;</P>
<P>The “Dynamic View” node has the following behavior. </P>
<OL>
<LI>Expanding the Dynamic View node will query the IDynamicObject object for the members available for display and get the value for each. </LI></OL>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_6.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_6.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_6.png"><IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=234 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_2.png" width=874 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_2.png"></A></P>
<OL>
<LI>The children of the Dynamic View are immutable.</LI>
<LI>Choosing “Add to Watch” for any child of the Dynamic View inserts a new watch that casts the object to dynamic (i.e. ((dynamic)y).Name).</LI>
<LI>The Dynamic View and its children are assumed to be side-effecting, and therefore stepping in the debugger will not automatically re-evaluate the Dynamic View or its children; they are made stale.</LI>
<LI>The Dynamic View and/or its children will need to be manually refreshed by the user.</LI></OL>
<P>A “dynamic” format specifier has been added to the expression evaluator. This allows the Dynamic View to be added to the watch by suffixing expressions with “, dynamic”</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_8.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_8.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_8.png"><IMG title=image style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; DISPLAY: inline; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=225 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_3.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_3.png" width=880 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingDynamicobjectsinCPart1_AD2B/image_thumb_3.png"></A> </P>
<H4>Pdb support</H4>
<P>In response to this implementation, a PDB payload has been added for local variables typed in some way as dynamic. This payload is necessary since there is no metadata corresponding to locals and since there no actual type called dynamic anywhere in the CLR. The compiler must find some way to decorate the locals to infer that its a dynamic local at runtime. The payload includes the name of the local, its slot ID and a boolean array (length&lt;=128) that represents a pre-order traversal of the type. For example, consider:</P>
<P>Dictionary&lt;int, dynamic&gt; dict = new Dictionary&lt;int, dynamic&gt;();</P>
<P>This code will produce a boolean array of false,false,true to indicate the portion of the type that is dynamic.</P>
<P><STRONG>So remember if you want to debug dynamic locals be sure you generate the debug information(pdb) and have it where you can access it</STRONG></P>
<P><STRONG></STRONG></P>
<P>With regard to declaration (as opposed to inspection), in some embodiments, declaration of dynamic variables within an Immediate window is supported, including complex generic types (e.g. Dictionary&lt;int, List&lt;dynamic&gt;&gt;). But more on this later …</P>
<P>More later … cheers</P><A href="https://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2009%2f02%2f24%2fdebugging-dynamic-objects-in-c-part-1.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2009%2f02%2f24%2fdebugging-dynamic-objects-in-c-part-1.aspx" border=0></A>]]></content:encoded>
    </item>
    <item>
      <title>C# Debugging Improvement for VS 2008 SP1- Part II</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/c-debugging-improvement-for-vs-2008-sp1-part-ii</link>
      <pubDate>Fri, 13 Jun 2008 17:10:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2008/06/13/c-debugging-improvement-for-vs-2008-sp1-part-ii/</guid>
      <description><![CDATA[Anonymous Types
On Further review there are a few problems with anonymous-types, they all boil down...]]></description>
      <content:encoded><![CDATA[<H2>Anonymous Types</H2>
<P>On Further review there are a few problems with anonymous-types, they all boil down to the fact the names given to these types are not valid C# type names ( so that users don't explicitly use them in code). But while debugging this is exactly the kind of thing that one wants to do, Consider the following cases</P>
<H3>Case1:</H3>
<P class=MsoNormal>The anonymous type appears in a cast, like when an anonymous type is returned from a function or when its cast from System.Object to the actual type.</P>
<P class=MsoNormal>var obj = Func(<SPAN style="COLOR: blue">new</SPAN>{ I = 10, J = <SPAN style="COLOR: #a31515">"Sree"</SPAN>}); <BR>System.Diagnostics.<SPAN style="COLOR: #2b91af">Debugger</SPAN>.Break();&nbsp; <BR><BR><SPAN style="COLOR: blue">private static object </SPAN>Func&lt;T&gt;(T obj) <BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">object </SPAN>o = obj; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.<SPAN style="COLOR: #2b91af">Debugger</SPAN>.Break(); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">return </SPAN>obj; <BR>}</P>
<P class=MsoNormal>At the first breakpoint add to watch any member on o results in<SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> </SPAN></P>
<P class=MsoNormal><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_2.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_2.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=94 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb.png" width=457 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb.png"></A></P>
<P class=MsoNormal>At the second break point adding to watch any member on obj results in </P>
<P class=MsoNormal><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_4.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=124 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_1.png" width=503 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_1.png"></A> </P>
<H3><SPAN style="mso-no-proof: yes">Case 2:</SPAN></H3>
<P><SPAN style="mso-no-proof: yes"></SPAN></P>
<P>The user wished to create a instance of the anonymous type during a debugging session or when the Anonymous Type is a type argument on a generic type and the user want to evaluate a static member, use it in a cast etc.&nbsp; </P>
<H3>SP1 Changes</H3>
<P>The anonymous type names are no longer invalid in the Expression evaluator. Therefor </P>
<OL>
<LI>C# Constructs involving Anonymous-types can actually be evaluated at runtime and </LI>
<LI>Instances of Anonymous-types can actually be created during a debugging session. </LI></OL>
<P>Which means using the same example as above and trying it with SP1 produces</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_10.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_10.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_10.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=308 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_4.png" width=518 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_4.png"></A> </P>
<P>See how the anonymous type name is no longer hidden and is used in the cast to bind to the members.</P>
<P>As an added bonus while debugging you can now create instances of anonymous types on the fly and use them. Assign them to objects and check for pathological conditions etc</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_14.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_14.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_14.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=206 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_6.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_6.png" width=737 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/CDebuggingImprovementforVS2008SP1PartII_AF04/image_thumb_6.png"></A> </P>
<P>Hope you enjoy discovering and debugging anonymous types now, that they are much more useful in the debugger. </P>
<P>As always do let me know if there are others things you would like to see me improve or implement.</P><A href="https://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2008%2f06%2f13%2fc-debugging-improvement-for-vs-2008-sp1-partii.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2008%2f06%2f13%2fc-debugging-improvement-for-vs-2008-sp1-partii.aspx" border=0></A> ]]></content:encoded>
    </item>
    <item>
      <title>C# Debugging Improvements for VS 2008 SP1- Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/c-debugging-improvements-for-vs-2008-sp1-part-1</link>
      <pubDate>Mon, 21 Jan 2008 15:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2008/01/21/c-debugging-improvements-for-vs-2008-sp1-part-1/</guid>
      <description><![CDATA[Overview
Over the past few months I have been busy closing VS 2008 and working on some fixes for...]]></description>
      <content:encoded><![CDATA[<H2>Overview</H2>
<P>Over the past few months I have been busy closing VS 2008 and working on some fixes for SP1. We have enabled some key debugging scenarios in C# in VS 2008 SP1, they include support for&nbsp; </P>
<OL>
<LI>Range Variables in Queries &amp; </LI>
<LI>Anonymous Types </LI>
<LI>Generic Type arguments </LI></OL>
<P>Covering all of them was making the post long so i am going to discuss Range variables this time and continue on with the other 2 in the next post.</P>
<H2>Range variables</H2>
<P>Range variables are the variables defined and used in a query. Currently they have a limitation in that they are not recognized as "true" local variables when stopped/stepping though a query. And since queries are one of the newest constructs in C#, are a prime candidate for SP1. </P>
<P>Range variables cannot currently be inspected in the watch window or in data tips(hover over them), quick watch and immediate. They can only be seen in the locals window,&nbsp; but the display shows the internal <A href="https://blogs.msdn.com/wesdyer/archive/2006/12/22/transparent-identifiers.aspx" mce_href="https://blogs.msdn.com/wesdyer/archive/2006/12/22/transparent-identifiers.aspx">transparent identifier</A> created for the query. This leaves the variable of interest to the user nested and difficult to understand and use.&nbsp; This happens as long as the user adds </P>
<P>1. A second from, </P>
<P class=MsoNormal style="MARGIN-BOTTOM: 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"><SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?">int</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: " courier="courier" new?;="new?;" mso-no-proof:="mso-no-proof:" yes?="yes?">[] ints = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: blue">int</SPAN>[] { 1, 2, 3, 45, 56 }; </SPAN></P>
<P mce_keep="true"><SPAN style="COLOR: blue; mso-no-proof: yes">var</SPAN><SPAN style="mso-no-proof: yes"> q = </SPAN><SPAN style="COLOR: blue">from </SPAN>i <SPAN style="COLOR: blue">in </SPAN>ints <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">from </SPAN>k <SPAN style="COLOR: blue">in </SPAN>ints <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">where </SPAN>i &gt; k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">//add BP here</SPAN> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: blue">select </SPAN>i + k;</P>
<P class=MsoNoSpacing><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_2.jpg" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_2.jpg" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_2.jpg"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=83 alt=clip_image002 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_thumb.jpg" width=628 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/clip_image002_thumb.jpg"></A></P>
<P>2. A join or </P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_4.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=235 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_1.png" width=554 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_1.png"></A> 
<P>3. A let clause to their query, </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_2.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_2.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=239 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb.png" width=554 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb.png"></A> </P>
<P>Seeing these simple examples it is not hard to imagine the debugging state when stopped in queries that use many of these in combination.</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_12.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_12.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_12.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=390 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_5.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_5.png" width=749 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_5.png"></A> </P><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"></A>
<P>Here "Hover over" does not work, can't add anything to watch, the transparent identifier gets larger and the lvl of nesting makes it very hard to find the range variables your looking for.</P>
<H3>SP1 Changes</H3>
<P>All of these issues are now fixed in SP1 and the user has the full set of debugging tools for him to help inspect and evaluate the current state when stopped at a break-point. using the same example </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_10.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_10.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_10.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=398 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_4.png" width=766 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingC3.0SP1changes_9D76/image_thumb_4.png"></A> </P>
<H2>Conclusion</H2>
<P>In concluding this article, As always I am very interested in </P>
<OL>
<LI>Any others pain points you have discovered while debugging or </LI>
<LI>Things are are hard to debug. </LI>
<LI>Things that would be nice to inspect etc. </LI></OL>
<P>Looking forward to your feedback. Cheers</P><A href="https://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2008%2f01%2f21%2fc-debugging-improvements-for-vs-2008-sp1.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2008%2f01%2f21%2fc-debugging-improvements-for-vs-2008-sp1.aspx" border=0></A> ]]></content:encoded>
    </item>
    <item>
      <title>Debugging C# 3.0 Part II</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/debugging-c-3-0-part-ii</link>
      <pubDate>Thu, 29 Nov 2007 17:01:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2007/11/29/debugging-c-3-0-part-ii/</guid>
      <description><![CDATA[Overview
In the last article I covered the "results view" for lazy evaluated collections like...]]></description>
      <content:encoded><![CDATA[<H3>Overview</H3>
<P>In the last article I covered the "results view" for lazy evaluated collections like Queries/Enumerable and the use of extension methods in the watch and immediate window. For completeness I will cover stepping, range variables, anonymous types and Xlinq support and this will lead us into the SP1 work for debugging.</P>
<H3>Stepping</H3>
<P>Stepping has been extended to support the query execution. That is, when the query is being executed one can step though the query created or add break points for the same. This allows the user to actually see the flow of the execution though a query and find out how a particular element was retrieved from the enumerable.</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_2.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_2.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=296 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb.png" width=643 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb.png"></A> </P>
<P>The results view is marked as having side effects ( just like a method call) and is disabled during a step. This mean we don't have unwanted side effects or seeing the contents of a enumerable</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_4.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_4.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=330 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_1.png" width=771 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_1.png"></A> </P>
<H3>Range Variables</H3>
<P>The variables that are declared and used in queries can also be inspected when stopped in a query execution ( as shown in stepping). Here the variables in question might be nested under an <A href="https://blogs.msdn.com/wesdyer/archive/2006/12/22/transparent-identifiers.aspx" mce_href="https://blogs.msdn.com/wesdyer/archive/2006/12/22/transparent-identifiers.aspx">transparent identifier</A> and if so the top level transparent identifier is show in the locals window and the user can dig in though this object to find the variable he is looking for. </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_6.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_6.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_6.png"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=426 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_2.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_2.png" width=883 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingforC3.0Part2_8827/image_thumb_2.png"></A> </P>
<H3>Anonymous Types</H3>
<P>Since anonymous type are identified by their structure all instances of anonymous-types give a brief description of their structure (first 5 elements) in the value column. The name of the type is hidden as its an unparseable name in C#. All elements of the anonymous type are un editable( after the <A href="https://blogs.msdn.com/sreekarc/archive/2007/04/03/immutable-the-new-anonymous-type.aspx" mce_href="https://blogs.msdn.com/sreekarc/archive/2007/04/03/immutable-the-new-anonymous-type.aspx">immutable dcr</A>)</P>
<H3>Xlinq Objects</H3>
<P>Objects of type System.Xml.Linq.XNode or any derived type get the built in visualizers ( text, XML and html) and user can see the Xml data, with a few clicks.</P>
<P>This pretty much covers the work done to support debugging in VS 9, however as I will describe soon this leaves a <STRONG>pretty big hole when debugging queries</STRONG> where the range variables are under an transparent identifiers ( e.g. Color, agg, y etc from range variable eg). Secondly since anonymous types are unparseable any construct that contains an anonymous type ( think type argument , casts , ctors) are broken. These are some of the issues i will cover in my next post of VS 9 SP1.</P><A href="https://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2007%2f11%2f29%2fdebugging-for-c-3-0-part-2.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fsreekarc%2farchive%2f2007%2f11%2f29%2fdebugging-for-c-3-0-part-2.aspx" border=0></A>]]></content:encoded>
    </item>
    <item>
      <title>Extension methods Interoperability between languages</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/extension-methods-interoperability-between-languages</link>
      <pubDate>Thu, 11 Oct 2007 13:58:39 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2007/10/11/extension-methods-interoperability-between-languages/</guid>
      <description><![CDATA[Extension methods written in C# can be imported and called with Extension method semantics in VB and...]]></description>
      <content:encoded><![CDATA[<p>Extension methods written in C# can be imported and called with Extension method semantics in VB and vice versa. This is possible since me decorate the assemblies , types and&nbsp;methods&nbsp;in the same manner. Using the Attribute</p> <p>[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)] <pre class="code"><span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">sealed</span> <span style="color: rgb(0,0,255)">class</span> ExtensionAttribute : Attribute { } </pre><a href="https://11011.net/software/vspaste"></a>
<p>This should be a special note to developers writing their own compilers or doing IL gen. This decoration allows the importer to precisely identify the classes to import when looking for extension methods.&nbsp;Allowing it&nbsp;to omit unnecessary types and their dependencies when looking for extension methods, which can quickly addup. 
<p>So if your doing anything custom be sure to inspect the IL to see if other languages can discover and call your extension methods seamlessly</p>]]></content:encoded>
    </item>
    <item>
      <title>Conversion rules for Instance parameters and their impact</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/conversion-rules-for-instance-parameters-and-their-impact</link>
      <pubDate>Thu, 11 Oct 2007 13:45:39 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2007/10/11/conversion-rules-for-instance-parameters-and-their-impact/</guid>
      <description><![CDATA[Overview: Instance parameter is the first parameter of an extension method and has the "this"...]]></description>
      <content:encoded><![CDATA[<p>Overview: Instance parameter is the first parameter of an extension method and has the "<span style="color: rgb(0,0,255)">this</span>" parameter modifier. I discuss special conversion rules for them and some of the things that users of extension methods might encounter.</p> <p>Consider the code bellow</p><span style="color: rgb(0,0,255)">using</span> System;<br><span style="color: rgb(0,0,255)">using</span> System.Linq;<br><br><span style="color: rgb(0,0,255)">namespace</span> TestExtensions<br>{<br>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">class</span> <span style="color: rgb(43,145,175)">Program<br></span>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Main()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.Foo();&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,128,0)">// 1<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0f.Foo();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0d.Foo();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A.Foo(0);&nbsp;&nbsp; <span style="color: rgb(0,128,0)">// 2<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A.Foo(0f);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A.Foo(0d);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">class</span> <span style="color: rgb(43,145,175)">A<br></span>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">long</span> x) { <span style="color: rgb(43,145,175)">Console</span>.WriteLine(<span style="color: rgb(163,21,21)">"Long"</span>); }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,128,0)">//public static void Foo(this int x) { Console.WriteLine("int"); }<br></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">object</span> x) { <span style="color: rgb(43,145,175)">Console</span>.WriteLine(<span style="color: rgb(163,21,21)">"Object"</span>); }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">double</span> x) { <span style="color: rgb(43,145,175)">Console</span>.WriteLine(<span style="color: rgb(163,21,21)">"decimal"</span>); }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">float</span> x) { <span style="color: rgb(43,145,175)">Console</span>.WriteLine(<span style="color: rgb(163,21,21)">"float"</span>); }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0,0,255)">public</span> <span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">void</span> Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">short</span> x) { <span style="color: rgb(43,145,175)">Console</span>.WriteLine(<span style="color: rgb(163,21,21)">"short"</span>); }<br>&nbsp;&nbsp;&nbsp; }<br>}<br> <p>1 binds to Foo(object) and 2 binds to Foo(short). This means that the same method when used as an extension method binds to a different overload than if used as an static method.</p> <p>That raise the question Why is that ?</p> <p>This is so because the&nbsp;conversions rules&nbsp;for instance parameter&nbsp;in an Extension methods&nbsp;are</p> <ol> <li>Identity conversions</li> <li>Implicit reference conversions</li> <li>Boxing conversions</li></ol> <p>So we are not considering numeric conversions and this can cause some confusion. 0 is of type <span style="color: rgb(0,0,255)">int</span> and will not be implicitly converted to <span style="color: rgb(0,0,255)">long</span> while binding the method as an Extension Method.</p> <p>Extension methods have different semantics than standard static methods, since they are called by the client as an instance method. So the conversion rules are modified so that they behave as such.</p> <p>Lets say we define an instance method on <span style="color: rgb(0,0,255)">int</span> does it mean I can call it on a object of type <span style="color: rgb(0,0,255)">long</span> ? It is this kind of enforcement that the conversion rules enforce.</p> <p>uncommenting the perfect match Foo(<span style="color: rgb(0,0,255)">this</span> <span style="color: rgb(0,0,255)">int</span> x) and they behave the same ...</p>]]></content:encoded>
    </item>
    <item>
      <title>Debugging and Delayed Execution in C# 3.0</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/debugging-and-delayed-execution-in-c-3-0</link>
      <pubDate>Thu, 12 Jul 2007 14:55:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2007/07/12/debugging-and-delayed-execution-in-c-3-0/</guid>
      <description><![CDATA[Overview:
C# 3.0 added a few constructs like queries which are delay executed. This means that they...]]></description>
      <content:encoded><![CDATA[<P mce_keep="true"><STRONG><FONT color=#800040>Overview:</FONT></STRONG></P>
<P>C# 3.0 added a few constructs like queries which are delay executed. This means that they are not actually executed until the results of the query are required. Debugging some of them can seem strange since one can't step in to the Query where its created but only where its enumerated, like in a foreach loop. In this article i will show some of the problems that the user can face based on the fact that the Query is delay executed and the debugger tries to be as non-intrusive as possible. 
<P>So what does it mean to step over the creation of the query, does it mean the statements that are part of the Query are executed... as you would have guessed No. At this point we have just created&nbsp;delegates that point to code in the Query(the body of the <SPAN style="COLOR: rgb(0,0,255)">select</SPAN>, <FONT color=#0000ff>where</FONT> etc), these delegate form the arguments to the extension methods (<SPAN style="COLOR: rgb(0,0,255)">select</SPAN> , <FONT color=#0000ff>where</FONT> etc )that form the query. 
<P><STRONG>Consider the following example:</STRONG> 
<P>Define a Class Library and add a single extension method to it 
<P><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System;<BR><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System.Linq;<BR><BR><SPAN style="COLOR: rgb(0,0,255)">public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">class</SPAN> <SPAN style="COLOR: rgb(43,145,175)">Extensions<BR></SPAN>{<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">string</SPAN> EM(<SPAN style="COLOR: rgb(0,0,255)">this</SPAN> <SPAN style="COLOR: rgb(43,145,175)">UInt32</SPAN> i)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">return</SPAN> <SPAN style="COLOR: rgb(163,21,21)">"hello"</SPAN>;<BR>&nbsp;&nbsp;&nbsp; }<BR>}<BR></P><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"></A>
<P>Now create a console application and add the class lib as a reference. In the console application&nbsp;add the following code ..</P>
<P><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System;<BR><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System.Linq;<BR><BR><SPAN style="COLOR: rgb(0,0,255)">namespace</SPAN> lateboundExtensionmethods<BR>{<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">class</SPAN> <SPAN style="COLOR: rgb(43,145,175)">Program<BR></SPAN>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">void</SPAN> Main(<SPAN style="COLOR: rgb(0,0,255)">string</SPAN>[] args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="COLOR: rgb(0,0,255)">var</SPAN> q = <SPAN style="COLOR: rgb(0,0,255)">from</SPAN> i <SPAN style="COLOR: rgb(0,0,255)">in</SPAN> <SPAN style="COLOR: rgb(0,0,255)">new</SPAN> <SPAN style="COLOR: rgb(0,0,255)">uint</SPAN>[] { 1 }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">select</SPAN> i.EM();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,128,0)">//module containing EM is not loaded<BR></SPAN><SPAN style="COLOR: rgb(0,128,0)"><BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.<SPAN style="COLOR: rgb(43,145,175)">Debugger</SPAN>.Break();&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">foreach</SPAN> (<SPAN style="COLOR: rgb(0,0,255)">var</SPAN> v <SPAN style="COLOR: rgb(0,0,255)">in</SPAN> q)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,128,0)">//module containing EM is loaded</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(43,145,175)">Console</SPAN>.WriteLine(v);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>}<BR></P>
<P>Now run to the breakpoint and try and evaluate&nbsp;i.EM() in the watch window.... we get an error like </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image02.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image02.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image02.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=58 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image0_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image0_thumb.png" width=899 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingandDelayedExecution_A52D/image0_thumb.png"></A> </P>
<P mce_keep="true">&nbsp;</P>
<P>What was all that about .... have i not just compiled and ran this code ... What's the debugger smoking ?</P>
<P><STRONG><FONT color=#800040>The Problem:</FONT></STRONG></P>
<P>Though the problem is not specific to Extension methods. The Query rewrite rules move code in the select, where etc in to a delegate and in order to do that a new static method is generated. Until this Method is Jitted the assemblies referenced in it are not loaded. Since the assembly is not yet loaded in the debugging session the Expression&nbsp;evaluator can't find the methods, if they are added to watch. This leave the user feeling like he has stepped over a code that can't be evaluated in the debugger. once we come to the foreach loop the code in the select is actually need to be stepped into and the Jitter jits this method, this results in all the assemblies referenced in to be loaded.</P>
<P>On the other hand trying something like this, and the extension method in watch will work.</P>
<P><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System;<BR><SPAN style="COLOR: rgb(0,0,255)">using</SPAN> System.Linq;<BR><BR><SPAN style="COLOR: rgb(0,0,255)">namespace</SPAN> lateboundExtensionmethods<BR>{<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">class</SPAN> <SPAN style="COLOR: rgb(43,145,175)">Program<BR></SPAN>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">void</SPAN> Main(<SPAN style="COLOR: rgb(0,0,255)">string</SPAN>[] args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">uint</SPAN> j = 10;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.<SPAN style="COLOR: rgb(43,145,175)">Debugger</SPAN>.Break(); <SPAN style="COLOR: rgb(0,128,0)">//module containing EM is loaded<BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; j.EM();</P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.<SPAN style="COLOR: rgb(43,145,175)">Debugger</SPAN>.Break(); 
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }<BR>}<BR></P>
<P><STRONG><FONT color=#800040>Workarounds:</FONT></STRONG></P>
<P>So while debugging you code if you are unable to execute an static or extension method defined in a satellite assembly check the modules window to see if the assembly is loaded, if not for the debugging session you might want to add something like typeof(className) to you'r code. Where className is the class defined in the satellite assembly.</P><A href="https://www.dotnetkicks.com/kick/?url=https://blogs.msdn.com/sreekarc/archive/2007/07/12/debugging-and-delayed-execution.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=https://blogs.msdn.com/sreekarc/archive/2007/07/12/debugging-and-delayed-execution.aspx" border=0></A>]]></content:encoded>
    </item>
    <item>
      <title>Debugging Features in C# 3.0 Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/sreekarc/debugging-features-in-c-3-0-part-1</link>
      <pubDate>Sun, 20 May 2007 00:52:00 GMT</pubDate>
      <dc:creator><![CDATA[Sree_C]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sreekarc/2007/05/20/debugging-features-in-c-3-0-part-1/</guid>
      <description><![CDATA[Overview
C# 3.0 introduces many new constructs and opens entirely new ways of thinking and...]]></description>
      <content:encoded><![CDATA[<P><STRONG><FONT color=#800040>Overview</FONT></STRONG></P>
<P>C# 3.0 introduces many new constructs and opens entirely new ways of thinking and developing&nbsp;code. In this article I will talk about the new debugging features that make it easy to&nbsp;see the running code and better understand it. In my experience one spends as much time writing the initial code as debugging it later. In fact stepping though the code&nbsp;and inspecting variables and expressions is one of the best ways to understand it. So its not just the original writer but many more who will eventually debug it. To this end there are many new things that you will notice when you start debugging in a C# 3.0 project, I will enumerate&nbsp;few of them in this part of the article. 
<P><STRONG><FONT color=#800040>Results View</FONT></STRONG> </P>
<P>The primary aim of the results view is to provide a array like view for Enumerable objects. This allows the user to see the items that are the results of the Query. The Query/Enumeration might be on a local collection(Linq/Xlinq/iterators) or from a remote store(Dlinq/customProviders). The&nbsp;idea here is not to&nbsp;change/hide the object's&nbsp;default&nbsp;structure while adding a simple way to inspect the result. This is quite different from debugger proxies which hide the actual view of the object under a "raw" node and show the users the custom view.&nbsp;The rational being that there are many useful properties/fields on the users query&nbsp;and we wanted to add&nbsp;this functionality without loosing all that&nbsp;information.&nbsp;This brings up 2 interesting questions. 
<P><B>1. When is this applied?</B></P>
<P>The&nbsp;Results&nbsp;View&nbsp;is&nbsp;applied&nbsp;to&nbsp;an&nbsp;object/struct&nbsp;if 
<OL>
<LI>It&nbsp;does&nbsp;not&nbsp;have&nbsp;a&nbsp;Debugger&nbsp;type&nbsp;proxy&nbsp; 
<LI>Does&nbsp;not&nbsp;implement&nbsp;IList&nbsp;or&nbsp;ICollection&nbsp;(they&nbsp;already&nbsp;have&nbsp;items&nbsp;view)&nbsp;&nbsp; 
<LI>It&nbsp;does&nbsp;implement&nbsp;IEnumerable&nbsp;or&nbsp;IEnumerable&lt;T&gt;. </LI></OL>
<P><B>2. What does the View look like? </B></P>
<OL>
<LI>For a&nbsp;object whose compile time type is an interface of type IEnumerable, IEnumerable&lt;T&gt;, IQueryable or IQueryable&lt;T&gt;,&nbsp;we&nbsp;hide&nbsp;the&nbsp;derived&nbsp;node&nbsp;and&nbsp;show&nbsp;the runtime type’s &nbsp;members&nbsp;directly&nbsp;under the&nbsp;object&nbsp;&nbsp;. 
<LI>A new node called “Results View” is added to the Expression which when expanded will enumerate the Enumerable.&nbsp;&nbsp;&nbsp;&nbsp; 
<LI>The Results View's value column warns the user that <FONT color=#ff8040>expanding will change the state of the object being inspected.</FONT> 
<LI>A new <A href="https://msdn2.microsoft.com/en-us/library/e514eeby(VS.80).aspx" mce_href="https://msdn2.microsoft.com/en-us/library/e514eeby(VS.80).aspx">format specifier</A> is added to represent the view and can be accessed by typing object/expression, results.</LI></OL>
<BLOCKQUOTE>
<P>E.g. for query like </P>
<P><SPAN style="COLOR: rgb(0,0,255)">int</SPAN>[] array&nbsp; = <SPAN style="COLOR: rgb(0,0,255)">new</SPAN> <SPAN style="COLOR: rgb(0,0,255)">int</SPAN>[]{ 23, 3,54, 8, 10, 39, 87, 3, 7};<BR><SPAN style="COLOR: rgb(0,0,255)">var</SPAN> q = <SPAN style="COLOR: rgb(0,0,255)">from</SPAN> i <SPAN style="COLOR: rgb(0,0,255)">in</SPAN> array.AsQueryable()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">let</SPAN> y = i * i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">let</SPAN> z = y * y<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">select</SPAN> <SPAN style="COLOR: rgb(0,0,255)">new</SPAN> { y, i, z };<BR><BR>System.Diagnostics.<SPAN style="COLOR: rgb(43,145,175)">Debugger</SPAN>.Break();</P></BLOCKQUOTE><PRE class=code><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B10%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B10%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B10%5D.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=111 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B4%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B4%5D.png" width=885 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B4%5D.png"></A> </PRE><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"></A>
<BLOCKQUOTE>
<P>here we can see the Results View Node is added as a child of the Query q. Though q has a static type of IQueryable&lt;SomeAnontype&gt;, we directly show the members of the actual runtime type. The value column has a important message for the user, stating that expanding this view will enumerate the object.If the base of the expression in watch is also an enumerable the results view is added to it. If a field/property which implements IEnumerable&nbsp;is hidden then the results view inherits the hidden property from its parent. 
<P>Finally we can also access&nbsp;the results view by using the results specifier “, results”. </P></BLOCKQUOTE>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B13%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B13%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D%5B13%5D.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=203 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B5%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B5%5D.png" width=731 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_1330A/image%7B0%7D_thumb%5B5%5D.png"></A> </P>
<BLOCKQUOTE>
<P>There are some exceptions to the rule, Sytem.String is&nbsp;excluded from having this view though it implements IEnumerable. </P></BLOCKQUOTE>
<P mce_keep="true"><STRONG><FONT color=#0000ff>Extension Methods</FONT></STRONG></P>
<P>Extension methods can now be used when calling an instance method in the watch and the immediate window. This is very useful if you want to&nbsp;&nbsp;see 
<OL>
<LI>Which extension method will get called if the statement was placed here in the code. 
<LI>The results of a Extension method not present in the code being executed. 
<LI>Limit the number of elements returned by a query, before expanding its results. 
<LI>Most importantly since Queries boil down to extension methods, we&nbsp;can <FONT color=#0000ff>use the watch/immediate like scratch pad to try out some Ad-hoc</FONT> Query like behavior.&nbsp;&nbsp; </LI></OL>
<P>Consider the following code</P>
<P><SPAN style="COLOR: rgb(0,0,255)">&nbsp;&nbsp;&nbsp;&nbsp;public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">class</SPAN> <SPAN style="COLOR: rgb(43,145,175)">Program<BR></SPAN>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">void</SPAN> Main(<SPAN style="COLOR: rgb(0,0,255)">string</SPAN>[] args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">int</SPAN>[] array = <SPAN style="COLOR: rgb(0,0,255)">new</SPAN> <SPAN style="COLOR: rgb(0,0,255)">int</SPAN>[] { 1, 23, 45, 67, 12 };&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,128,0)">// simple in memory array<BR><BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(43,145,175)">Func</SPAN>&lt;<SPAN style="COLOR: rgb(43,145,175)">Func</SPAN>&lt;<SPAN style="COLOR: rgb(0,0,255)">int</SPAN>, <SPAN style="COLOR: rgb(0,0,255)">bool</SPAN>&gt;, <SPAN style="COLOR: rgb(43,145,175)">IEnumerable</SPAN>&lt;<SPAN style="COLOR: rgb(0,0,255)">int</SPAN>&gt;&gt; where = array.Where&lt;<SPAN style="COLOR: rgb(0,0,255)">int</SPAN>&gt;;&nbsp; <SPAN style="COLOR: rgb(0,128,0)">//curry an Extension method<BR><BR></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.<SPAN style="COLOR: rgb(43,145,175)">Func</SPAN>&lt;<SPAN style="COLOR: rgb(0,0,255)">int</SPAN>, <SPAN style="COLOR: rgb(0,0,255)">int</SPAN>&gt; f = <SPAN style="COLOR: rgb(43,145,175)">Program</SPAN>.identity;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Diagnostics.<SPAN style="COLOR: rgb(43,145,175)">Debugger</SPAN>.Break();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">bool</SPAN> Eval(<SPAN style="COLOR: rgb(0,0,255)">int</SPAN> i){ <SPAN style="COLOR: rgb(0,0,255)">return</SPAN> i &gt; 5; }<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">bool</SPAN> Eval1(<SPAN style="COLOR: rgb(0,0,255)">int</SPAN> val) { <SPAN style="COLOR: rgb(0,0,255)">return</SPAN> val &lt; 50; }<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: rgb(0,0,255)">public</SPAN> <SPAN style="COLOR: rgb(0,0,255)">static</SPAN> <SPAN style="COLOR: rgb(0,0,255)">int</SPAN> identity(<SPAN style="COLOR: rgb(0,0,255)">int</SPAN> x) { <SPAN style="COLOR: rgb(0,0,255)">return</SPAN> x; }<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>Trim the Enumerable before inspecting it ( very useful if this call will be remoted to the provider of the extension method)</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B2%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B2%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B2%5D.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=160 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb.png" width=845 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb.png"></A></P>
<P>Calling an Extension methods with a method (predicate) as argument</P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B5%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B5%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B5%5D.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=188 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B1%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B1%5D.png" width=842 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B1%5D.png"></A> </P><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"><A href="https://11011.net/software/vspaste" mce_href="https://11011.net/software/vspaste"></A>
<P>Using <A href="https://blogs.msdn.com/sreekarc/archive/2007/05/01/extension-methods-and-delegates.aspx" mce_href="https://blogs.msdn.com/sreekarc/archive/2007/05/01/extension-methods-and-delegates.aspx">Curried delegate</A> from the code 
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B8%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B8%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B8%5D.png" atomicselection="true"><IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=226 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B2%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B2%5D.png" width=845 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B2%5D.png"></A> 
<P>Chaining extension methods to archive&nbsp;Ad-hoc query like execution 
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B11%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B11%5D.png" mce_href="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D%5B11%5D.png" atomicselection="true"><IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=220 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B3%5D.png" original-url="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B3%5D.png" width=851 border=0 mce_src="https://blogs.msdn.com/blogfiles/sreekarc/WindowsLiveWriter/DebuggingFeaturesinC3.0Part1_8AA6/image%7B0%7D_thumb%5B3%5D.png"></A> 
<P>This assumes that the assembly contain the extension method is already loaded by an earlier runtime call. 
<P>All in all using these 2 features&nbsp;in combination&nbsp;allows users to do some powerful analysis&nbsp;on a&nbsp; program while it executes. Though not as powerfully as a full fledged Query Analyzer with lambdas, it does allows the user to do&nbsp;very interesting stuff. I am interested in knowing potential pain points that you come across, things that are in your way when debugging etc. 
<P>In the coming article i will cover Stepping, Anonymous-types, Range-variables and Xlinq Support.</P><A href="https://www.dotnetkicks.com/kick/?url=https://blogs.msdn.com/sreekarc/archive/2007/05/19/debugging-features-in-c-3-0-part-1.aspx"><IMG alt="kick it on DotNetKicks.com" src="https://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=https://blogs.msdn.com/sreekarc/archive/2007/05/19/debugging-features-in-c-3-0-part-1.aspx" border=0></A>]]></content:encoded>
    </item>
  </channel>
</rss>