<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Leaning Into Windows</title><subtitle type="html">Kathleen Dollard&amp;#39;s view of life and .NET development</subtitle><id>http://msmvps.com/blogs/kathleen/atom.aspx</id><link rel="alternate" type="text/html" href="http://msmvps.com/blogs/kathleen/default.aspx" /><link rel="self" type="application/atom+xml" href="http://msmvps.com/blogs/kathleen/atom.aspx" /><generator uri="http://communityserver.org" version="4.1.40407.4157">Community Server</generator><updated>2012-04-18T09:43:00Z</updated><entry><title>EventSource: A New Way to Trace</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2013/05/03/eventsource-a-new-way-to-trace.aspx" /><id>/blogs/kathleen/archive/2013/05/03/eventsource-a-new-way-to-trace.aspx</id><published>2013-05-03T22:21:00Z</published><updated>2013-05-03T22:21:00Z</updated><content type="html">&lt;h3&gt;Module 3 Highlights&lt;/h3&gt;
&lt;p&gt;This is the next installment in my series of high points in .NET 4.5, which parallels my Pluralsight course &amp;ldquo;&lt;a href="http://www.pluralsight.com/training/Courses/TableOfContents/dotnet45-whatsnew"&gt;What&amp;rsquo;s New in .NET 4.5&lt;/a&gt;&amp;rdquo;. I think the course offers important insight and details into the release, and if you&amp;rsquo;ve already watched it, this will give a second explanation of the most important features. If you don&amp;rsquo;t watch it, you can follow along with the most important features I cover.&lt;/p&gt;
&lt;p&gt;First two installments of the course highlights are &lt;a href="http://msmvps.com/blogs/kathleen/archive/2013/03/29/module-1-high-points-side-by-side-implications.aspx"&gt;here&lt;/a&gt; and &lt;a href="http://msmvps.com/blogs/kathleen/archive/2013/04/03/module-2-high-points-portable-class-libraries.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;What&amp;rsquo;s New?&lt;/h4&gt;
&lt;p&gt;Tracing becomes more and more critical as our applications move onto remote servers and into the cloud. Even with other tools available, desktop applications still need tracing to determine what the user was doing when a problem appears. Debug mode is rarely an option in production. &lt;/p&gt;
&lt;p&gt;Microsoft&amp;rsquo;s answer is high speed unified tracing within the operating system: Event Tracing for Windows. ETW has been around since Vista, so it&amp;rsquo;s hardly a news flash. What&amp;rsquo;s new in .NET 4.5 is that ETW goes from being a royal pain to use to being one of the most simple and elegant features of .NET. This change makes ETW support and the new EventSource class is &lt;b&gt;the &lt;/b&gt;sleeper feature of .NET 4.5 &amp;ndash; the most important feature you never heard of. &lt;/p&gt;
&lt;p&gt;So, let me explain, and hopefully inspire you to completely rethink your tracing strategy. Warning, if you&amp;rsquo;re fantasies get too carried away, I&amp;rsquo;ll knock a few over when I cover shortcomings near the end of the post.&lt;/p&gt;
&lt;p&gt;While I won&amp;rsquo;t cover it hear, the Semantic Logging Block Patterns and Practices is using unifies ETW with traditional trace output locations and plus a couple of holes. So, if I get your attention, you may also want to explore what they&amp;rsquo;ve done &amp;ndash; same underlying tools and syntax, with some important additions. &lt;/p&gt;
&lt;h4&gt;ETW &lt;/h4&gt;
&lt;p&gt;ETW is a high performance tracing system built into the operating system. It&amp;rsquo;s a fully composite system with some extreme extensibility options. There are four moving parts &amp;ndash; ETW itself, providers, controllers and consumers. Because it&amp;rsquo;s a completely interchangeable system, not only can you come up with your own providers, controller and consumers to support ETW, you can replace ETW with something else filling it&amp;rsquo;s role &amp;ndash; allowing alternate tracing options such as Silverlight support. That&amp;rsquo;s amazing, but the important parts to .NET 4.5 are providers, consumers, and controllers. &lt;/p&gt;
&lt;p&gt;Consumers are important because the OS creates the smallest possible binary output to meet its goal of not hurting performance with tracing. There are a number of task specific consumers, including Visual Studio tooling, such as WCF tools and the Concurrency Visualizer. A good general purpose tool to consider is PerfView. And if you want, or need, to write your own tooling, you can use PerfView&amp;rsquo;s underlying libraries to access the binary stream. Or, if you need to party on raw trace events, you can get the binary stream transformed into XML output. &lt;/p&gt;
&lt;p&gt;Controllers turn ETW on and off. Gone are the days of stopping your server, changing a configuration setting, and restarting the server &amp;ndash; only to repeat in order to turn tracing off. Controllers communicate to providers whether they are on or off, and can do this to running applications. Tracing can be turned on before your application starts, as part of startup, or as the application runs. Controllers also communicate filtering information such as severity level to providers. &lt;/p&gt;
&lt;p&gt;Providers create trace events. The operating system, .NET and other libraries are already fully on board. Right now you can fire up PerfView and get information on your application, including crashes. The purpose of the new EventSource class is to let you add events to this holistic stream. &lt;/p&gt;
&lt;p&gt;Providers create trace events, controllers turn tracing on and off, and consumers do something with the resulting trace. Central to the design is a stream of trace events (actually a few streams, called channels, see more below). It doesn&amp;rsquo;t matter if the trace event is created by your application, the operating system, the .NET framework, WCF, or anything else. &lt;/p&gt;
&lt;p&gt;This creates a fundamentally different approach to tracing because you don&amp;rsquo;t have much work to do. &lt;i&gt;Almost&lt;/i&gt; everything you want to know is already in the trace system.&lt;/p&gt;
&lt;h4&gt;A New Way of Thinking about Tracing&lt;/h4&gt;
&lt;p&gt;If you&amp;rsquo;ve done tracing before, you probably worked to create a reasonably complete picture of what was happening in your application - you took responsibility for providing all of the relevant information. That&amp;rsquo;s changed. Since other providers are already dumping information into ETW you can think of the trace stream as a river with all of the information you can imagine flowing passed. &lt;/p&gt;
&lt;p&gt;Your job is simply to complete the picture. The river has no context without your help. The surface is just a series of waves with no relation to what&amp;rsquo;s actually happening. Throw in key buoys about what you&amp;rsquo;re doing, and suddenly the part of the river adjacent to your buoy makes sense. &lt;/p&gt;
&lt;p&gt;The markers you throw out can contain information like the current record. But remember the earlier caveat &amp;ndash; what you put into the ETW stream with EventSource will be visible to whomever asks for it. You can&amp;rsquo;t put in sensitive information. Let me say that again &amp;ndash; do not put any information into the ETW stream that can&amp;rsquo;t be seen by people with access to your servers. &lt;/p&gt;
&lt;h4&gt;Strong Typing and Manifests&lt;/h4&gt;
&lt;p&gt;One of the important ways ETW differs from some other approaches to tracing is that the information you provide is strongly typed. If you record primary keys and tables, you can find a trace vent with a particular primary key from a particular table. You can then watch that thread or process for information on the process that occurs. &lt;/p&gt;
&lt;p&gt;To keep tracing blazingly fast, the operating system creates the trace as a binary stream of goo. Turning goo into strongly typed events requires en event specific definition, which is called a manifest in ETW. &lt;/p&gt;
&lt;p&gt;Prior to .NET 4.5 you could create your own manifest or skip the strongly typed benefits of ETW. It&amp;rsquo;s icky work to create your own manifest and you have to install it on the machine that interprets the trace. This is really problematic if you version your trace event structure (and trust me, you will) because the machine may need to interpret traces from many other machines. &lt;/p&gt;
&lt;p&gt;.NET 4.5 and the EventSource class creates the manifest for you and sidesteps manifest issues by using an &amp;ldquo;in-line manifest.&amp;rdquo; That&amp;rsquo;s just another event that contains the manifest. As long as the consumer knows how to grab that special manifest event and use the attached manifest (and PerfView does) all your manifest problems are solved. &lt;/p&gt;
&lt;h4&gt;EventSource&lt;/h4&gt;
&lt;p&gt;The ETW goodness in .NET 4.5 is wrapped up in the EventSource class. The second best source of information on ETW (I like my &lt;a href="http://pluralsight.com/training/Courses/TableOfContents/dotnet45-whatsnew"&gt;Pluralsight video&lt;/a&gt;) is Vance Morrison&amp;rsquo;s blog posts, such as &lt;a href="http://blogs.msdn.com/b/vancem/archive/2012/07/09/logging-your-own-etw-events-in-c-system-diagnostics-tracing-eventsource.aspx"&gt;this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;While Vance&amp;rsquo;s posts do a great job, and this post is important, this particular post doesn&amp;rsquo;t mention that you should probably define your event id&amp;rsquo;s and provider name. Before you add tracing to your own application, be sure to understand those two features. &lt;/p&gt;
&lt;h4&gt;It&amp;rsquo;s Not All Joy &amp;ndash; Bad Tooling&lt;/h4&gt;
&lt;p&gt;I said I might knock over your fantasies a bit. The biggest problem with ETW is a lack of good tooling. Please help pressure the Visual Studio team to supply an awesome consumer and at least a decent controller. Interpreting traces is hard and we don&amp;rsquo;t all need to work out the tricks. &lt;/p&gt;
&lt;p&gt;PerfView is the best tool I know of now for the things you&amp;rsquo;ll need to do. But imagine Microsoft releasing the tool one dev made for their own use and it sort of spiraled into general use by those brainiac softies, and then (thank goodness) they released it to use. You won&amp;rsquo;t be too far off the mark. But from that you might guess that the important parts are open source, so you can use the underlying library to build your own tool. You&amp;rsquo;ll find the &lt;a href="http://bcl.codeplex.com/wikipage?title=TraceEvent&amp;amp;referringTitle=Home"&gt;TraceEvent library&lt;/a&gt; on the BCL team&amp;rsquo;s CodePlex site.&lt;/p&gt;
&lt;h4&gt;It&amp;rsquo;s Not Complete &amp;ndash; Channels, etc.&lt;/h4&gt;
&lt;p&gt;The other issue with ETW right now is hard to complain about. Once they got to the edges of what they needed and problems they understood &amp;ndash; largely around profiling the .NET framework itself &amp;ndash; they slowed down. I don&amp;rsquo;t think this is laziness, but an honest desire to get it right. I think the most obvious place you&amp;rsquo;ll see this is the lack of channel support. &lt;/p&gt;
&lt;p&gt;ETW supports four channels. While you can define your own, I haven&amp;rsquo;t yet seen a good use case. The well-known channels are Admin, Operational, Analytic and Debug. EventSource tracing aims at the last &amp;ndash; events by devs for devs. Your IT folks (and probably you as well) use the Windows Event Viewer to gauge system healthy. At present, trace events you create with the EventSource class do not show up in Event Viewer because they aren&amp;rsquo;t admin events. &lt;/p&gt;
&lt;p&gt;I was initially appalled by this omission, annoyed that it felt like they ran out of time. But I&amp;rsquo;ve evolved my thinking. Event Viewer and trace events for the purpose of system health monitoring and warm fuzzies for your IT staff, are inherently different than profiling and debugging information (which overlap). Specifically, you want bells and whistles for filtering and you want to filter extra events at the point of consumption (assuming they aren&amp;rsquo;t so extreme that they affect performance). &lt;/p&gt;
&lt;p&gt;Your IT folks probably don&amp;rsquo;t see it that way. They probably want your apps to tell them what they need to know when they need to know it. &amp;ldquo;Just the facts, ma&amp;rsquo;am.&amp;rdquo; And maybe strong typing doesn&amp;rsquo;t matter very much. Let&amp;rsquo;s start a conversation about the best ways to get information into the admin channel. &lt;/p&gt;
&lt;h4&gt;Semantic Logging Application Block&lt;/h4&gt;
&lt;p&gt;I&amp;rsquo;m just getting into this, but I&amp;rsquo;m excited about what I&amp;rsquo;m hearing about the Semantic Logging Application Block (other than its name, and it&amp;rsquo;s even worse acronym, but I&amp;rsquo;ll survive). You can get info on the CTP &lt;a href="http://entlib.codeplex.com/wikipage?title=Entlib6CTPReleaseNotes"&gt;here&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/b/agile/archive/2013/02/07/embracing-semantic-logging.aspx"&gt;here&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m really happy that P&amp;amp;P is building on the good work of the BCL team and building on it in ways that make sense to business programmers. What most catches my eye is that you&amp;rsquo;re EventSource derived classes can be used to write to ETW or more traditional trace listeners. I hope to have time to explore the Semantic Logging Application Block in the coming weeks and post a more thorough discussion. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1829317" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET 4.5" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET+4.5/default.aspx" /></entry><entry><title>Why a Women In Technology Luncheon</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2013/05/02/why-a-women-in-technology-luncheon.aspx" /><id>/blogs/kathleen/archive/2013/05/02/why-a-women-in-technology-luncheon.aspx</id><published>2013-05-02T18:05:00Z</published><updated>2013-05-02T18:05:00Z</updated><content type="html">&lt;p&gt;I just read &lt;a href="http://stronglikebool.com/post/2013/04/10/No-I-Dont-Want-a-Ticket-for-the-Womens-Luncheon"&gt;this post&lt;/a&gt; by Samantha Houtsand and it annoyed me. No, it pissed me off. She hasn&amp;rsquo;t been to a &amp;ldquo;Women in Technology&amp;rdquo; event since a bad one in high school and explained to the world what WIT events are. She entirely mischaracterized a specific event&lt;b&gt; that she did not attend.&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;ldquo;My initial hesitation about going to the luncheon had gradually grown into a vehement denial that the luncheon should exist in the first place. What was the point of it? Was it a support group? A private club with a &amp;quot;no boys allowed&amp;quot; sign stuck on the table? &amp;ldquo;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Depending on whether I had a talk following the luncheon at that specific DevConnections she attended, I was there, and possibly on a panel. Had she gone&amp;hellip;&lt;/p&gt;
&lt;p&gt;She probably would have seen Michelle and Julie and a lot of other awesome women &amp;ndash; speakers and attendees. &lt;/p&gt;
&lt;p&gt;Folks would have asked questions like &amp;ldquo;I&amp;rsquo;m a bit intimidated about letting my team know I&amp;rsquo;m pregnant&amp;rdquo; (Samantha brought this up) and gotten an answer like &amp;ldquo;it&amp;rsquo;s probably not going to be a problem, follow a gut and know who your friends are.&amp;rdquo; &lt;/p&gt;
&lt;p&gt;She might have heard from someone that had a bad work situation, with advice something like &amp;ldquo;create the scenario where you can move on and find a better fit,&amp;rdquo; probably with a gentle tough love comment about what the person was doing to prepare for those new internal jobs as well. &lt;/p&gt;
&lt;p&gt;She probably would have heard from someone asking about work/life balance. She would have realized that no one, famous or not, thinks they do it very well. &lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a good chance she would have heard a question about increasing visibility or technical skill set. The answer would have been &amp;ldquo;hard work,&amp;rdquo; along with some roadmap signposts specific to their goals. &lt;/p&gt;
&lt;p&gt;Someone would probably have asked about how we get more young women into technology. That&amp;rsquo;s not just an IT question &amp;ndash; we&amp;rsquo;re doing badly in all technical fields except medicine. A lot of stupid things would have probably been said, there&amp;rsquo;s no good answer.&lt;/p&gt;
&lt;p&gt;She might have heard someone ask about encouraging a young person to consider this industry. Someone might have mentioned professional Barbies and hopefully someone would point out the importance of gender neutral gifts (LEGOs are gender neutral !!!!) for nieces, nephews, etc.&lt;/p&gt;
&lt;p&gt;There would have been a couple of specific technical or entrepreneurship questions that were answered or taken off line.&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Oh, crap, we&amp;rsquo;re out of time&amp;rdquo;&lt;/p&gt;
&lt;p&gt;None of this is whining. It&amp;rsquo;s a conversation about issues &amp;ndash; in a mostly female environment (men often come, and I would never support excluding them).&lt;/p&gt;
&lt;p&gt;If she had attended the luncheon, she would have made a few contacts of technical or business interest. If she was attending the conference alone, she would have had more friendly faces. And if she &lt;b&gt;wasn&amp;rsquo;t shy&lt;/b&gt;, she could have done the same things in the main lunch area.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&amp;ldquo;What bothers me about &amp;quot;women in technology&amp;quot; is the apparent need to beat their bosoms and proclaim that the industry &lt;/i&gt;&lt;em&gt;must&lt;/em&gt;&lt;i&gt; change to accommodate them, &lt;/i&gt;&lt;em&gt;must&lt;/em&gt;&lt;i&gt; recognize that they exist, &lt;/i&gt;&lt;em&gt;must&lt;/em&gt;&lt;i&gt; treat them &lt;/i&gt;&lt;em&gt;equally&lt;/em&gt;&lt;i&gt;!! -- but &lt;/i&gt;&lt;em&gt;differently&lt;/em&gt;&lt;i&gt;.&amp;rdquo;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;I have never met the women that she describes here. Never. Anywhere. Nada. I&amp;rsquo;ve met tens of thousands of developers, and a number of IT pros, and I&amp;rsquo;ve never met women that wanted the industry to offer more than common decency and fairness. Send me the links where women are asking the industry to accommodate them or think they need or should have &amp;ldquo;special treatment&amp;rdquo; (from a comment on Samantha&amp;rsquo;s blog). I&amp;rsquo;ve heard people make this claim, but show me the evidence - when and where!&lt;/p&gt;
&lt;p&gt;Having lunch together does not equate to bosom beating. Being inspired by amazing women like Cathy Sullivan or Rhonda Layfield (both have been on past panels) is not bosom beating. Asking questions across the table or of the panel is not bosom beating. &lt;/p&gt;
&lt;p&gt;Why did I write this? I&amp;rsquo;m tired of seeing mischaracterization of women in this industry. We aren&amp;rsquo;t a bunch of whining angry bosom beaters, any more than the jobs we fill are &amp;ldquo;men&amp;rsquo;s jobs.&amp;rdquo; Samantha knew nothing about the DevConnections lunch because she chose not to attend it. &lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s OK to have a conversation about women in this industry. Samantha chose to make herself part of that conversation. But that conversation must be on what&amp;rsquo;s real, not on this persistent crazy fantasy that there is a cadre of harpies somewhere. &lt;/p&gt;
&lt;p&gt;Trust me, almost every woman in this industry is, like Samantha, just out there working hard, bringing a unique set of skills and capabilities to the problem at hand, and thinking about how to build the career she wants in a very crazy, tough, fun industry. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1829212" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term="Women in Tech" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Women+in+Tech/default.aspx" /></entry><entry><title>Module 2 High Points: Portable Class Libraries</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2013/04/03/module-2-high-points-portable-class-libraries.aspx" /><id>/blogs/kathleen/archive/2013/04/03/module-2-high-points-portable-class-libraries.aspx</id><published>2013-04-03T14:53:00Z</published><updated>2013-04-03T14:53:00Z</updated><content type="html">&lt;p&gt;I&amp;rsquo;m continuing to channel how excited I am about my Pluralsight course &amp;ldquo;&lt;a href="http://www.pluralsight.com/training/Courses/TableOfContents/dotnet45-whatsnew"&gt;What&amp;rsquo;s New in .NET 4.5&lt;/a&gt;&amp;rdquo; into a series of blog posts with the most important thing(s) in each module. Sure, I won&amp;rsquo;t mind if these posts inspire you to watch my course, but I&amp;rsquo;m also doing this so folks that can&amp;rsquo;t watch my course can still get the most important information. &lt;/p&gt;
&lt;h4&gt;Module 2: Changes to the Core Framework&lt;/h4&gt;
&lt;p&gt;There is a whole lot of information in this module, and I might come back to the most important thing in each clip. But for right now, I&amp;rsquo;m going to maintain discipline and focus on the single most important thing, which has two parts. &lt;/p&gt;
&lt;p&gt;That would be the changes in how we deliver applications - how libraries are arranged and how MSIL becomes native code on the target machine. I&amp;rsquo;ll focus on how libraries are arranged, with just a smidgen on native code creation because it deserves a dedicated post.&lt;/p&gt;
&lt;h5&gt;Portable Class Libraries&lt;/h5&gt;
&lt;p&gt;You might have heard about Portable Class Libraries. It&amp;rsquo;s a new type of class library you can create that will run on the platforms you choose. Right, that&amp;rsquo;s platformS, plural. In the box you&amp;rsquo;ve got .NET main framework, Silverlight, XBox, Windows Store and Phone. Online, you&amp;rsquo;ve got more, including Azure and updates to other platforms. &lt;/p&gt;
&lt;p&gt;In these libraries &amp;ndash; these DLLs &amp;ndash; you can only do things that work across all the selected platforms &amp;ndash; the limited intersection of behavior. You&amp;rsquo;re not going to write your entire application this way, but you can create key libraries with business rules, calculations, maybe service access, maybe View Models &amp;ndash; you get the idea. This, of course, directly useful. It also causes both you and Microsoft to rethink the concept of a DLL.&lt;/p&gt;
&lt;h5&gt;Your Libraries&lt;/h5&gt;
&lt;p&gt;Using Portable Class Libraries will force you It will instill new discipline in your designs, and I&amp;rsquo;d encourage you to begin moving everything possible into Portable Class Libraries just for this reason. &lt;/p&gt;
&lt;p&gt;Isolated designs have been on our whiteboards for years - like View Models without any UI artifacts. But enforcement was by .NET libraries &amp;ndash; and they were designed for many reasons other than correctly dissecting your code. No one that created reflection had a clue that it would look fundamentally different in a Windows Store application. &lt;/p&gt;
&lt;p&gt;Visual Studio provides the appropriate IntelliSense and the compiler structures the correct libraries. We coders work organically. There are things we learn to do reflexively, and you want the classes and methods you reach for to be the right ones &amp;ndash; generally that means the techniques with the broadest reach. As you learn what works within your Portable Class Libraries, you&amp;rsquo;ll learn what works across multiple platforms. &lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll warn you that the jury isn&amp;rsquo;t entirely in on some critical details, such as using async across some of the different platforms, but many core features work flawlessly today, and the others are sorting themselves out. &lt;/p&gt;
&lt;h5&gt;Microsoft Libraries&lt;/h5&gt;
&lt;p&gt;Prior to .NET 4.5, the .NET libraries were fairly large units and completely different versions were created for alternate platforms. Just ask a phone developer how painful this pattern was as new sets of redesigned libraries reflected changes in how .NET was interpreted for the platform. &lt;/p&gt;
&lt;p&gt;Starting with apps targeting .NET 4.5, there&amp;rsquo;s a new approach to core assemblies. This reflects platform differences, such as how local storage works, and isolates commonalities. Sometimes, such as the new Zip libraries in .NET 4.5, libraries can be designed with portability in mind. &lt;/p&gt;
&lt;p&gt;It doesn&amp;rsquo;t make sense to restructure legacy assemblies to meet today&amp;rsquo;s vision, because today&amp;rsquo;s arrangement will be tomorrow&amp;rsquo;s legacy. Instead a huge effort behind the scenes created smaller leaner libraries that can be pulled together, and a redirect system that means you no longer care where any piece of functionality resides. &lt;/p&gt;
&lt;p&gt;You can see this in Object Browser. View Containers to show the assemblies (from the gear for settings) and select &amp;ldquo;Portable Class Subset&amp;rdquo; (not legacy) from the dropdown. Now open mscorlib. Huh!!! It&amp;rsquo;s empty. That&amp;rsquo;s a bit of a surprise.&lt;/p&gt;
&lt;p&gt;Now open System.Runtime &amp;ndash; which is one of the many libraries that didn&amp;rsquo;t previously exist. It&amp;rsquo;s got all that mscorlib stuff. What you need at runtime will be there &amp;ndash; &lt;i&gt;but in an assembly location that&amp;rsquo;s platform dependent. &lt;/i&gt;&lt;/p&gt;
&lt;h5&gt;Reflection&lt;/h5&gt;
&lt;p&gt;Nowhere is the importance of PCL more evident than with the newly designed reflection. It needed an overhaul. It sits at a critical junction of many other things &amp;ndash; often causes performance problems of design compromise to avoid performance issues. For example, if you ask for the members of a type, assemblies containing all base types must be loaded. Also, GetMembers and its siblings have horrendous enum dependent overloads to help you filter the results. &lt;/p&gt;
&lt;p&gt;Microsoft redesigned reflection for Windows Store applications. I&amp;rsquo;ll skip the details, but the GetMembers method is replaced with a DeclaredMembers property that returns an IEnumerable you can party on with LINQ. It doesn&amp;rsquo;t load any base class assemblies &amp;ndash; if you want that, walk the tree so you understand what&amp;rsquo;s happening. The team also split the name of the type separate from all other functionality. The name is often enough and avoids loading even the class&amp;rsquo;s assembly. &lt;/p&gt;
&lt;p&gt;This quick sketch of the massive change lets me illustrate why you want to move reflection based code into PCL projects. &lt;/p&gt;
&lt;p&gt;.NET main framework projects need to support the old and new reflection approach. Instead of ditching the old stuff and creating a new namespace, they extended existing reflection to include the new features. I&amp;rsquo;ll leave it to the video to explain the inheritance hierarchy sleight of hand that let&amp;rsquo;s this happen. But the resulting classes have all the features of the old &lt;b&gt;&lt;i&gt;and&lt;/i&gt;&lt;/b&gt; new reflection approaches. &lt;/p&gt;
&lt;p&gt;While I agree with this decision to allow smooth transition of existing reflection code with no breaking changes, I think it makes it nearly impossible to learn and use the new reflection approach &amp;ndash; unless you create a PCL targeting main framework and Windows Store apps and do as much of your reflection work as possible in this assembly. &lt;/p&gt;
&lt;p&gt;You&amp;rsquo;re already doing all your reflection in utility methods &amp;ndash; right? No? Well, then this is also a moment for reflection, er, um, no, um, meditation, contemplation, &lt;a href="http://www.bing.com/Dictionary/Search?q=define+deliberation&amp;amp;form=DTPDIO"&gt;deliberation&lt;/a&gt;, musing, rumination on the nature of an evolving framework and how to structure code to survive this change. That&amp;rsquo;s more posts, and I&amp;rsquo;ll get to them, but for now, reflection of your poster child of constructive change you&amp;rsquo;ll need to roll with. &lt;/p&gt;
&lt;h5&gt;JIT and NGen&lt;/h5&gt;
&lt;p&gt;It&amp;rsquo;s a separate blog post series, but I just can&amp;rsquo;t talk about this module without talking about JIT and NGetn. Your actual delivery is changing. There are now six, or is it seven, different ways IL can turn into native code on your target machine. It&amp;rsquo;s a pretty big set of changes, and I promise a blog post that cuts through some of the detail I hit in the video to more simply explain how to choose your approach. But don&amp;rsquo;t worry, for most people, most of the time plain old JIT remains the best approach (maybe with a little chocolate sprinkles).&lt;/p&gt;
&lt;h5&gt;Core Library Changes&lt;/h5&gt;
&lt;p&gt;Does my focus on the library creation and deployment mean that there weren&amp;rsquo;t any meaningful changes to the libraries themselves &amp;ndash; new classes and methods? No, it doesn&amp;rsquo;t mean that at all. &lt;/p&gt;
&lt;p&gt;There were a lot of changes to the core frameworks, and I hope to come back and give the most important couple of items from each clip in this module &amp;ndash; changes to reflection, big arrays, console improvements, and, most exciting of all, real Zip support. These are great improvements, but none of them stand out as changing your development the way PCL does. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1826480" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET 4.5" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET+4.5/default.aspx" /></entry><entry><title>Module 1 High Points – Side by Side Implications</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2013/03/29/module-1-high-points-side-by-side-implications.aspx" /><id>/blogs/kathleen/archive/2013/03/29/module-1-high-points-side-by-side-implications.aspx</id><published>2013-03-29T14:14:00Z</published><updated>2013-03-29T14:14:00Z</updated><content type="html">&lt;p&gt;I&amp;rsquo;m really excited about my new &amp;ldquo;&lt;a href="http://www.pluralsight.com/training/Courses/TableOfContents/dotnet45-whatsnew"&gt;What&amp;rsquo;s New in .NET 4.5&lt;/a&gt;&amp;rdquo; course on Pluralsight. &lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s more information in the course than I could stuff into my blog in a year, but I want to cover a few high points here. I wrote the course as &amp;ldquo;What I want every coder and manager to know about this release,&amp;rdquo; but I know you won&amp;rsquo;t &lt;i&gt;all&lt;/i&gt; get a chance to watch it. So, I&amp;rsquo;ll cover what I can here, starting with a series of short posts with the most important point, or maybe two, in each of the eight modules. &lt;/p&gt;
&lt;h4&gt;Module 1 &amp;ndash; Introduction&lt;/h4&gt;
&lt;p&gt;Yes, the introduction is more than an agenda slide J&lt;/p&gt;
&lt;p&gt;As an in-place release, there are two versions of the .NET 4 libraries &amp;ndash; no, wait three versions &amp;ndash; and probably more in the future. That&amp;rsquo;s right, I said the .NET 4 libraries &amp;ndash; it doesn&amp;rsquo;t matter whether your targeting .NET 4.0 or 4.5. I know that sounds a little crazy, but I&amp;rsquo;m afraid we&amp;rsquo;re going to have to get used to the craziness. &lt;/p&gt;
&lt;p&gt;You probably don&amp;rsquo;t control the version of the .NET framework that&amp;rsquo;s running in production. Another application installation, or the user, or an operating system upgrade (Windows 8 or Server 2012), or at some future point Windows Update could upgrade a target computer to a new version of .NET 4 without you touching your deployed application in any way. &lt;/p&gt;
&lt;p&gt;That should scare you, but it&amp;rsquo;s part of the brave new world. Microsoft is tooling itself for fast incremental releases, led by the fantastic advancements in the Azure space. There&amp;rsquo;s a good side of this and a bad side of this, and in the end I&amp;rsquo;m not sure it matters very much what I think. &lt;/p&gt;
&lt;p&gt;So, you&amp;rsquo;ve got to learn about this release, whether or not you intend to target .NET 4.5 in the foreseeable future. And we need to ferret out ways for ongoing validation of our working systems &amp;ndash; validated algorithms, in-place production testing, and widespread use of tracing (oh wait! that&amp;rsquo;s module 3 on ETW support). &lt;/p&gt;
&lt;p&gt;I said there were three, versions of the .NET 4.0 framework in the wild &amp;ndash; there are probably more with hot fixes, but these are the three you need to know about.&lt;/p&gt;
&lt;p&gt;- .NET 4.0 released with VS 2010 (4.0.30319.&lt;b&gt;&lt;span style="text-decoration:underline;"&gt;1&lt;/span&gt;)&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;- .NET 4.5 released with VS 2012, regardless of target platform (4.0.30319.&lt;b&gt;&lt;span style="text-decoration:underline;"&gt;17929&lt;/span&gt;&lt;/b&gt;)&lt;/p&gt;
&lt;p&gt;o Please don&amp;rsquo;t run this version this pre-January 2013 updates version if you can help it&lt;/p&gt;
&lt;p&gt;o You may not be able to ensure your user&amp;rsquo;s install this &lt;i&gt;recommended&lt;/i&gt; upgrade&lt;/p&gt;
&lt;p&gt;o There&amp;rsquo;s a corresponding security update that is separate and &lt;i&gt;required&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;- .NET 4.5 reliability (and security) update released January 8, 2013 (4.0.30319.&lt;b&gt;&lt;span style="text-decoration:underline;"&gt;18033&lt;/span&gt;)&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;-&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re not thoughtful, you may be testing against a different version of the framework than the one your users are running. &lt;/p&gt;
&lt;p&gt;On a particular machine, you can determine whether the updates are installed through Windows Update history, the registry, or the version number on something like mscorlib.dll in the GAC (oh wait! that&amp;rsquo;s module 8 on breaking changes). You can also test for the existence of the type System.ReflectionContext if you want to know whether you&amp;rsquo;re working with a version above the VS 2010 libraries (4.0.30319.1). Test for a type, not a member (reflection considerations are in module 2 on the core framework changes) and not the specific version number, which might be fragile going forward. &lt;/p&gt;
&lt;p&gt;There are at least four ways the new version of .NET will affect your code:&lt;/p&gt;
&lt;p&gt;- When new libraries are installed in production (what I&amp;rsquo;m talking about in this post)&lt;/p&gt;
&lt;p&gt;- When you recompile with the VS 2012 compilers (regardless of your target version)&lt;/p&gt;
&lt;p&gt;- When you target .NET 4.5 for its awesome new features &lt;/p&gt;
&lt;p&gt;- When you rerun custom tools&lt;/p&gt;
&lt;p&gt;- When a computer you exchange data with upgrades libraries&lt;/p&gt;
&lt;p&gt;The five point survival guide is test, test, test, test, test, test. And that&amp;rsquo;s regardless of when you plan to explicitly target .NET 4.5.&lt;/p&gt;
&lt;p&gt;Overall .NET 4.5 is awesome and the compatibility of the new libraries is good. But, if your one of the unlucky ones that encounter a problem, the probabilities don&amp;rsquo;t matter at all. &lt;/p&gt;
&lt;p&gt;Whether it&amp;rsquo;s through my course or other venues &amp;ndash; if you&amp;rsquo;re responsible for production code, you really need to learn about .NET 4.5 and start considering how you&amp;rsquo;re going to accommodate the new fast moving cycles. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1826106" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET 4.5" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET+4.5/default.aspx" /></entry><entry><title>DevIntersection</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2013/03/08/devintersection.aspx" /><id>/blogs/kathleen/archive/2013/03/08/devintersection.aspx</id><published>2013-03-08T14:22:41Z</published><updated>2013-03-08T14:22:41Z</updated><content type="html">&lt;p&gt;I thought I should post a status after being so quiet on Twtiter and my blog.&lt;/p&gt;  &lt;p&gt;I had a really fun, intense time putting together my next Pluralsight video. It’s delayed for a technical screw-up on my part, but it should be up in the next week or two. &lt;/p&gt;  &lt;p&gt;Upcoming, I’ll be at DevIntersection (&lt;a href="http://www.devintersection.com/"&gt;www.Devintersection.com&lt;/a&gt;). I think it’s going to be an awesome show – check out the line- up of speakers. There’s also a great pre/post con deal – registering for the conference and pre or post con gets you a tablet as well! And if you use the discount code DOLLARD (how easy is that to remember) you’ll get $50 off! &lt;/p&gt;  &lt;p&gt;If you haven’t heard of DevIntersection, that’s because it’s a new conference. But don’t worry, it will be smooth and professionally run with leadership and staff that are some of the most experienced around in presenting conferences for developers&lt;/p&gt;  &lt;p&gt;I’ll be teaching you things you don’t know or have forgotten about the core .NET framework in a pre-conference workshop titled “&lt;i&gt;Getting the Most from the .NET Framwork”&lt;/i&gt;. Half the day is fast paced puzzle format with plenty of surprises for even the most experienced .NET programmer. I get asked whether the details matter – I pick puzzles because they affect what code runs, the result of calculations, might have significant performance implications, and help you better understand the framework. This understanding helps you read code, and it helps you right code with minimal surprises – bugs based on surprises are hard to find!&lt;/p&gt;  &lt;p&gt;In the afternoon I’ll move through potentially challenging areas of the framework improving your mental models of how and why things work. I’ll teach the why and how, not demonstrate the how-to. You need both, but this day is dedicated to making you a smarter, more robust programmer. &lt;/p&gt;  &lt;p&gt;If you live in Vegas or can get there easily, you can register separately for pre and post conferences – but then you’ll miss the show!&lt;/p&gt;  &lt;p&gt;The next conference I’m scheduled for is DevTeach, May 37-31 outside Toronto. I’m looking forward to celebrating DevTeach’s 10&lt;sup&gt;th&lt;/sup&gt; anniversary. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1824850" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Workshop</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/12/05/workshop.aspx" /><id>/blogs/kathleen/archive/2012/12/05/workshop.aspx</id><published>2012-12-05T15:56:16Z</published><updated>2012-12-05T15:56:16Z</updated><content type="html">&lt;p&gt;I’m extending my popular “Getting Geeky” series to a full day workshop at DevIntersection on Dec 13. I’ve struggled a bit naming and describing this series – it’s called “Better Coding: Stop Coping, Start Comprehending” at DevIntersection. My goal is to dive into the important aspects of the .NET framework – both old and new. To expose you to, or remind you of, details in the context of why the .NET framework behaves the way it does - from details about integer math, inference and overloads to the implications of MEF and Async on your architecture. It’s very fast paced and focuses on the things that I think you need to know that many people, even many very, very smart programmers don’t know. &lt;/p&gt;  &lt;p&gt;I’ll do this workshop with a little theory and a lot of code “puzzles.” Unit tests where the audience gets to predict which asserts that will pass and get immediate feedback directly with the code. You’ll also get my puzzles code to experiment with later. It’s a fun way to stay engaged – while it’s obviously important to know what code will run and what the outcome will be, zillion of details can get scattered and a bit dry without some underlying theory and the code itself teaching you. &lt;/p&gt;  &lt;p&gt;I love getting excited about new features – but I also love making a fun time of understanding what’s in the core. I’d love to see you at my workshop at DevIntersection. I’m also available to give this workshop in a one or two day forma, with or without adjacent mentoring and team coaching. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;You can sign up for DevIntersection, or the workshop &lt;a href="http://www.devintersection.com/?refer=DOLLARD"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Here’s some recent feedback from the short form of this talk: &lt;/p&gt;  &lt;p&gt;&lt;i&gt;“If this presentation had been a job interview, I would have failed. That is what made it a great presentation. The most dangerous facts are the ones we are sure we know that aren&amp;#39;t true. Without every actually having looked into it, I expected the default behavior of .NET to be to automatically detect arithmetic overflows, only to have Kathleen teach me that it is not the default for integer math and is not even an option for floating-point math.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;In about an hour and a half there were a dozen other puzzles about .NET basics, teaching me that I do not fully grasp overloads, type inference, generics, and other key framework concepts. I would have skipped lambdas and closures myself, as they have done nothing but make my head hurt since I first read about LISP in 1975. However Kathleen rightly discussed them as they are necessary to understand her discussion of LINQ, which is useful.” - &lt;/i&gt;Martin Buchanan&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Your talk on Monday was absolutely your best ever – you really have a special touch that you have been refining for quite a while and you could not have been better – very impressive! &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;My members really liked it – nothing but outstanding reviews. Your enthusiasm was infectious (in a good way) and it showed with the tremendous interaction. Your professional animated talk and engaging personality truly highlighted your inner desire to find areas of knowledge that you could pass onto others – helping them become better at what they do. I hold my members in high regard and you continued to foster an environment which makes it all worthwhile. &lt;/i&gt;– Chris Wallace, president Denver User Group&lt;/p&gt;  &lt;p&gt;(BTW, the Denver UG has a special place in my heart because I have been occasionally speaking there for over 15 years)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1820434" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Slides and code for Denver Visual Studio User Group Talk</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/11/27/slides-and-code-for-denver-visual-studio-user-group-talk.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="3404268" href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.01.82.00.19/Getting-Geeky-with-the-.NET-Framework-Posted.zip" /><id>/blogs/kathleen/archive/2012/11/27/slides-and-code-for-denver-visual-studio-user-group-talk.aspx</id><published>2012-11-27T22:25:00Z</published><updated>2012-11-27T22:25:00Z</updated><content type="html">&lt;p&gt;I had a great time last night at the Denver Visual Studio User Group. The crowd was super engaged and on top of the code tricks/surprises I tried to throw at them.&lt;/p&gt;
&lt;p&gt;Thanks again to Chris for his long term leadership of the group!&lt;/p&gt;
&lt;p&gt;Slides and code attached.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1820019" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Why You Should Come to DevIntersection</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/11/18/why-you-should-come-to-devintersection.aspx" /><id>/blogs/kathleen/archive/2012/11/18/why-you-should-come-to-devintersection.aspx</id><published>2012-11-18T17:10:04Z</published><updated>2012-11-18T17:10:04Z</updated><content type="html">&lt;p&gt;&lt;a href="http://www.devintersection.com/?refer=DOLLARD"&gt;DevIntersection&lt;/a&gt; is going to be an awesome conference. It’s right around the corner, so get to work convincing your boss to let you come. Here are just a couple of reasons you should come. &lt;/p&gt;  &lt;p&gt;- You get a Windows 8 Tablet. Yep. That’s right, a Windows 8 Tablet! Register by Nov 20 for that!&lt;/p&gt;  &lt;p&gt;- It’s in Vegas a week that has traditionally low airfares &lt;/p&gt;  &lt;p&gt;- $65 room rates and the MGM Grand, so your overall cost will be relatively low. &lt;/p&gt;  &lt;p&gt;- The MGM has just been renovated, so the facilities should be great.&lt;/p&gt;  &lt;p&gt;- Richard Campbell is the force behind this show, so you know it will be a bit irreverent, casual and absolutely stuffed full of great information&lt;/p&gt;  &lt;p&gt;- There’s an amazing list of speakers&lt;/p&gt;  &lt;p&gt;- Look for a fantastic blend of info direct from Microsoft and some of the best independent speakers to go way beyond the Microsoft party line. &lt;/p&gt;  &lt;p&gt;- Keynotes by the Scott Guthrie, Steve Fox, and the Visual Studio Team&lt;/p&gt;  &lt;p&gt;- It’s your last chance effectively use any leftover training and travel funds in calendar 2012&lt;/p&gt;  &lt;p&gt;- Did I mention that everyone who registers by Nov 20 gets a Windows 8 Tablet?&lt;/p&gt;  &lt;p&gt;Abstracts for the show are under “Sessions” at &lt;a href="http://www.devintersection.com/?refer=DOLLARD"&gt;DevIntersection&lt;/a&gt; . My talks are:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Deeper into Async&lt;/i&gt;&lt;/b&gt; – I’ll explain async in .NET 4.5 and show techniques to integrate timeouts, cancellation and exceptions into your async apps. (&lt;i&gt;There is a mistake in the heading, in 75 minutes, I will focus on single thread async – this is NOT a multi-thread talk, I’ll work to get this fixed)&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Visual Studio 2012 Tips&lt;/i&gt;&lt;/b&gt; – I’ll show you ways to improve your navigation, editing and searching techniques. &lt;/p&gt;  &lt;p&gt;&lt;b&gt;&lt;i&gt;Managed Extensibility Framework in .NET 4.5 &lt;/i&gt;&lt;/b&gt;– I’m really excited to show you the next version of MEF with resolution of open generics, flexible container creation and inference and improved diagnostics. This will start with an introduction to MEF so it’s definitely not just for MEF geeks. &lt;/p&gt;  &lt;p&gt;You should also come to my post conference workshop called &lt;b&gt;&lt;i&gt;Better Coding: Stop Coping, Start Comprehending&lt;/i&gt;&lt;/b&gt;. &lt;/p&gt;  &lt;p&gt;I’m becoming increasingly passionate about people learning or relearning core concepts of the framework. In general, it’s consistent, and if you understand what’s happening under the hood you can predict what it will. You can get your hands on a lot of material on the main libraries. That’s great, but, as I’ve gone around the country doing talks, I see a dropping level of knowledge about the core framework itself – the type system, the languages, the fundamentals of why .NET works the way it does. And I’ve seen this in folks that have been in .NET since the early betas because it’s been a really long time since .NET kicked off. &lt;/p&gt;  &lt;p&gt;There’s the basics - we still need to understand nuances of the heap and stack, overloads, evil static constructors, the multiple meanings of equals, attributes and such things. And there are the things that have evolved our thinking about code – generics, lambda expressions, LINQ and Dependency Injection. And there’s the new stuff – async, simpler parallel processing, code info and event sourcing. Whew! It’ pretty overwhelming unless you have a mental model that aligns with the consistency underlying the framework. This day is absolutely stuffed full of information to make you better at writing .NET code. &lt;/p&gt;  &lt;p&gt;I teach this with a fun unit test “puzzle” format where the audience collaborating to select from multiple commented assert options. I’ll ask you to think as well as listen, and sometimes you’ll get fellow students explanations as well as mine for the critical question of &lt;b&gt;&lt;i&gt;why&lt;/i&gt;&lt;/b&gt; something works the way it does. We might do a skit involving throwing Snickers bars, and I’ll integrate Visual Studio tricks, so when I write code for you, I’ll show you some pretty cool things along the way.&lt;/p&gt;  &lt;p&gt;I hope you’ll sign up for &lt;a href="http://www.devintersection.com/?refer=DOLLARD"&gt;DevIntersection&lt;/a&gt;, get your new Tablet and sign up for my post conference workshop as well!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1819432" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Why is My Pluralsight Course in Visual Studio 2010?</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/11/11/why-is-my-pluralsight-course-in-visual-studio-2010.aspx" /><id>/blogs/kathleen/archive/2012/11/11/why-is-my-pluralsight-course-in-visual-studio-2010.aspx</id><published>2012-11-11T17:48:53Z</published><updated>2012-11-11T17:48:53Z</updated><content type="html">&lt;p&gt;&lt;font size="3"&gt;There were a couple of tweets when my Plurals&lt;sub&gt;&lt;/sub&gt;ight Visual Studio 2010 Tricks released pointing out that Visual Studio 2012 has been released. I actually had noticed the Visual Studio 2012 release. So, why the course in 2010?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;I could give a lot of answers. There are currently people working in both versions and most Visual Studio tricks work in Visual Studio 2012 and such things. But the truth is I massively underestimated the amount of time I’d spend on the course – an order of magnitude in the number of hours. I optimistically anticipated the course would release before 2012. That didn’t work out. So, the more interesting question is why I didn’t start over. The core issues – keystroke shortcuts, columns selection, selection anchors, settings, and a boatload of things I covered are the same for VS 2010 and 2012. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;There have been significant changes in Find and of course there are a boatload of new features. I do talks at conferences and user groups about the new features and I’m totally stoked about the new version. But I think to do the kind of course I did takes a little time. The VS 2010 Tricks course, and the course I hope to do in a few months on VS 2012 aren’t a list of Tip #1, Tip #2, etc. It’s a holistic view of how to smoothly leverage the environment where the rough spots and some of the bugs are and how to work around them. That’s going to take some time to work out. In the meantime, you can get an overview of the new features in Kate Gregory’s course Introduction to Visual Studio 2012. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;Why did the course require so much work? Video was a new format to me, and I thought a lot more of my audio experience would translate to. And I want the course to move very fast. In a tricks course, and probably any skills course, there’s a chunk you already know, a chunk you’re never going to use, and a chunk that make it all worthwhile. I want to get you to whichever nuggets of gold you’re going to find in the course as quickly as possible. And I want to keep you engaged – so I worked to add the occasionally, hopefully humorous moment. I learned an incredible amount. My future videos will be better for what I learned, in the end, it was time to tie it up, imperfections and all, and get it out to you. Hopefully you’ll enjoy it – a clip a day will gradually make you a more efficient coder. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;And I hope you’ll keep an eye out for the next video I do!&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1819062" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term="Visual Studio Tricks" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Visual+Studio+Tricks/default.aspx" /></entry><entry><title>Plain Old Objects and MEF</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/10/11/plain-old-objects-and-mef.aspx" /><id>/blogs/kathleen/archive/2012/10/11/plain-old-objects-and-mef.aspx</id><published>2012-10-11T11:08:00Z</published><updated>2012-10-11T11:08:00Z</updated><content type="html">&lt;p&gt;After my MEF presentation at the &lt;a href="http://www.hrnug.org/Home.aspx"&gt;Hampton Roads .NET User Group&lt;/a&gt; someone asked me about creating objects like customers and invoices via MEF. I gave an overly quick answer to a really good question. &lt;/p&gt;
&lt;p&gt;A lot of the IoC history involves using dependency injection for services. This is great partly because it&amp;#39;s a framework to isolate plain old objects from services, and services from each other. Like many of the techniques we&amp;#39;ve adopted in the agile timeframe, it&amp;#39;s not just what the technique does &lt;b&gt;&lt;i&gt;&lt;span style="text-decoration:underline;"&gt;for&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; us, but what the technique does &lt;b&gt;&lt;i&gt;&lt;span style="text-decoration:underline;"&gt;to&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; us. That&amp;#39;s the quick answer I gave. &lt;/p&gt;
&lt;p&gt;But, we can go further to fully composed systems. Fully composed systems have offered mind boggling benefits in some places they&amp;#39;ve been tried, and they haven&amp;#39;t been tried in very many places yet. This is why I have such a high fascination with &lt;a href="http://1060research.com/netkernel/" title="1060 Research"&gt;NetKernel&lt;/a&gt; and the work people like Randy Kahle (@RandyKahle) and Brian Sletten (@bsletten) are doing. And that work is similar to work Juval Lowy and I have talked about for a number of years. &lt;/p&gt;
&lt;p&gt;However, fully composed systems with MEF, and I assume other DI tools (although I&amp;#39;ll be happy to be proven wrong) are hard. Without the infrastructure of something like NetKernel there&amp;#39;s a fair amount of work to do, and without the caching benefits of NetKernel it&amp;#39;s going to be tough to justify. It&amp;rsquo;s hard because everything needs an interface. Everything. And even if you generate the interfaces and plain objects, the level of infrastructure ceremony gets very unwieldy.. At least that&amp;#39;s my experience from using MEF to wrap everything (yes, everything) in interfaces, in order to create a fully composed MEF 1.0 system. &lt;/p&gt;
&lt;p&gt;We could go a slightly different direction. Put everything into the container, but place plain old objects in the container as their own type, rather than via an interface. Plain old objects in this sense are objects that we can&amp;#39;t imagine a scenario where they&amp;#39;ll be reused and they have a unique, and generally multi-valued interface. A customer or invoice POCO would be examples. &lt;/p&gt;
&lt;p&gt;Placing these objects into the container offers the immediate benefit of guaranteeing their usage is isolated We take advantage of what DI does to us, not just for us.. &lt;/p&gt;
&lt;p&gt;And if we use inference in MEF 2.0 (.NET 4.5), and probably configuration techniques with other IoC containers, we can stick another object in if we have a later reason to do it. &lt;/p&gt;
&lt;p&gt;But here&amp;#39;s where strong typing bites us. Any new class that ever replaces that plain old object (the customer or invoice) has to be assignable to that class. That means it has to be that class or a class that derives from it. I&amp;#39;m still hanging on to the strong typing life boat because I still feel that without it I&amp;#39;m in a North Atlantic storm. For big systems, I think that&amp;#39;s still true, and while I put a lot of thought into making big systems into smaller systems, non-typed based DI is still a jump into icy water for me. &lt;/p&gt;
&lt;p&gt;With the plain object in the container under its own type, if I get blindsided with a requirement that just doesn&amp;#39;t fit I can manage, I just have to write a wrapper for the non-derived object and the wrapper has to derive from the expected type. Ugly, but workable. &lt;/p&gt;
&lt;p&gt;What I want to do is experiment with strongly typed systems with generated interfaces. I&amp;#39;ve already done this with traditional generation, and I want a solution that is cleaner than that. I don&amp;#39;t have the syntax worked out, but imagine that we never create the interface for our plain old object, we just tell the system to do it. The container uses the interface, all using objects request the object by its interface, and we humans can ignore it. &lt;/p&gt;
&lt;p&gt;Until the day the plain old object needs attention. On that day, we make the interface explicit and do whatever we need to do. &lt;/p&gt;
&lt;p&gt;But with the versions of .NET we have today, we can&amp;#39;t build this. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817948" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET/default.aspx" /><category term="Code Generation" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Code+Generation/default.aspx" /><category term="C#" scheme="http://msmvps.com/blogs/kathleen/archive/tags/C_2300_/default.aspx" /><category term="MEF" scheme="http://msmvps.com/blogs/kathleen/archive/tags/MEF/default.aspx" /><category term="Composition" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Composition/default.aspx" /></entry><entry><title>Formatting Replace Output</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/09/15/formatting-replace-output.aspx" /><id>/blogs/kathleen/archive/2012/09/15/formatting-replace-output.aspx</id><published>2012-09-16T00:48:26Z</published><updated>2012-09-16T00:48:26Z</updated><content type="html">&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;This post applies to Visual Studio 2010. I&amp;#39;ll do another post on Visual Studio 2012. &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;I’ll show you how to control the output of Replace in Files. To see where this is going, here’s before and after pictures.&lt;/p&gt;  &lt;p&gt;Here’s the view before the change. Note that I scrolled right to show the end of the line, and if the names of the directories were different lengths, this would not line up at all. This is about the best this will ever look:&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/0763.clip_5F00_image002_5F00_33BB0B65.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image002" border="0" alt="clip_image002" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/2350.clip_5F00_image002_5F00_thumb_5F00_39297C09.jpg" width="471" height="167" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You control the output after the change. Here&amp;#39;s one possiblity:&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/4251.clip_5F00_image004_5F00_63297A31.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image004" border="0" alt="clip_image004" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/8814.clip_5F00_image004_5F00_thumb_5F00_16C1C0C3.jpg" width="474" height="172" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Personal Note: On rare occasions you get to find something that isn’t reported elsewhere, making you feel like you’ve found something no one else in the world knows – although obviously this isn’t a new continent and I’m not the very first person to know how to alter the output of Replace in Files. Still finding something that isn&amp;#39;t documented yet on the web is pretty exciting. &lt;/i&gt;&lt;/p&gt;  &lt;h4&gt;Find Format&lt;/h4&gt;  &lt;p&gt;I love Sara Ford and Zain Naboulsi. They’ve posted boatloads of tips on Visual Studio over the years and they&amp;#39;ve got a great &lt;a href="http://www.amazon.com/Coding-Faster-Getting-Productive-Microsoft/dp/0735649928/ref=sr_1_1?ie=UTF8&amp;amp;qid=1347755112&amp;amp;sr=8-1&amp;amp;keywords=zain+tips+and+tricks+visual+studio"&gt;tips and tricks book&lt;/a&gt;. One of the great features that Sara introduced us to in 2006 is formatting the output of Find in Files – you can find that post &lt;a href="http://saraford.net/2008/11/24/did-you-know-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363/"&gt;here&lt;/a&gt; .&lt;/p&gt;  &lt;p&gt;As Sara explained, the output of the find results window is controlled by a registry key called “Find result format.” It’s a rather arcane syntax that creates a string output for each line, you can’t control the output by columns except with tabs, but you can create much more usable output than the default. I’ll let you check out Sara’s article for details. &lt;/p&gt;  &lt;h4&gt;Replace in Files&lt;/h4&gt;  &lt;p&gt;The Visual Studio Replace in Files feature is cool – you can control the scope of the replacement better than Quick Replace, you can control whether files are left open, and you get a list of all the changes made. That list of changes is a great feature. It’s so great that you might even want to use it if you are just making replacements in a single file.&lt;/p&gt;  &lt;p&gt;You’ll find Replace in Files if you drop down the Replace combo box at the top of the Find dialog. You can select al of the standard scopes, as well as selecting specific folders by right clicking the three dots to the right of the combo box. &lt;/p&gt;  &lt;p&gt;When you select Fnd All, Visual Studio lists of the changes that were made, in the Find Results window. If you don’t like the changes, and you left files open, you can undo all the changes with a single Ctl Z.&lt;/p&gt;  &lt;h4&gt;Replace Output Format&lt;/h4&gt;  &lt;p&gt;I was really disappointed that the Find result format did not affect the output of Replace in Files. The oversight surprised me, so I decided to take a shot at creating a registry key named &amp;quot;Replace result format.&amp;quot; I wasn&amp;#39;t optimistic, but voila&amp;#39; it worked!!!&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Note: You can screw up Visual Studio, or even your computer if you mess up your registry. Be careful out there. &lt;/i&gt;&lt;/p&gt;  &lt;p&gt;To make this change, open RegEdit and find the key &lt;/p&gt;  &lt;p&gt;HKEY_CURRENT_USER/Software/Microsoft/VisualStudio/10.0/Find&lt;/p&gt;  &lt;p&gt;Add a string value named &amp;quot;Replace results format&amp;quot; (no quotes), modify, and add your preferred format. &lt;/p&gt;  &lt;p&gt;Here’s a summary of the important format options for Find. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/7245.clip_5F00_image006_5F00_4A89B714.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image006" border="0" alt="clip_image006" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/6710.clip_5F00_image006_5F00_thumb_5F00_779EA3E2.jpg" width="204" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;All these format options work in Replace as well. In Replace, and there are some additional options that don&amp;#39;t make much sense in Find. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/5141.clip_5F00_image008_5F00_0FC20E3E.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image008" border="0" alt="clip_image008" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/5078.clip_5F00_image008_5F00_thumb_5F00_0EE9A854.jpg" width="236" height="196" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In Sara’s post, she refers to $t, $T, and $s as matched values. This probably seems picky, but for clarity I want to point out that it&amp;#39;s not the matched value, but the replaced value that&amp;#39;s displayed. Obviously for the Find result format key it does not matter, but for the Replace result key there are different. You actually can’t get the matched values, which is an incredible shame. &lt;/p&gt;  &lt;h4&gt;My Favorite Formats&lt;/h4&gt;  &lt;p&gt;$l\t$c\t$f$e:\t$s\r\n is line, column, file with extension and first line of replacement&lt;/p&gt;  &lt;p&gt;:&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/5444.clip_5F00_image009_5F00_193ACCB4.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image009" border="0" alt="clip_image009" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/6052.clip_5F00_image009_5F00_thumb_5F00_77DB2717.jpg" width="499" height="181" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;$l\t$c\t$f$e:\t$0\t$s\r\n is line, column, file with extension, replaced value and first line of replacement&lt;/p&gt;  &lt;p&gt;:&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/1207.clip_5F00_image011_5F00_75BE284E.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image011" border="0" alt="clip_image011" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/2211.clip_5F00_image011_5F00_thumb_5F00_4934F868.jpg" width="510" height="181" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;$l\t$c\t($g)\t$f$e:\t$0\t$s\r\n is line, column, replacement length, file with extension, replacement value and first line of replacement:&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/3247.clip_5F00_image013_5F00_32FEDD16.jpg"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="clip_image013" border="0" alt="clip_image013" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/kathleen.metablogapi/5756.clip_5F00_image013_5F00_thumb_5F00_71842ABC.jpg" width="513" height="182" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Enjoy creating custom formats for Replace in Files as well as Find in Files!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816354" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Breaking into the Visual Studio .SOU File</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/08/21/breaking-into-the-visual-studio-sou-file.aspx" /><id>/blogs/kathleen/archive/2012/08/21/breaking-into-the-visual-studio-sou-file.aspx</id><published>2012-08-21T17:22:34Z</published><updated>2012-08-21T17:22:34Z</updated><content type="html">&lt;p&gt;I’ll probably need to do this again one day, so I want to record how I did it…and it might help someone…&lt;/p&gt;  &lt;p&gt;I wanted to check whether an absolute or relative file path was saved for a particular thing in the .SOU file. But, Notepad displays garbage when you force it to open a .SOU file. &lt;/p&gt;  &lt;p&gt;Instead I opened &lt;i&gt;another &lt;/i&gt;copy of Visual Studio 2010 (not a copy where this solution was open, tried that, it didn’t work). I created a new solution folder, and dragged the .SOU file into it. &lt;/p&gt;  &lt;p&gt;I could not drag it onto the document surface, because someplace along the way I picked up a file association with Notepad – so Visual Studio was just one more mechanism to do the useless.&lt;/p&gt;  &lt;p&gt;I selected Open With from the Right Click context menu and selected the binary editor.&lt;/p&gt;  &lt;p&gt;Find did not work for me. I can think of a few possible reasons. &lt;/p&gt;  &lt;p&gt;So, I selected from the first readable text in the binary editor to somewhere near the last readable text and did a normal Ctl-C copy. In other words, I used the binary editor to chop off the beginning and end of the file, and to put something sufficiently useful into the clipboard buffer. Notepad cooperated in displaying the text retrieved from the clipboard buffer with a normal Ctl-V paste. &lt;/p&gt;  &lt;p&gt;This file is still a mess, not usable for any normal exploration. However, I could confirm that the file name I was interested in was only stored in absolute, not relative form.&lt;/p&gt;  &lt;p&gt;Microsoft, please, pretty, pretty, please, pretty, pretty, pretty, pretty, pretty please can we get readable formats for .sou and .user files?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1815344" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>To “as” or not to “as”</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/08/12/to-as-or-not-to-as.aspx" /><id>/blogs/kathleen/archive/2012/08/12/to-as-or-not-to-as.aspx</id><published>2012-08-12T18:37:00Z</published><updated>2012-08-12T18:37:00Z</updated><content type="html">&lt;p&gt;&lt;a href="http://msmvps.com/controlpanel/blogs/posteditor.aspx/Stupid&amp;rsquo;%20Question%2020:%20How%20should%20I%20do%20casting%20in%20C#?%20Should%20I%20use%20the%20prefix%20cast%20or%20the%20as-cast?"&gt;Iris Classon&lt;/a&gt; is asking and finding answers for &amp;ldquo;stupid&amp;rdquo; questions on her blog. First of all, they are definitely not stupid questions. There are a lot of nuances of .NET that slip out of our daily thinking. When I first started my Getting Geeky with the .NET Framework series I&amp;rsquo;d ask really hot coders basic questions &amp;ndash; things that affect how code runs &amp;ndash; and the results were not stellar. So, first, three cheers for Iris&amp;rsquo;s project. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://msmvps.com/controlpanel/blogs/posteditor.aspx/Stupid&amp;rsquo;%20Question%2020:%20How%20should%20I%20do%20casting%20in%20C#?%20Should%20I%20use%20the%20prefix%20cast%20or%20the%20as-cast?"&gt;Today&amp;rsquo;s question&lt;/a&gt; was &amp;ldquo;How should I do casting in C#? Should I use the prefix cast or the as-cast?&amp;rdquo; She&amp;rsquo;s got some good input that I suggest you read first. I also felt that the discussion left out a significant factor - debugging. &lt;/p&gt;
&lt;p&gt;If the value resulting from the cast really should not be null, the code becomes unstable or incorrect at the point of the cast. Period. With the prefix cast, application state clearly becomes incorrect at that point because an exception occurs. With the &amp;ldquo;as&amp;rdquo; cast, the application state still becomes incorrect at that point, you just don&amp;rsquo;t know it. If the value should not be null, you&amp;rsquo;ll get a null exception, or possibly failure of a Requires clause if you&amp;rsquo;re using code contracts somewhere, sometime later in application execution. &lt;/p&gt;
&lt;p&gt;One of the things that makes hard bugs hard is when there is a disconnect in time or space between the cause and the symptom. Time is time, space is lines of code, assembly placement, etc. Code can be written to minimize these disconnects. One of the ways to do that is to fail quickly. When application state becomes incorrect, yell about it immediately and rarely continue with the application in an invalid state. A null-reference exception at an unexpected time just makes code more difficult to debug.&lt;/p&gt;
&lt;p&gt;Eric Lippert&amp;rsquo;s quote short-cutted the idea of what happens next. He&amp;rsquo;s quoted as saying that a prefixing cast failure requests, &amp;ldquo;then please crash the program.&amp;rdquo; That would be much better put as &amp;ldquo;then please do not continue the current operation.&amp;rdquo; Our programs need never crash in the sense of blue screen ugly death. Exception handling is a mechanism for recovering to a valid state, with the capacity to communicate failure to interested parties like the user and system logs. &lt;/p&gt;
&lt;p&gt;So, use the &amp;ldquo;as&amp;rdquo; cast only when the resulting null does not make the application state incorrect, or you have an immediate and adjacent test that you prefer to make the application state correct or perform different exception management. For example, you might want to add a specific error message if the invalid cast indicates a particular type of problem.&lt;/p&gt;
&lt;p&gt;I think the prefixing cast should be the &amp;ldquo;go to&amp;rdquo; cast for .NET &amp;ndash; the one you use when you haven&amp;rsquo;t thought through the implications of the null value to the remainder of your program. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1815042" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET/default.aspx" /><category term="Visual Basic" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Visual+Basic/default.aspx" /><category term="C#" scheme="http://msmvps.com/blogs/kathleen/archive/tags/C_2300_/default.aspx" /></entry><entry><title>Build/DevConnections Scheduling Conflict</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/08/01/build-devconnections-scheduling-conflict.aspx" /><id>/blogs/kathleen/archive/2012/08/01/build-devconnections-scheduling-conflict.aspx</id><published>2012-08-01T16:36:24Z</published><updated>2012-08-01T16:36:24Z</updated><content type="html">&lt;p&gt;Since Microsoft scheduled Build on top of DevConnections, I’ve had people ask which conference they should go to. I’ll start by admitting my bias. I haven’t missed speaking at a major DevConnections show for six or seven years, and if you come to DevConnections, you can come see my talks! &lt;/p&gt;  &lt;p&gt;But biased or not, I think the DevConnections/Build decision is a no-brainer…they are very different events. This is a quick list off the top of my head with no discussion with any marketing people at either event. &lt;/p&gt;  &lt;p&gt;- Based on history, the Build content will have good technical content, but be planned for Microsoft’s marketing convenience&lt;/p&gt;  &lt;p&gt;- Build will focus on future products&lt;/p&gt;  &lt;p&gt;- Build talks and speaker list may not be public until the last minute&lt;/p&gt;  &lt;p&gt;- Build speakers will be from Microsoft and might be constrained in what they can say&lt;/p&gt;  &lt;p&gt;- Build sessions will probably be recorded so you can see them in the future&lt;/p&gt;  &lt;p&gt;- Build may help you make human connections inside Microsoft to get your opinions heard&lt;/p&gt;  &lt;p&gt;- Build will probably sell out in minutes, possibly seconds&lt;/p&gt;  &lt;p&gt;- Build attendees might get cool hardware – maybe a new Surface&lt;/p&gt;  &lt;p&gt;- DevConnections will include a Microsoft day, presumably with future focus, that day may be driven by the same marketing as Build&lt;/p&gt;  &lt;p&gt;- DevConnections will feature many high level Microsoft speakers, including Scott Guthrie&lt;/p&gt;  &lt;p&gt;- DevConnections has two days of independent content with a long track record of healthy skepticism of Microsoft stuff &lt;/p&gt;  &lt;p&gt;- DevConnections speaker and abstract lists (day 2 and 3) are public right now&lt;/p&gt;  &lt;p&gt;- DevConnections speakers (day 2 and 3) are independent industry experts, I’m humbled to be in such company&lt;/p&gt;  &lt;p&gt;- DevConnections is focused on what devs need today and tomorrow, not next year&lt;/p&gt;  &lt;p&gt;- DevConnections has an extremely wide array of topics with seven concurrent conferences – you have access to all&lt;/p&gt;  &lt;p&gt;- DevConnections makes a lot of sense for teams that need to bring several members and have them learning different things (data, web and core, for example)&lt;/p&gt;  &lt;p&gt;- DevConnections features pre and post conference workshops (for additional fee)&lt;/p&gt;  &lt;p&gt;- DevConnections is larger with more opportunity to network with real devs and won’t sell out anytime soon&lt;/p&gt;  &lt;p&gt;- DevConnections talks are not recorded – you’ve got to be there (all slide decks are available to all attendees)&lt;/p&gt;  &lt;p&gt;- DevConnections has amazing independent speakers that are the best in their field and focus on communicating complex ideas – Kimberly Tripp, Juval Lowy, Ward Bell, Dino Esposito, Julie Lerman, and Mark Minasi represent incredible breadth, and are just the tip of the iceberg – really, go look at the speaker list (you have to look separately for each co-located conference)&lt;/p&gt;  &lt;p&gt;- I hate Las Vegas, but the weather is better than Seattle in November&lt;/p&gt;  &lt;p&gt;- The Bellagio is nice and if you can’t get your company to spring for it, you can get a deal at many hotels with relatively easy access&lt;/p&gt;  &lt;p&gt;- Las Vegas is one of the easiest places to fly to from anywhere (except Fairbanks) and you can lose all your spending money before you even leave the airport&lt;/p&gt;  &lt;p&gt;- OK, the taxi queues are definitely better in Seattle, but the venue is closer and access easier in Las Vegas&lt;/p&gt;  &lt;p&gt;If you think I’ve missed something for either event, let me know. I’ll try to approve comments quickly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1814527" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>High Park Fire</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/07/31/high-park-fire.aspx" /><id>/blogs/kathleen/archive/2012/07/31/high-park-fire.aspx</id><published>2012-07-31T15:06:18Z</published><updated>2012-07-31T15:06:18Z</updated><content type="html">&lt;p&gt;I haven’t been able to follow up on the fire, because it’s been too hard to catch it.&lt;/p&gt;  &lt;p&gt;From my near hysteria on the phone with a friend the first day when I was watching the plume and knowing my sister would be out there with it. To the shock of seeing the fire walking down the hill to my Colorado home. To what it means to be evacuated. To listening in on emergency services to hear Carol’s voice and know she was OK. To hearing the radio traffic as Poudre Fire Authority fought for Don’s. To be guessing what “happy dance” meant. To know that there were so many houses that were still in danger ten days in. To the pop, pop, pop of people I knew in so many different ways… Louise lost her house, Mark lost his house, Larry lost his house and shop, Joe lost his house and his entire horse set up. To hearing that my best friend lost her house. To coming home to ash and the black and the fire line right there next to the house. To the map where the east fire line jogs west just north of CO 14. That’s the driveway, that’s where the fire goes around the house. To knowing there are people going home to the middle of the ash. To the driving east with my son on a prescheduled trip two weeks in and someplace in Kansas finally not seeing smoke. &lt;/p&gt;  &lt;p&gt;I can’t explain all that. Someone helped my sister tell the bigger story, the real heroes. &lt;a href="http://www.youtube.com/watch?v=Mo3cTkIXk8o&amp;amp;feature=youtu.be"&gt;Watch it.&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;This isn’t over. This is the beginning. There are houses and lives to rebuild. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1814163" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Lifting ForEach, Breaking Change in Visual Studio 2012</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/07/03/lifting-foreach-breaking-change-in-visual-studio-2012.aspx" /><id>/blogs/kathleen/archive/2012/07/03/lifting-foreach-breaking-change-in-visual-studio-2012.aspx</id><published>2012-07-03T15:15:00Z</published><updated>2012-07-03T15:15:00Z</updated><content type="html">&lt;p&gt;&lt;em&gt;This post is updated due to the STUPID error I originally made in the last code sample. Thanks to the folks that pointed it out!&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Also, I neglected to thank &lt;a href="http://www.adilmughal.com/" title="Adil Mughal&amp;#39;s blog"&gt;Adil Mughal&lt;/a&gt; for grabbing the ReSharper warnng text for me. &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a breaking change you should know about in Visual Studio 2012. In case you have a short attention span, aka have a life, I&amp;rsquo;ll give you the punch line first. The behavior of closures has changed in the specific instance of a lambda expression.&lt;/p&gt;
&lt;p&gt;Good news: You aren&amp;rsquo;t writing the affected code on purpose, or if you are I honestly want to know why&lt;/p&gt;
&lt;p&gt;Bad news: I don&amp;rsquo;t think anyone can guarantee their code doesn&amp;rsquo;t contain the issue&lt;/p&gt;
&lt;p&gt;Good news: It&amp;rsquo;s a side case, the affected code probably isn&amp;rsquo;t there&lt;/p&gt;
&lt;p&gt;Bad news: If it is in your program, its behavior will change when compiled with VS 2012&lt;/p&gt;
&lt;p&gt;Good news: It probably won&amp;rsquo;t be too bad if the behavior changes&lt;/p&gt;
&lt;p&gt;Bad news: The change symptom might be obtuse or bizarre&lt;/p&gt;
&lt;p&gt;Good news: If you use VB or ReSharper there&amp;rsquo;s a warning and you just need to look for it&lt;/p&gt;
&lt;p&gt;Bad news: If you&amp;rsquo;re in C# there&amp;rsquo;s no warning&lt;/p&gt;
&lt;p&gt;Good news: You can download ReSharper&amp;rsquo;s 30 day free trial and run it against all of your code in 30 days (yes, I asked before posting this suggestion)&lt;/p&gt;
&lt;h4&gt;Observe the Change&lt;/h4&gt;
&lt;p&gt;Run this code in a console application in Visual Studio 2010. You might want to predict the result before continuing with the blog post:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:48b0ccd6-e90c-4908-899d-22e51762542f" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Program&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClosuresForEachWithLambda();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.Read();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ClosuresForEachWithLambda()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; actions = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Action&lt;/span&gt;&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; list = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; list)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ actions.Add(() =&amp;gt; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(i)); }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; actions)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ i(); }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Or the identical code for Visual Basic&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f75cd0e8-ba96-4c0d-97c6-25711f0500d3" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;Option Strict On&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;Module&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Main&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; Main()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ClosuresForEachWithLambda()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.Read()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; ClosuresForEachWithLambda()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; actions = &lt;span style="color:#0000ff;"&gt;New&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;Of&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Action&lt;/span&gt;)()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; list = &lt;span style="color:#0000ff;"&gt;New&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Int16&lt;/span&gt;() {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;For&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Each&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;In&lt;/span&gt; list&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;actions.Add(&lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt;() &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(i))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;For&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Each&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;In&lt;/span&gt; actions&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Module&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;The Answer and the Explanation&lt;/h4&gt;
&lt;p&gt;While you might expect this code to print 0,1,2,3, etc, it actually prints 9,9,9,9, etc.&lt;/p&gt;
&lt;p&gt;When variables are used in a lambda expression, the actual variable goes along for the ride. Not a copy, not the value but the actual variable. This is called a closure and is essential to you getting the behavior you expect at many other points in .NET. You can also find examples in this&lt;a href="http://weblogs.asp.net/fbouma/archive/2009/06/25/linq-beware-of-the-access-to-modified-closure-demon.aspx"&gt; blog entry by Frans Bouma&lt;/a&gt; and a &lt;a href="http://confluence.jetbrains.net/display/ReSharper/Access+to+modified+closure"&gt;different example by Dmitri Nesteruk&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;This is a significant enough issue that both Visual Basic and ReSharper issue a warning. C# without ReSharper does not issue a warningThe Visual Basic warning is 
&lt;table cellpadding="0" cellspacing="0" border="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="67" valign="top"&gt;
&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Warning&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="30" valign="top"&gt;
&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;1&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;td width="541" valign="top"&gt;
&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Using the iteration variable in a lambda expression may have unexpected results. Instead, create a local variable within the loop and assign it the value of the iteration variable.&lt;/span&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;The ReSharper warning is&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:Courier New;"&gt;Access to modified closure&lt;/span&gt;&lt;/p&gt;
&lt;h4&gt;The Visual Studio 2012 Change&lt;/h4&gt;
&lt;p&gt;When a lambda expression uses the looping variable of a for each loop in either Visual Basic or C#, the Visual Studio 2012 compiler creates a new variable scoped to the loop and assigns the value of the looping variable to this variable. Logically it&amp;rsquo;s the same as:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3509b15f-0487-4d1d-b529-876b39572777" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ClosuresForEachWithLambda()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; actions = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Action&lt;/span&gt;&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; list = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; list)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// Changes are here&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; x = i;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;actions.Add(() =&amp;gt; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(x));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#008000;"&gt;// End changes&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; i &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; actions)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ i(); }&lt;br /&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since the new variable is scoped to the loop, there&amp;rsquo;s a new copy for every iteration of the loop. The original code compiled in Visual Studio 2012 prints 0,1,2,3&amp;hellip; Try it!&lt;/p&gt;
&lt;h4&gt;Why this is a Really Good Thing to Change&lt;/h4&gt;
&lt;p&gt;I&amp;rsquo;ve been showing this code at user group presentations around the country and taken a few other opportunities to put this code in front of .NET developers - some of them really good .NET developers - and asking what the code would do. &lt;/p&gt;
&lt;p&gt;The most common response is a few people in the room get it after about a minute. Sometimes, no one gets it. It&amp;rsquo;s exceedingly rare that anyone will have an immediate knee jerk response that it will print all nines. I get boatloads of &amp;ldquo;I should have seen that!&amp;rdquo; and very few &amp;ldquo;I saw it right away!&amp;rdquo; And, the very fact I am asking the question creates a context that the code probably doesn&amp;rsquo;t do what you&amp;rsquo;d expect and I made it as obvious as I possibly could. Your code is going to be a list of customers or invoices or something else. The vast majority of .NET developers do not expect the VS 2010 result, even though it is technically correct. &lt;/p&gt;
&lt;p&gt;The async features of Visual Studio 2012 will create lambda expressions for you, and you will be much more likely to create lists of lambda expressions for simultaneous execution. Your ability to see this issue in your code gets significantly tougher in some VS 2012 scenarios. It was time to make this change. &lt;/p&gt;
&lt;p&gt;It would have been nice if this had been an error from the beginning of lambda usage in .NET. But that didn&amp;rsquo;t happen and adding this as an error would have been a different kind of breaking change. For better or worse, the automatic fix won over adding an error or warning. &lt;/p&gt;
&lt;h4&gt;Is it a big deal? &lt;/h4&gt;
&lt;p&gt;I get asked a lot whether this is a big deal &amp;ndash; sometimes even by people that are responsible for a code base. &lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s &lt;i&gt;probably&lt;/i&gt; not a big deal in your code. The chances are excellent that you do not have code that uses a looping variable in a lambda expression. If you do, it&amp;rsquo;s probably a mistake &amp;ndash; that&amp;rsquo;s why VB and ReSharper issue a warning. And it&amp;rsquo;s possible that any change in behavior will either be immensely obvious and perhaps trigger a test failure, or be so subtle that it never breaks your code at all. &lt;/p&gt;
&lt;p&gt;But these are the wrong question to ask about a breaking change. The right question is &amp;ldquo;Can you guarantee that this does not exist anywhere in the code bases you are responsible for?&amp;rdquo; That&amp;rsquo;s the bar for a breaking change &amp;ndash; can I guarantee I know how it affects me. The only way to do that is to run a tool that looks for the problem &amp;ndash; check for the Visual Basic warning or run ReSharper. &lt;/p&gt;
&lt;p&gt;I have had only one person say they were extremely confident that their unit tests would catch this change. I believe they are wrong. This is a side case that can give extremely unexpected behavior. It&amp;rsquo;s not a change I&amp;rsquo;d trust unit tests to find. &lt;/p&gt;
&lt;h4&gt;What&amp;rsquo;s Not Changed&lt;/h4&gt;
&lt;p&gt;This change happened because it can be very difficult to see the issue in a &lt;i&gt;for each&lt;/i&gt; loop. It wasn&amp;rsquo;t done lightly and the teams decided to do the change in as narrow a scope as possible. That means the change was &lt;b&gt;not&lt;/b&gt; made to &lt;i&gt;for &lt;/i&gt;loops in either Visual Basic or C#. The following code returns 10,10,10, etc with both the VS 2012 and VS 2010 compilers. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a2d44141-5f10-4c7b-997f-1bd7147ea7f2" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ClosuresForWithLambda()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; x = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;Action&lt;/span&gt;&amp;gt;();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; 10; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ x.Add(() =&amp;gt; &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(i)); }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; j &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; x)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{ j(); }&lt;br /&gt;}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Or for VB&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:beadf633-9fd1-4d64-af4a-b48ae093bddb" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="color:#0000ff;"&gt;Public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt; ClosuresForWithLambda()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Dim&lt;/span&gt; x = &lt;span style="color:#0000ff;"&gt;New&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;Of&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Action&lt;/span&gt;)()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;For&lt;/span&gt; i = 0 &lt;span style="color:#0000ff;"&gt;To&lt;/span&gt; 9&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x.Add(&lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt;() &lt;span style="color:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(i))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;For&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Each&lt;/span&gt; j &lt;span style="color:#0000ff;"&gt;In&lt;/span&gt; x&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;j()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;Next&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="color:#0000ff;"&gt;End&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;Sub&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;The Critical Footnote&lt;/h4&gt;
&lt;p&gt;Any breaking compiler changes are a big deal. They aren&amp;rsquo;t such a big deal if we know about them, they are side cases and the new behavior is improved. The Visual Studio teams have announced that they are working to replace the compilers in a future version of Visual Studio. The current compilers are old and it seems highly unlikely that they can be rewritten without breaking changes. We can handle some breaking changes as long as the issues can be found with tools &amp;ndash; specifically we can identify code that is clean of known behavior changes because of compiler changes. One of the reasons I want the community talking about this breaking change is that we need to establish expectations for all future breaking changes. So, talk about it. Run ReSharper. Tell your friends.!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1812221" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term=".NET" scheme="http://msmvps.com/blogs/kathleen/archive/tags/.NET/default.aspx" /><category term="Visual Studio 2012" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Visual+Studio+2012/default.aspx" /></entry><entry><title>INotifyPropertyChanged Implementation for VS2012</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/06/30/inotifypropertychanged-implementation-for-vs2012.aspx" /><id>/blogs/kathleen/archive/2012/06/30/inotifypropertychanged-implementation-for-vs2012.aspx</id><published>2012-06-30T21:57:00Z</published><updated>2012-06-30T21:57:00Z</updated><content type="html">&lt;p&gt;I told some folks at the East Tennessee .NET UG (ETNUG, which was adorably put on the reservation board at the after meeting bar as &amp;ldquo;Eatnug&amp;rdquo;) meeting in Knoxville that I would post info on a .NET 4.5 version of INotifyPropertyChanged that used CallerMemberName. I also said I wanted to reference other people rather than making up on my own because I&amp;rsquo;d rather post something already vetted. &lt;/p&gt;
&lt;p&gt;CallerMemberName is a new feature of .NET 4.5 that lets you access the name of the thing that called the current method. It&amp;rsquo;s implemented by adding an attribute on an optional parameter:&lt;/p&gt;
&lt;p&gt;public void Foo([CallerMemberName] string callerMemberName = null) &lt;/p&gt;
&lt;p&gt;The CallerMemberName attribute signals that the caller parameter should contain the name of the calling method, to be filled in automatically if the calling code doesn&amp;rsquo;t pass a value. Since it&amp;rsquo;s an optional value, the calling code doesn&amp;rsquo;t need to pass a value, and should only pass one when chaining the &amp;ldquo;real&amp;rdquo; caller member name. Unfortunately, Intellisense doesn&amp;rsquo;t help you out here, so a really good parameter name, consistent across your project or organization is a great idea: I like &lt;i&gt;callerMemberName &lt;/i&gt;as a direct indicator of the purpose/usage of the parameter. &lt;/p&gt;
&lt;p&gt;There are a couple of obvious places to use CallerMemberName &amp;ndash; logging and implementing INotifyPropertyChanged.&lt;/p&gt;
&lt;p&gt;I asked on Twitter and checked around the Internet, and there are a bunch of simple examples that illustrate CallerMemberName. Here&amp;rsquo;s one in &lt;a href="http://jesseliberty.com/2012/06/28/c-5making-inotifypropertychanged-easier/"&gt;English&lt;/a&gt;, and one in &lt;a href="http://balassygyorgy.wordpress.com/2012/03/01/csharp5-caller-info-attributes-es-inotifypropertychanged/"&gt;Hungarian&lt;/a&gt;. There&amp;rsquo;s also a version in the documentation for the INotifyProertyChanged interface. If you&amp;rsquo;re interested in how CallerMemberName works, check these out. &lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re interested in a bang-up, super-great, sea-salt and malt vinegar (potato chip) version, check out Dan Rigby&amp;rsquo;s blog posts &lt;a href="http://danrigby.com/2012/01/08/inotifypropertychanged-the-anders-hejlsberg-way/"&gt;here&lt;/a&gt; and &lt;a href="http://danrigby.com/2012/04/01/inotifypropertychanged-the-net-4-5-way-revisited/"&gt;especially here&lt;/a&gt; where he evaluates versions of INotifyPropertyChanged that have been used elsewhere. The basics are that the Set method should contain exactly one method call, the event should not be raised unless the property is actually changed to a new value, no strings should be used to avoid typo bugs, and no reflection or callstack access should be used to maintain performance. &lt;/p&gt;
&lt;p&gt;I really like the flow of information on the Internet when people find something good and add to it. I have two enhancements I want to add &amp;ndash; I hate having SetProperty in every class and I didn&amp;rsquo;t find a VB version. &lt;/p&gt;
&lt;p&gt;First, you can use a common base class to avoid redundant SetProperty methods. This simplifies the data class. Note that it&amp;rsquo;s common to supply a protected OnPropertyChanged method in a base class. If this is called from something other than the property, such as the SetProperty method, the CallerMemberName can be passed in, passing on or chaining the original property name:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8506ada-8749-43a3-a034-5bb354bcd54c" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;Foo&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;FooBase&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; _bar;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; Bar&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; _bar; }&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; { SetProperty(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;ref&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; _bar, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;value&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;); }&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;abstract&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;FooBase&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;event&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;PropertyChangedEventHandler&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; PropertyChanged;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;protected&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;bool&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; SetProperty&amp;lt;T&amp;gt;(&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;ref&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; T storage, T value, &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;CallerMemberName&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;] &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;String&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; callerMemberName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; (&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;.Equals(storage, value)) &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;false&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;storage = value;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;.OnPropertyChanged(callerMemberName);&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;protected&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; OnPropertyChanged(&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;CallerMemberName&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;] &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; callerMemberName = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; eventHandler = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;.PropertyChanged;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; (eventHandler != &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;eventHandler(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;this&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;, &lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;PropertyChangedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;(callerMemberName));&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;Since I didn&amp;rsquo;t find this available in VB, I translated: &lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:efc81025-6fa8-4e86-8ae1-3a222a739cf6" style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;"&gt;
&lt;div class="le-pavsc-container"&gt;
&lt;div style="background-color:#ffffff;max-height:300px;overflow:auto;padding:2px 5px;white-space:nowrap;"&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;Foo&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Inherits&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;FooBase&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Private&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; _bar &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Integer&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Property&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; Bar &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Integer&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; _bar&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Get&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;(value &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Integer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;SetProperty(_bar, value)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Set&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Property&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;FooBase&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Implements&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Event&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; PropertyChanged(sender &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;, e &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;PropertyChangedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;) _&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Implements&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;INotifyPropertyChanged&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;.PropertyChanged&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Protected&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; SetProperty(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Of&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;T&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;ByRef&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; field &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;T&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;, value &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;T&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;,&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;CallerMemberName&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;&amp;gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Optional&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; callerMemberName &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;String&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Nothing&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;) _&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Boolean&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;If&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Object&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;.Equals(field, value) &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Then&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;False&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;OnPropertyChanged(callerMemberName)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;field = value&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;True&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Function&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Protected&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Sub&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; OnPropertyChanged(&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;CallerMemberName&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;&amp;gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Optional&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; callerMemberName &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;As&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;String&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Nothing&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;RaiseEvent&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; PropertyChanged(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Me&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;, &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;New&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af;"&gt;PropertyChangedEventArgs&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt;(callerMemberName))&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background:#ffffff;color:#000000;"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Sub&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;End&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000;"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff;"&gt;Class&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1812081" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term="Visual Studio 2012" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Visual+Studio+2012/default.aspx" /></entry><entry><title>Colorado Springs Slides</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/06/15/colorado-springs-slides.aspx" /><link rel="enclosure" type="application/pdf" length="393859" href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.01.81.11.61/Dollard-Visual-Studio-Tips.pdf" /><id>/blogs/kathleen/archive/2012/06/15/colorado-springs-slides.aspx</id><published>2012-06-15T20:01:00Z</published><updated>2012-06-15T20:01:00Z</updated><content type="html">&lt;p&gt;Here are the slides from my Colorado Springs talk - Visual Studio Tips and Tricks. &lt;/p&gt;
&lt;p&gt;(Please visit the site to view this media)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1811161" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>TaskCancelledException vs OperationCancelledException</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/05/25/taskcancelledexception-vs-operationcancelledexception.aspx" /><id>/blogs/kathleen/archive/2012/05/25/taskcancelledexception-vs-operationcancelledexception.aspx</id><published>2012-05-25T21:25:40Z</published><updated>2012-05-25T21:25:40Z</updated><content type="html">&lt;p&gt;I had a conversation with Stephen Toub, Peter Ritchie and Kevin Hazzard about the different between the TaskCancelledException and the OperationCancelledException. It turns out not to be a big difference, but some understanding might keep you out of a bit of trouble. &lt;/p&gt;  &lt;p&gt;TaskCancelledException derives from OperationCancelledException. TaskCancelledException contains a property for the cancelled task. &lt;/p&gt;  &lt;p&gt;If you’re catching exceptions, you probably want to catch both exceptions. If you don’t care about the task, you can do this by just catching the OperationCancelledException since the TaskCancelledException derives from it. Or you can catch them both in order if you use the task in your exception response. Catching only the TaskCancelledException will not work in all cases, since it won’t catch OperationCancelledException. &lt;/p&gt;  &lt;p&gt;If you’re throwing an exception, and there’s a task available, throw TaskCanceledException. If there isn’t a task available, throw an OperationCancelledException. This is reflected in the framework when the CancellationToken’s ThrowIfCancellationRequested method throws an OperationCancelledException. &lt;/p&gt;  &lt;p&gt;If you’re manually throwing cancellation exceptions, check that you aren’t repeating things already handled well by the .NET framework. CancellationTokenSource and CancellationToken may take a little getting used to, but this mechanism provides a predictable approach that handles some tricky threading side cases that will ultimately make your code simpler and easier to understand. &lt;/p&gt;  &lt;p&gt;Throwing exceptions to communicate cancellation steps slightly outside usual exception guidelines. Exceptions are intended for exceptional circumstances, and cancellation is arguably not an exceptional occurrence. But, one of the things exceptions do is abort further processing and fail to return a value. Clearly this should happen on cancellation. I think the tradeoff is worthwhile because treating cancellations as exceptions significantly simplifies your code and avoids bogus return values after cancellation. &lt;/p&gt;  &lt;p&gt;One of the reasons exceptions are bad for implementing control flow outside exceptional circumstances is that there must be no confusion about the exceptions that are thrown. Let’s avoid confusion J&lt;/p&gt;  &lt;p&gt;- Catch OperationCancelledException, and possibly also TaskCancelledException&lt;/p&gt;  &lt;p&gt;- Throw TaskCancelledException when you have a task to pass, otherwise OperationCancelledException&lt;/p&gt;  &lt;p&gt;Thanks to Stephen, Peter and Kevin - I’m a bit smarter than I was a few hours ago. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1810308" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author></entry><entry><title>Roslyn</title><link rel="alternate" type="text/html" href="/blogs/kathleen/archive/2012/04/18/roslyn.aspx" /><id>/blogs/kathleen/archive/2012/04/18/roslyn.aspx</id><published>2012-04-18T14:43:00Z</published><updated>2012-04-18T14:43:00Z</updated><content type="html">&lt;p&gt;I believe project Roslyn is a watershed moment. It will start a complete redefinition of what programming and being a computer programmer means. &lt;/p&gt;
&lt;p&gt;But why? How could rewriting the Visual Basic and C# compilers be even a blip in the history of computer programming? At best it&amp;rsquo;s a sneeze!&lt;/p&gt;
&lt;p&gt;Show me a computer program. Right now. Really. At least think through how you would show me. &lt;/p&gt;
&lt;p&gt;OK, you just opened up an instance of Visual Studio and showed me Solution Explorer graph of a whole bunch of files. Text. &lt;/p&gt;
&lt;p&gt;A small minority of you might have used a different approach &amp;ndash;showing me functional tests, a user interface, a database or a dependency graph. An even smaller minority might have shown me a UML diagram, DSL, or other code generation metadata. Six or seven of you might have even opened a decompilation tool or showed me some IL. Two or three of you might have discussed semantics. One of you, just maybe, opened a workflow designer (ah, the sad story of Workflow is for another day). &lt;/p&gt;
&lt;p&gt;The line between these realities has been stark. You&amp;rsquo;re writing code or your ditzing around with the tools that support you writing code. Text. Text. Text. &lt;/p&gt;
&lt;p&gt;A computer program has always been all of these things and something else. Something ethereal that existed between your ears and my ears. As programs have become more complex, we become increasingly desperate to live in the ecosystem of our application instead of in the code. That&amp;rsquo;s what agile was all about. Agile makes our application into an ecosystem of players. So does DSL. But in both cases we&amp;rsquo;re blind and playing with only parts of the elephant.&lt;/p&gt;
&lt;p&gt;Wait, code matters. Of course code matters! It is one expression of abstraction along the pipeline from idea to electrons moving in silicon. Code is the last thing that normal humans will comprehend. It becomes IL that a platform specific compiler understands, and then some magic happens. That end works. With apologies for the analogy, we know how to take the elephants output and fertilize the garden. The apps work. We just feed the elephants badly because we do not understand them. &lt;/p&gt;
&lt;p&gt;Oh, just forget that analogy, it was gross anyway. &lt;/p&gt;
&lt;p&gt;What we need to understand is that &lt;i&gt;no one today understands what an application is.&lt;/i&gt; We can&amp;rsquo;t. We can&amp;rsquo;t because the way we reason about anything is predetermined by the wiring of how we sense it. To understand what applications are in new ways, we need new ways to sense them, redefine what they are and place them in rich ecosystems with no rigid boundaries of definition between problem and solution. It&amp;rsquo;s easiest to visualize as no rigid boundaries between text and graphics, but that will feel like a very shallow distinction within five years.&lt;/p&gt;
&lt;p&gt;While no one understands what an application is today, &lt;i&gt;no one can stop us coming to a new understanding and a new relationship in the next five years. &lt;/i&gt;Roslyn is not birthing in a vacuum. We have relatively mature ecosystems in DSL and functional languages. We have an emerging (about to be exploding) work happening in composition and semantics. We have ongoing research in algorithms. We have a lot of work in the areas of agile, quality, reasoning/diagraming, requirements, human interfaces, etc. We are ready. &lt;/p&gt;
&lt;p&gt;Roslyn, for us in the .NET world, is the snowball tossed to start the avalanche of change. It will do this because it will lead us to think of our code as a semantic tree. Such a tiny, tiny thing. And then we&amp;rsquo;ll have the most amazing array of IDE tools, and then new DSL/generation tools, and then amazing new composition reasoning, and then&amp;hellip;, and then&amp;hellip; , and then&amp;hellip; , and then&amp;hellip; , and then&amp;hellip; Each will lead us to new thinking about the next and around the tenth or hundredth &amp;ldquo;and then&amp;rdquo; it will be obvious how seismic the shift.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1808981" width="1" height="1"&gt;</content><author><name>Kathleen</name><uri>http://msmvps.com/members/Kathleen/default.aspx</uri></author><category term="Roslyn" scheme="http://msmvps.com/blogs/kathleen/archive/tags/Roslyn/default.aspx" /></entry></feed>