<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>@ Head : VSM</title><link>http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx</link><description>Tags: VSM</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Saving and transferring customisations</title><link>http://msmvps.com/blogs/bill/archive/2009/11/25/saving-and-transferring-customisations.aspx</link><pubDate>Wed, 25 Nov 2009 03:54:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1742064</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1742064</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/11/25/saving-and-transferring-customisations.aspx#comments</comments><description>&lt;p&gt;I got an email from a reader last week asking about saving customisations in Visual Studio:&lt;/p&gt;  &lt;blockquote style="color:#7f7f7f;"&gt;   &lt;p&gt;Hi Bill&lt;/p&gt;    &lt;p&gt;I read an excellent article by you&lt;/p&gt;    &lt;p&gt;&lt;a href="http://visualstudiomagazine.com/Articles/2007/12/01/Customize-the-VB-IDE.aspx?Page=1"&gt;http://visualstudiomagazine.com/Articles/2007/12/01/Customize-the-VB-IDE.aspx?Page=1&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Just wondering if you know of a way to export those customisations so I can set up my computer at work restore after HDD fails and share my favorite settings with friends.&lt;/p&gt;    &lt;p&gt;Also would like to do same for my VBIDE customisations&lt;/p&gt;    &lt;p&gt;I have googled to no avail...... :-/ &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Well the good news is this is incredibly easy. On the Tools menu in Visual Studio you should see the “&lt;strong&gt;Import and Export Savings . . &lt;/strong&gt;.” command.&amp;#160; You can choose what groups of settings to import or export.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1742064" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Iterators in VB 10 ?</title><link>http://msmvps.com/blogs/bill/archive/2009/02/02/iterators-in-vb-10.aspx</link><pubDate>Mon, 02 Feb 2009 13:56:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1668151</guid><dc:creator>bill</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1668151</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2009/02/02/iterators-in-vb-10.aspx#comments</comments><description>&lt;p&gt;Although VB 10 won’t have a formal syntax for iterators, it will have all the necessary ingredients to easily write iterators. In VB10 you can use a generic template and multi line lambdas to create iterators. &lt;/p&gt;  &lt;p&gt;This iterator in C# :&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt; static public IEnumerable&amp;lt;String&amp;gt; Lines( this TextReader rdr)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; String line;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; while ((line = rdr.ReadLine()) != null)&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; yield return line;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Can be written as this in VB10:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre&gt;&lt;font face="Trebuchet MS"&gt;&amp;lt;Extension()&amp;gt; &lt;/font&gt;&lt;br /&gt;Public Function Lines(ByVal rdr as TextReader) As IEnumerable(Of String)&lt;/pre&gt;

  &lt;pre&gt;     Return New GenericIterator(Of String) 
          (&lt;strong&gt;Function(ByRef nextItem As String) As Boolean
              nextItem = rdr.ReadLine
              Return nextItem IsNot Nothing
           End Function)&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;End Function&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The above code uses a generic iterator class that accepts a lambda function. The lambda function sets the Current item of the iterator and returns True if MoveNext should be True. The above example is written as an extension method, but you can also use the inner part of the function inline.&lt;/p&gt;

&lt;p&gt;For more on using iterators in VB 9 today, as well as the generic class for the above example, see &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2972" target="_blank"&gt;my latest article in Visual Studio Magazine .&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1668151" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS+10/default.aspx">VS 10</category></item><item><title>Generic variance and List(Of T)</title><link>http://msmvps.com/blogs/bill/archive/2008/08/08/generic-variance-and-list-of-t.aspx</link><pubDate>Fri, 08 Aug 2008 04:55:36 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1643886</guid><dc:creator>bill</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1643886</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/08/08/generic-variance-and-list-of-t.aspx#comments</comments><description>&lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;This post has been sitting in my drafts for a while, so I thought I should post it, mainly because I want to talk about this and generic variance and arrays in more detail in the days ahead.&amp;#160; The reason this post was put on hiatus was I was waiting for &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2679" target="_blank"&gt;my article on arrays to appear in Visual Studio Magazine&lt;/a&gt;, as that deals with many of the details as to why this works ;) &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Have you ever wanted to cast a List(Of Customer) to a List(Of BusinessBase), where Customer Inherits BusinessBase, only to find that you can&amp;#39;t... well you can ;)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This extension will return an IList of BusinessBase for an input of a List(Of Customer).&amp;#160; Be aware it is the underlying array, so you will need to get the actual count from the original input.&lt;/p&gt;  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &amp;lt;Runtime.CompilerServices.Extension()&amp;gt; _&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; ToIList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T, TBase)(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; list &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)) &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; TBase)&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; fi = &lt;span style="color:#3092b1;"&gt;GetType&lt;/span&gt;(List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)).GetField(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;_items&amp;quot;&lt;/span&gt;, Reflection.BindingFlags.Instance &lt;span style="color:#3092b1;"&gt;Or&lt;/span&gt; _&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;                                                      Reflection.BindingFlags.GetField &lt;span style="color:#3092b1;"&gt;Or&lt;/span&gt; _&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;                                                      Reflection.BindingFlags.NonPublic)&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;CType&lt;/span&gt;(fi.GetValue(list), IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; TBase))&lt;/pre&gt;

&lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And a quick test:&lt;/p&gt;

&lt;div style="font-size:11pt;background:#eff0f1;color:black;font-family:consolas;"&gt;
  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Module&lt;/span&gt; Module1&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt; Main()&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; myApples &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Apple)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; myApples.Add(&lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; Apple &lt;span style="color:#3092b1;"&gt;With&lt;/span&gt; {.Name = &lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;Golden Delicious&amp;quot;&lt;/span&gt;})&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; myApples.Add(&lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; Apple &lt;span style="color:#3092b1;"&gt;With&lt;/span&gt; {.Name = &lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;Red Delicious&amp;quot;&lt;/span&gt;})&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; myApples.Add(&lt;span style="color:#3092b1;"&gt;New&lt;/span&gt; Apple &lt;span style="color:#3092b1;"&gt;With&lt;/span&gt; {.Name = &lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;Granny Smith&amp;quot;&lt;/span&gt;})&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; fruits &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Fruit) = myApples.ToIList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; Fruit)()&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color:#3092b1;"&gt;To&lt;/span&gt; myApples.Count - 1&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fruits(i).Name = &lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;Fruit : &amp;quot;&lt;/span&gt; &amp;amp; fruits(i).Name&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Next&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;For&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Each&lt;/span&gt; a &lt;span style="color:#3092b1;"&gt;In&lt;/span&gt; myApples&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(a.Name)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Next&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.WriteLine(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;finished&amp;quot;&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Console.ReadLine()&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &amp;lt;Runtime.CompilerServices.Extension()&amp;gt; _&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt; ToIList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T, TBase)(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; list &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)) &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; TBase)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Dim&lt;/span&gt; fi = &lt;span style="color:#3092b1;"&gt;GetType&lt;/span&gt;(List(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; T)).GetField(&lt;span style="background:#feffea;color:#a31515;"&gt;&amp;quot;_items&amp;quot;&lt;/span&gt;, _&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;                                         Reflection.BindingFlags.Instance &lt;span style="color:#3092b1;"&gt;Or&lt;/span&gt; _&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;                                         Reflection.BindingFlags.GetField &lt;span style="color:#3092b1;"&gt;Or&lt;/span&gt; _&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;                                         Reflection.BindingFlags.NonPublic)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;CType&lt;/span&gt;(fi.GetValue(list), IList(&lt;span style="color:#3092b1;"&gt;Of&lt;/span&gt; TBase))&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Function&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Module&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt; Fruit&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Private&lt;/span&gt; _Name &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;String&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Public&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Property&lt;/span&gt; Name() &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;String&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Return&lt;/span&gt; _Name&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;Set&lt;/span&gt;(&lt;span style="color:#3092b1;"&gt;ByVal&lt;/span&gt; value &lt;span style="color:#3092b1;"&gt;As&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;String&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _Name = value&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Set&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160; &lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Property&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt; Apple : &lt;span style="color:#3092b1;"&gt;Inherits&lt;/span&gt; Fruit&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre style="margin:0px;"&gt;&lt;span style="color:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="color:#3092b1;"&gt;Class&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1643886" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/.NET/default.aspx">.NET</category></item><item><title>Least among equals ?</title><link>http://msmvps.com/blogs/bill/archive/2008/03/25/least-among-equals.aspx</link><pubDate>Tue, 25 Mar 2008 11:10:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1552798</guid><dc:creator>bill</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1552798</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2008/03/25/least-among-equals.aspx#comments</comments><description>&lt;p&gt;Patrick Meader &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2540"&gt;writes on the divide between VB and C# inside Microsoft&lt;/a&gt;, and raises an interesting question.&lt;/p&gt;
&lt;p&gt;My response is probably going to be lengthy; more than I have time for&amp;nbsp;at present. In the meanwhile, what do you think of the issues raised in Pat&amp;#39;s editorial ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1552798" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Rant/default.aspx">Rant</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category><category domain="http://msmvps.com/blogs/bill/archive/tags/CSharp/default.aspx">CSharp</category></item><item><title>What's new in VB 2008</title><link>http://msmvps.com/blogs/bill/archive/2007/12/21/what-s-new-in-vb-2008.aspx</link><pubDate>Fri, 21 Dec 2007 03:23:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1408765</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1408765</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2007/12/21/what-s-new-in-vb-2008.aspx#comments</comments><description>&lt;p&gt;Visual Studio magazine&amp;#39;s January &lt;strong&gt;&lt;a href="http://visualstudiomagazine.com/columns/columnist.aspx?columnistsid=69" target="_blank"&gt;On VB&lt;/a&gt;&lt;/strong&gt; column, by your&amp;#39;s truly, has a &lt;a href="http://visualstudiomagazine.com/listings/list.aspx?id=252" target="_blank"&gt;quick reference guide to what&amp;#39;s new in VB 2008&lt;/a&gt;.&amp;nbsp; The &lt;a href="http://visualstudiomagazine.com/listings/list.aspx?id=252" target="_blank"&gt;guide&lt;/a&gt; includes links to earlier articles that provide more in depth information on specific features.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;hr /&gt;

&lt;p&gt;Errata for my &lt;a href="http://visualstudiomagazine.com/columns/article.aspx?editorialsid=2421" target="_blank"&gt;January column&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;The web site fails to display &lt;em&gt;&lt;strong&gt;&amp;amp;amp;&lt;/strong&gt;&lt;/em&gt; properly instead showing &lt;strong&gt;&amp;amp;&lt;/strong&gt;.&amp;nbsp; The relevant part of he article should read:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;XML literals are, as the name implies, the literal representation of the XML as it would appear in a file (or close to it). For example, if you wanted to name a book &amp;quot;War &amp;amp; Peace&amp;quot; instead of &amp;quot;War and Peace,&amp;quot; you&amp;#39;d need to encode the &amp;amp; to &amp;amp;amp; inside the XML literal: &lt;pre&gt;&amp;#39; won&amp;#39;t compile
Dim el = _
   &amp;lt;book&amp;gt;War &amp;amp; Peace&amp;lt;/book&amp;gt;

&amp;#39; will compile
Dim el = _
   &amp;lt;book&amp;gt;War &amp;amp;amp; Peace&amp;lt;/book&amp;gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1408765" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VS2008/default.aspx">VS2008</category></item><item><title>Cleaning up your XML literal namespaces</title><link>http://msmvps.com/blogs/bill/archive/2007/11/24/cleaning-up-your-xml-literal-namespaces.aspx</link><pubDate>Sat, 24 Nov 2007 05:16:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1351614</guid><dc:creator>bill</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1351614</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2007/11/24/cleaning-up-your-xml-literal-namespaces.aspx#comments</comments><description>&lt;p&gt;If you use XML literals in your code, adding one to another:&lt;/p&gt;
&lt;p&gt;Dim e1 = &amp;lt;a:books&amp;gt;&amp;lt;/a:books&amp;gt;&lt;br /&gt;dim e2 = &amp;lt;a:book&amp;gt;&amp;lt;/a:book&amp;gt;&lt;br /&gt;e1.Add(e2)&lt;br /&gt;&lt;br /&gt;You will have the xmlns declaration repeated in each of the elements, when really it is only needed once per the document or outer element. The problem is caused by VB adding a xmlns declaration as an attribute to the root element. It can get a bit more complex if you have duplicate namespace declarations with different prefixes.&amp;nbsp; So I decided to write a &lt;strong&gt;CleanUpNS&lt;/strong&gt; extension, that keeps the xml written clean by removing un-necessary namespace declarations. To use it, simply add a call to CleanUpNS to the end of your literals, e.g:&lt;br /&gt;&lt;/p&gt;Dim e1 = &amp;lt;a:books&amp;gt;&amp;lt;/a:books&amp;gt;.CleanUpNS&lt;br /&gt;dim e2 = &amp;lt;a:book&amp;gt;&amp;lt;/a:book&amp;gt;.CleanUpNS&lt;br /&gt;e1.Add(e2) 
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div style="FONT-SIZE:11pt;BACKGROUND:#f1f3f2;COLOR:black;FONT-FAMILY:consolas;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp; &amp;lt;Runtime.CompilerServices.Extension()&amp;gt; _&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;span style="COLOR:#3092b1;"&gt;Function&lt;/span&gt; CleanUpNS(&lt;span style="COLOR:#3092b1;"&gt;ByVal&lt;/span&gt; el &lt;span style="COLOR:#3092b1;"&gt;As&lt;/span&gt; XElement) &lt;span style="COLOR:#3092b1;"&gt;As&lt;/span&gt; XElement&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;Dim&lt;/span&gt; current = el.LastAttribute&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;Do&lt;/span&gt; &lt;span style="COLOR:#3092b1;"&gt;While&lt;/span&gt; current &lt;span style="COLOR:#3092b1;"&gt;IsNot&lt;/span&gt; &lt;span style="COLOR:#3092b1;"&gt;Nothing&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;Dim&lt;/span&gt; temp = current.PreviousAttribute&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;If&lt;/span&gt; current.IsNamespaceDeclaration &lt;span style="COLOR:#3092b1;"&gt;AndAlso&lt;/span&gt; el.Name.NamespaceName = current.Value &lt;span style="COLOR:#3092b1;"&gt;Then&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; current.Remove()&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="COLOR:#3092b1;"&gt;If&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; current = temp&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;Loop&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;Return&lt;/span&gt; el&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#3092b1;"&gt;End&lt;/span&gt; &lt;span style="COLOR:#3092b1;"&gt;Function&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I go into more details about how this works and how the XML is stored and emitted in my January On VB article in &lt;a href="http://visualstudiomagazine.com/" target="_blank"&gt;Visual Studio Magazine&lt;/a&gt;.&amp;nbsp; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1351614" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Bug/default.aspx">Bug</category></item><item><title>Snippet Editor 2008 release</title><link>http://msmvps.com/blogs/bill/archive/2007/11/06/snippet-editor-2008-release.aspx</link><pubDate>Tue, 06 Nov 2007 11:49:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1284756</guid><dc:creator>bill</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1284756</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2007/11/06/snippet-editor-2008-release.aspx#comments</comments><description>&lt;p&gt;I&amp;#39;ve updated the Snippet editor to work with Visual Studio 2008 and 2005 releases.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;strong&gt;Note this release requires .NET 3.5.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Changes/fixes:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Added 2008 product range to the list of products&lt;/li&gt;
&lt;li&gt;Fixed replacement of the install root variable for Visual Studio that was resulting in a double \ midway of file paths&lt;/li&gt;
&lt;li&gt;Removed VB&amp;#39;s single instancing and replaced it with named pipes messaging. This fixes various issues to do with firewalls, and the remoting VB tries to do. See Visual Studio Magazine November for details on the NamedPipes usage.&lt;/li&gt;
&lt;li&gt;Set the required permissions to run the application as Administrator for Vista.&amp;nbsp; Without this, the app would run, but snippets would be saved in the VirtualStore where Visual Studio wouldn&amp;#39;t see them properly.&amp;nbsp; The problem revolves around Visual Studio having the snippet stores in the Program Files tree.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strike&gt;The download includes the source and the release build. (in the bin\release path)&lt;/strike&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;UPDATE: The files are now available from &lt;/strong&gt;&lt;a class="" href="http://billmccarthy.com/Projects/Snippet_Editor"&gt;&lt;strong&gt;my web site&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; (&lt;/strong&gt;&lt;a href="http://billmccarthy.com/Projects/Snippet_Editor"&gt;&lt;strong&gt;http://billmccarthy.com/Projects/Snippet_Editor&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Enjoy :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1284756" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Vista/default.aspx">Vista</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VB10/default.aspx">VB10</category></item><item><title>Thoughts on Expression Trees</title><link>http://msmvps.com/blogs/bill/archive/2007/08/15/thoughts-on-expression-trees.aspx</link><pubDate>Wed, 15 Aug 2007 09:04:01 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1112596</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=1112596</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2007/08/15/thoughts-on-expression-trees.aspx#comments</comments><description>&lt;p&gt;I just finished writing an article about Expression Trees for &lt;a href="http://www.ftponline.com/vsm/" target="_blank"&gt;Visual Studio Magazine (aka VBPJ&lt;/a&gt;) and there seemed to be some &amp;quot;holes&amp;quot; that I think should be plugged.&amp;nbsp; An expression tree is basically a descriptive way of representing a lambda function. The standard LINQ query operators (e.g Where Group, Join et al)&amp;nbsp; on an IQueryable will cause the language compilers to compile the lambda function as an expression tree.&amp;nbsp; From there the expression basically allows for translation between, such as VB or C#&amp;nbsp;to TSQL.&lt;/p&gt; &lt;p&gt;A problem with this &amp;quot;translation&amp;quot; is that it is not 100%... that is, not all things you write in a lambda can be translated.&amp;nbsp; If you think about TSQL for example you can see there is a very finite limit of what can and what can&amp;#39;t be translated. Unfortunately the way things are you don&amp;#39;t and can&amp;#39;t really get any design time feedback on this.&amp;nbsp; For example, the extension methods in Queryable work for any IQueryable, so without a runtime analysis of the IQueryable.Provider you can&amp;#39;t really ask for what language features it supports.&lt;/p&gt; &lt;p&gt;So.... this got me thinking...&amp;nbsp; What about a couple&amp;nbsp;of design time attributes ?&amp;nbsp; The first would be on your collection/IEnumerable /data source and would specify the provider from which to&amp;nbsp;query the supported features.&amp;nbsp; This might take the form of &amp;lt;QueryProvider(&amp;quot;MyEntityFramework&amp;quot;)&amp;gt; . The &amp;quot;MyEntityFramework&amp;quot; should be the qualified named for the actual IQueryable.Provider .&lt;/p&gt; &lt;p&gt;The next problem is an extension method doesn&amp;#39;t tell us if it is going to use the provider or return the same provider, so we need an attribute on them to do so. e.g &amp;lt;QueryProvider(UsesProvider:= True, ReturnsSameProvider:= True)&amp;gt; .&amp;nbsp; We probably need a third property for this attribute that specifies the Provider it returns if ReturnsSameProvider is false.&lt;/p&gt; &lt;p&gt;Finally, a third attribute for the provider itself to indicate whether it is the design time service provider as well or the fully qualified class name for the design time service provider.&lt;/p&gt; &lt;p&gt;Then, it should be possible to provide a great design time experience for any query provider.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;$0.02&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1112596" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category><category domain="http://msmvps.com/blogs/bill/archive/tags/DevCenter/default.aspx">DevCenter</category></item><item><title>Extension methods on VSM</title><link>http://msmvps.com/blogs/bill/archive/2007/05/31/extension-methods-on-vsm.aspx</link><pubDate>Wed, 30 May 2007 14:34:17 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:934030</guid><dc:creator>bill</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/bill/rsscomments.aspx?PostID=934030</wfw:commentRss><comments>http://msmvps.com/blogs/bill/archive/2007/05/31/extension-methods-on-vsm.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.ftponline.com/vsm/2007_05/magazine/columns/programmingtechniques/default.aspx"&gt;My article about Extension methods is now on the web&lt;/a&gt;.  Unfortunately an edit I made didn&amp;#39;t make it into the print version (and the web version is the same as the print). The problem was as I looked at the way extension methods worked in Beta 1, it was as I was told it would work form discussions I had had with members of the VB team. But as I looked at it further it dawned on me that the design of having any instance method hiding all extension methods with the same name wasn&amp;#39;t really desirable. So I talked to some folks on the VB team about this. Meanwhile we were pushing the deadline out for print.  I ended up making edits but they didn&amp;#39;t make it into the printed release.
&lt;/p&gt;&lt;p&gt;The &lt;a href="http://www.ftponline.com/vsm/2007_05/magazine/columns/programmingtechniques/page3.aspx"&gt;last two paragraphs of the article read&lt;/a&gt;:
&lt;/p&gt;&lt;p style="background:#dbe5f1;margin-left:36pt;"&gt;If you recall the rules around precedence, you might be wondering if methods in your collection classes might Shadow LINQ statements by mistake. The answer to that is actually rather complex. The compiler goes out of its way to let the LINQ statements work. If you add a Select method to your collection class, VB uses AsQueriable to cast your collection to an IQueriable type, which means the compile precedence is on the IQueriable type. If you also have an AsQueriable type, it tries an AsIEnumerable extension, and failing that, it tries the Cast extension method. If all of those are Shadowed then the compiler throws a compile time error. 
&lt;/p&gt;&lt;p style="background:#dbe5f1;margin-left:36pt;"&gt;The goal is to allow you to use LINQ statements on existing collections of all sorts. Methods inside the collection classes are viewed as being from prior to LINQ and hence having a different intent. For this reason, the compiler attempts to navigate around them. If you need to change the LINQ behavior, you must use extension methods defined in a module and implement namespace precedence to suit your needs. 
&lt;/p&gt;&lt;p&gt;That was technically correct at the time, but I believe inaccurate as to what should happen, and as to what happens in C#.  The edited article replaced those two paragraphs with the following:
&lt;/p&gt;&lt;div style="margin-left:42pt;"&gt;&lt;table style="border-collapse:collapse;background:#eaf1dd;"&gt;&lt;tr&gt;&lt;td style="padding-left:7px;padding-right:7px;border-top:solid black 0.5pt;border-left:solid black 0.5pt;border-bottom:solid black 0.5pt;border-right:solid black 0.5pt;"&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;If you recall the rules around precedence, you might be wondering if methods in your collection classes might Shadow LINQ statements. The answer to that is instance methods will shadow by name and signature any extension methods. In the March CTP VB behaves differently: See sidebar &amp;quot;Out of the Shadows&amp;quot;.
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;Shadowing by name and signature in this case means methods that would resolve to the same if both were instance methods. Remember extensions are Shared methods with the first parameter the instance: hence when determining if a method is shadowed by an instance method, the first parameter in the extension method is removed from the actual signature.
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;For example, a Select extension would be shadowed by an instance method as long as the instance method has the correct and matching signature.
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;&amp;#39; inside a module
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;&amp;lt;Extension()&amp;gt; _
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;Public Function [Select](Of TSource, TResult) _
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        (ByVal source As IEnumerable(Of TSource), _
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        ByVal selector As Func(Of TSource, TResult)) _
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        As IEnumerable(Of TResult)
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        ….
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;End Function
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;&amp;#39; instance method inside the collection class
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;Public Function [Select](Of TResult)_
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        (ByVal selector As Func(Of T, TResult)) _
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        As IEnumerable(Of TResult)
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;        ….
&lt;/p&gt;&lt;p style="background:#eaf1dd;margin-left:18pt;"&gt;End Function
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;The source parameter is removed from the signature for the extension method, generic parameters are resolved, and return types ignored to determine if the instance method shadows the extension:  if they match, the instance method gets precedence.
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;The difficulty in using instance methods over extension methods for LINQ queries is you need to chain return types with types you have your instance methods in. Taking the earlier example of selecting a distinct list, the Distinct method has to be inside the type returned by the Select method. In that particular example you can have the Select return the same collection class and put your Distinct method in there. This becomes more complex when dealing with other projections and anonymous types. Rather than use instance methods you&amp;#39;ll find it generally easier to import a module with your extension methods in it. 
&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;margin-left:18pt;"&gt;Extension methods can make creating customized LINQ queries, easier, and easier to share amongst your different libraries or collection classes.  Powerful, yet incredibly simple in essence: used wisely they&amp;#39;ll make your coding easier.
&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;The sidebar was :
&lt;/p&gt;&lt;div style="margin-left:42pt;"&gt;&lt;table style="border-collapse:collapse;background:#eaf1dd;"&gt;&lt;tr&gt;&lt;td style="padding-left:7px;padding-right:7px;border-top:solid black 0.5pt;border-left:solid black 0.5pt;border-bottom:solid black 0.5pt;border-right:solid black 0.5pt;"&gt;&lt;p style="background:#eaf1dd;"&gt;&lt;h3&gt;Out of the Shadows
&lt;/h3&gt;&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;&lt;span style="font-family:Times New Roman;font-size:12pt;"&gt;In the March Orcas CTP, and most likely for Beta 1 of Orcas, VB shadows all extension methods by an instance method with the same name. That is, it shadows by name, not by name and signature. This has some unfortunate side effects such as the inability to add extensions with more or different parameters. A more complex issue arises around LINQ queries: if you have a Select method in your collection class that is the incorrect signature for the LINQ query, any Select extension in scope will be ignored for your collection class because they are shadowed. The compiler will then call a different extension method AsQueriable to cast the type to an IQueriable(Of T). Extension methods are then resolved for an IQueriable(Of t) rather than your collection class type. If your Select extension was written strongly typed to your collection class, it won&amp;#39;t get called.
&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;&lt;span style="font-family:Times New Roman;font-size:12pt;"&gt;The good news is I&amp;#39;ve had a chat to some of the VB team, and they&amp;#39;ve promised me they&amp;#39;ll look into. Most likely they will change it to shadows by name and signature. The bad news this change won&amp;#39;t make it into Beta 1, you&amp;#39;ll have to wait till Beta 2.
&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;&lt;span style="font-size:12pt;"&gt;&lt;span style="font-family:Times New Roman;"&gt;This highlights why we need to look at the early CTP&amp;#39;s and betas and give Microsoft feedback. They share these early bits with us so as we can shine light on things others might not notice and give them feedback early enough to steer them clear of any rocks lurking in the shadows. &lt;/span&gt;&lt;span style="font-family:Wingdings;"&gt;J&lt;/span&gt;&lt;span style="font-family:Times New Roman;"&gt;
								&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;
 &lt;/p&gt;&lt;p style="text-align:justify;background:#eaf1dd;"&gt;&lt;span style="font-size:12pt;"&gt;&lt;span style="font-family:Times New Roman;"&gt;And a special thanks to Adrian and Amanda for listening &lt;/span&gt;&lt;span style="font-family:Wingdings;"&gt;J&lt;/span&gt;&lt;span style="font-family:Times New Roman;"&gt;
								&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt;
 &lt;/p&gt;&lt;p&gt;My sincerest apologies for not getting this in the article on time to make the print release.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=934030" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/bill/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/bill/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://msmvps.com/blogs/bill/archive/tags/VSM/default.aspx">VSM</category></item></channel></rss>