<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Winterdom</title>
	
	<link>http://winterdom.com</link>
	<description>by dæmons be driven</description>
	<lastBuildDate>Thu, 02 Jul 2009 17:32:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/Commonality" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Comparing Text and Binary Serialization in WCF</title>
		<link>http://winterdom.com/2009/07/comparing-text-and-binary-serialization-in-wcf</link>
		<comments>http://winterdom.com/2009/07/comparing-text-and-binary-serialization-in-wcf#comments</comments>
		<pubDate>Thu, 02 Jul 2009 17:32:11 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[WCF]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/07/comparing-text-and-binary-serialization-in-wcf</guid>
		<description><![CDATA[A question I recently ran into asked about comparing message sizes when using the default Text Message Encoder used by most bindings in WCF with the Binary Message Encoder used by the TcpBinding, without going through the entire WCF stack and having to use a protocol analyzer.
Here’s a sample application that just serializes an object [...]]]></description>
			<content:encoded><![CDATA[<p>A question I recently ran into asked about comparing message sizes when using the default Text Message Encoder used by most bindings in WCF with the Binary Message Encoder used by the TcpBinding, without going through the entire WCF stack and having to use a protocol analyzer.</p>
<p>Here’s a sample application that just serializes an object using the DataContractSerializer and then runs it through both message encoders and presents the results:</p>
<pre class="codebg"><code>
<span class="Statement">using</span> System;
<span class="Statement">using</span> System.Collections.Generic;
<span class="Statement">using</span> System.IO;
<span class="Statement">using</span> System.Linq;
<span class="Statement">using</span> System.Runtime.Serialization;
<span class="Statement">using</span> System.ServiceModel;
<span class="Statement">using</span> System.ServiceModel.Channels;
<span class="Statement">using</span> System.Text;

<span class="StorageClass">namespace</span> BinSerializationTest {
   [DataContract]
   <span class="StorageClass">class</span> SampleDataContract {
      [DataMember]
      <span class="StorageClass">public</span> <span class="Type">string</span> Member1;
      [DataMember]
      <span class="StorageClass">public</span> <span class="Type">int</span> Member2;
      [DataMember]
      <span class="StorageClass">public</span> <span class="Type">string</span> Member3;
   }

   <span class="StorageClass">class</span> Program {
      <span class="StorageClass">static</span> <span class="Type">void</span> Main(<span class="Type">string</span>[] args) {
         <span class="Exception">try</span> {
            SampleDataContract dc = <span class="Statement">new</span> SampleDataContract {
               Member1 = <span class="String">&quot;Sample string 1&quot;</span>,
               Member2 = <span class="Number">142234</span>,
               Member3 = <span class="String">&quot;Different data here&quot;</span>
            };
            <span class="Type">byte</span>[] xml = SerializeToXml(dc);
            Console.WriteLine(<span class="String">&quot;DC serialized to XML resulted in {0} bytes&quot;</span>, xml.Length);
            <span class="Type">byte</span>[] bin = SerializeToBin(dc);
            Console.WriteLine(<span class="String">&quot;DC serialized to binary resulted in {0} bytes&quot;</span>, bin.Length);
         } <span class="Exception">catch</span> ( Exception ex ) {
            Console.WriteLine(ex);
         }
      }

      <span class="StorageClass">static</span> <span class="Type">byte</span>[] SerializeToXml&lt;T&gt;(T obj) {
         Message msg = ObjectToMessage(obj);
         MessageEncodingBindingElement mebe = <span class="Statement">new</span> TextMessageEncodingBindingElement();
         mebe.MessageVersion = MessageVersion.Soap12;
         <span class="Repeat">return</span> Serialize(msg, mebe.CreateMessageEncoderFactory());
      }
      <span class="StorageClass">static</span> <span class="Type">byte</span>[] SerializeToBin&lt;T&gt;(T obj) {
         Message msg = ObjectToMessage(obj);
         MessageEncodingBindingElement mebe = <span class="Statement">new</span> BinaryMessageEncodingBindingElement();
         mebe.MessageVersion = MessageVersion.Soap12;
         <span class="Repeat">return</span> Serialize(msg, mebe.CreateMessageEncoderFactory());
      }
      <span class="StorageClass">static</span> <span class="Type">byte</span>[] Serialize(Message msg, MessageEncoderFactory factory) {
         MessageEncoder enc = factory.Encoder;
         MemoryStream stream = <span class="Statement">new</span> MemoryStream();
         enc.WriteMessage(msg, stream);
         <span class="Repeat">return</span> stream.ToArray();
      }
      <span class="StorageClass">static</span> Message ObjectToMessage&lt;T&gt;(T obj) {
         DataContractSerializer ser = <span class="Statement">new</span> DataContractSerializer(<span class="Statement">typeof</span>(T));
         <span class="Repeat">return</span> Message.CreateMessage(MessageVersion.Soap12, <span class="String">&quot;&quot;</span>, obj, ser);
      }
   }
}
</code></pre>
<p>Hope it’s useful!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=K8AhETxAgV4:tCSVDO4Sc3Q:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=K8AhETxAgV4:tCSVDO4Sc3Q:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=K8AhETxAgV4:tCSVDO4Sc3Q:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/K8AhETxAgV4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/07/comparing-text-and-binary-serialization-in-wcf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item><title>Links for 2009-06-30 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-06-30</link><pubDate>Wed, 01 Jul 2009 00:00:00 PDT</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-06-30</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://hp.vector.co.jp/authors/VA000092/nt/xp-copy-e.html"&gt;Migrating existing Windows XP installation to new motherboard / CPU&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/TgvqRGluTag" height="1" width="1"/&gt;</description></item><item>
		<title>Current Line Highlighting for VS2010</title>
		<link>http://winterdom.com/2009/06/current-line-highlighting-for-vs2010</link>
		<comments>http://winterdom.com/2009/06/current-line-highlighting-for-vs2010#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:17:22 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/06/current-line-highlighting-for-vs2010</guid>
		<description><![CDATA[I’ve created another simple extension for Visual Studio 2010 beta 1 that will highlight the current line the caret is in with a different background color. Here’s a screenshot of the extension in action:
 
The extension itself is pretty simple, but it was a good way to understand how adornments for the text editor worked. [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve created another simple extension for Visual Studio 2010 beta 1 that will highlight the current line the caret is in with a different background color. Here’s a screenshot of the extension in action:</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/06/vs10_clh_1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_clh_1" border="0" alt="vs10_clh_1" src="http://winterdom.com/wp-content/uploads/2009/06/vs10_clh_1_thumb.png" width="640" height="374" /></a> </p>
<p>The extension itself is pretty simple, but it was a good way to understand how adornments for the text editor worked. I think it’s a fairly elegant mechanism that offers quite a bit of potential. A couple of things that I liked quite a bit about it:</p>
<ol>
<li>You can easily configure the order in which your adornment layer is rendered in, compared to the rest of the stuff in the editor. For example, you might want to render it last of all, or perhaps after the text, but before the selection mask. Like other editor extensions, the [Order] attribute on your <code>AdornmentLayerDefinition</code> controls this. </li>
<li>You can ask VS to position your adornment relative to the span of text it is associated with, or to the view layout, and VS will do most of the hard work of keeping it in the right place as the buffer view is scrolled and moved. It makes some things a lot easier. </li>
</ol>
<p>The other thing I found interesting about creating the sample was how you could leverage the Classifications system to integrate with the Fonts and Colors configuration options for an extension that is not a custom classifier extension.</p>
<p>If you look at the extension code, you’ll notice that I have a custom <code>ClassificationFormatDefinition</code> named “Current Line”, which allows the user to easily change the colors used to render the current line adornment. Then, in the code, I can get the settings the user configured (or the default ones provided by the classification format) by using the <code>IClassificationFormatMapService</code>. </p>
<p>This service gives you an <code>IClassificationFormatMap</code> that provides two key things: </p>
<ul>
<li>Get the <code>TextFormattingRunProperties</code> that contains the brushes and other settings you need to use for drawing your adornment, and </li>
<li>An event you can attach to in order to get notified when the user changes the fonts/color settings so that you can refresh your customization. </li>
</ul>
<p>Pretty cool stuff. You can grab the <a href="http://github.com/tomasr/LineAdornments/tree/master">code for the extension</a> from the GitHub repository.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=8sr1_9MRVDI:d4B0ipHbslo:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=8sr1_9MRVDI:d4B0ipHbslo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=8sr1_9MRVDI:d4B0ipHbslo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/8sr1_9MRVDI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/06/current-line-highlighting-for-vs2010/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Classifier Sample Update</title>
		<link>http://winterdom.com/2009/06/classifier-sample-update</link>
		<comments>http://winterdom.com/2009/06/classifier-sample-update#comments</comments>
		<pubDate>Sun, 14 Jun 2009 18:00:43 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/06/classifier-sample-update</guid>
		<description><![CDATA[I’ve been extending my Flow Control Classifier sample extension for Visual Studio 2010, and based on the new features, I decided to rename it to KeywordClassifier instead. I’ve renamed the GitHub repository as well, so make sure you’re heading to the new one.
I will continue playing with this, but besides a significant refactoring of the [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been extending my <a href="http://winterdom.com/2009/06/flow-control-classifier-sample">Flow Control Classifier</a> sample extension for Visual Studio 2010, and based on the new features, I decided to rename it to KeywordClassifier instead. I’ve renamed the GitHub repository as well, so make sure you’re heading to the <a href="http://github.com/tomasr/KeywordClassifier/">new one</a>.</p>
<p>I will continue playing with this, but besides a significant refactoring of the code, I’ve added support for two new classifications:</p>
<ul>
<li><strong>Visibility Keywords:</strong> You can now select different highlighting options for visibility keywords in code like <code>public</code>, <code>private</code> and so on. For example, you can make them less visible by changing them to a color closer to your background.</li>
<li><strong>LINQ Operators:</strong> For C#, you can select options for LINQ query operators, like <code>select</code>, <code>where</code>, <code>groupby</code>, etc.</li>
</ul>
<p>Here’s a screenshot of some of the extension C# code showing all three of our supported classifications:</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/06/vs10_kc_1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_kc_1" border="0" alt="vs10_kc_1" src="http://winterdom.com/wp-content/uploads/2009/06/vs10_kc_1_thumb.png" width="640" height="422" /></a>&#160;</p>
<p>Enjoy!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=WFf88WpTBrk:sB3SiMHXckI:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=WFf88WpTBrk:sB3SiMHXckI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=WFf88WpTBrk:sB3SiMHXckI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/WFf88WpTBrk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/06/classifier-sample-update/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Flow Control Classifier Sample</title>
		<link>http://winterdom.com/2009/06/flow-control-classifier-sample</link>
		<comments>http://winterdom.com/2009/06/flow-control-classifier-sample#comments</comments>
		<pubDate>Tue, 09 Jun 2009 02:25:32 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/06/flow-control-classifier-sample</guid>
		<description><![CDATA[I’ve been doing my first experiments with extending Visual Studio 2010 beta 1 using the recently released SDK. It’s been lots of fun, but it can also be frustrating at times because the new extensibility model is huge and you don’t always know where to get started.
My first sample extension is a custom Classifier that [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been doing my first experiments with extending Visual Studio 2010 beta 1 using the recently released <a href="http://msdn.microsoft.com/en-us/library/bb166441(VS.100).aspx">SDK</a>. It’s been lots of fun, but it can also be frustrating at times because the new extensibility model is huge and you don’t always know where to get started.</p>
<p>My first sample extension is a custom Classifier that changes how flow control keywords get rendered in the editor in C# and C/C++ so that they are easy to separate at a glance from other, more structural keywords. This is a common feature in other IDEs, but Visual Studio has always lumped all language keywords in a single category, which is a bit less useful.</p>
<p>Here’s how code might look with the Flow Control Classifier installed (C#):</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_fcext_1" border="0" alt="vs10_fcext_1" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-fcext-1.png" width="698" height="215" /> </p>
<p>One of the really nice things about how classifiers work in VS2010 is that they get recognized by the IDE automatically and new entries for any custom classificatios are added&#160; in the Fonts And Colors dialog so that the user can tweak the appearance. After installing the sample, you can adjust the settings for the “Flow Control Keyword” category to make the colors match your Visual Studio theme.</p>
<p>Much of the code in this sample is based on the Custom Classifier project template that comes with the VS2010 SDK, but I tweaked it quite a bit to make it easier to work with. You can find the code for the sample on the <a href="http://github.com/tomasr/KeywordClassifier/">FlowControlClassifier repository</a> at GitHub.</p>
<p>There are some interesting aspects about this extension that are worth commenting so that I remember them later on:</p>
<h2>Controlling which Editors are Extended</h2>
<p>The Visual Studio extensibility model provides an easy way to control on which editors your custom classifier runs, through the [ContentType] attribute on your Classifier Provider class.</p>
<p>The default project generated by the project template specifies the “text” content type, which causes it to run always. However, for this sample, I changed that and added the attribute twice; once for C# (which uses the “CSharp” content type), and once for C++ (which uses the “C/C++” content type). </p>
<p>The second aspect of this is, of course, checking the type of context you’re running in at runtime. For the FlowControlClassifier, I wanted to be able to use different lists of keywords to highlight for each language. Though C# and C/C++ are largely similar, this made it easier to support other languages later.</p>
<p>The way to do this is simple: When the classifier runs, I check the ContentType property of the TextBuffer instance associated to the span the classifier is currently classifying:</p>
<pre class="codebg"><code><span class="Type">string</span>[] keywords =
   GetKeywordsByContentType(span.Snapshot.TextBuffer.ContentType);</code></pre>
<h2>Overriding the Default Look</h2>
<p>Another cool thing that the new classifier model provides is that the format specifications provided by classifications are merged together before rendering. That means that a single span in the editor might get classified two different ways by two different classifiers, and the editor can merge those together to produce a single look.</p>
<p>For example, one classifier might say it wants it in bold, while the other might only say it wants it in blue. The editor can then make the span bold and blue.</p>
<p>Fortunately, you can tell the editor how you want that merging process to work. In the FlowControlClassifier, I wanted to always override the default look already provided by the language service classification (i.e. the format specified in the Keyword option in the Fonts And Colors dialog). To do this, I tell VS that I want my classification format to be applied <em>after</em> the default classifier and with a high priority:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_fcext_2" border="0" alt="vs10_fcext_2" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-fcext-2.png" width="574" height="46" /> </p>
<h2>Parsing the Content</h2>
<p>From what I can see, the way the editor interacts with the classifier is such that you will basically get a call to your GetClassificationSpans() method for each visible line in the buffer at a given time. Although the editor gives you a span covering a single line of text at a time while, you can ask for the text before/beyond the span given, though there’s good reason to avoid doing that as much as possible.</p>
<p>Obviously you can’t really rely that it will be exactly so (many things can affect when it gets called), but that does tell us a lot about how the editor works. In particular, only classifying the visible portion of the buffer should definitely keep the editor snappy when possible.</p>
<p>In my initial attempt at writing the classifier, I started manually parsing the text given (which can be retrieved by calling span.GetText()) to look for keywords and generate ClassificationSpans for each one I found.</p>
<p>This seemed to work at first, until I realized this was undesirable for a very simple reason: I couldn’t just look for the words in the text, without being aware of the context they were used in.</p>
<p>For example, “for” is a keyword I’m interested in, but obviously not if it appears inside a quoted string or a comment. I could work around that with a bit of work, but that even that fell apart real quick, since I couldn’t handle multi-line comments or multi-line string literals when I was just seeing the text one line at a time. And parsing back through the buffer to check for context was simply not an appealing option.</p>
<p>Fortunately, after wondering aloud on twitter if there might be a way to reuse the classifications already done by the underlying language service, <a href="http://blogs.msdn.com/noahric/">Noah Richards</a> came to the rescue and provided a fantastic sample on how to do just that: <a href="http://gist.github.com/125540">http://gist.github.com/125540</a></p>
<p>Basically the sample shows how to call use the Classifier Aggregator service provided by the IDE, which aggregates and merges all the classifications returned by the registered classifiers, and ask it to run the classifiers on the selected span of text. Now all you have to do is go through the classifications returned, look for those the language service marked as keywords, and filter those down based on our own list.</p>
<p>The only tricky part about it is some work on our classifier provider implementation so that when we’re calling into the aggregator ourselves, we exclude our own classifier from the process. Very important, otherwise we’d get the editor stuck in an infinite recursion and blow it up real quick.</p>
<p>All the credit for this goes to Noah, I wouldn’t even have known where to start to make this happen <img src='http://winterdom.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<h2>Conclusion</h2>
<p>All in all, I’ve been having lots of fun working on this little extension, and I’m looking forward to extend it to support a number of other things as well. It’s pretty cool that you can do things like this with relative ease in the new editor, and this one is one I sure plan on using day to day.</p>
<p>Everything is not rosy, of course. It takes a while to get used to the extensibility model, as it’s pretty big, and despite the support that MEF provides for hooking stuff together, you still have to be pretty careful about the values you provide in the attributes: If some things don’t match, you might find that things don’t work correctly and there’s no easy way to figure out what’s going on.</p>
<p><b>Update:</b> I&#8217;ve renamed the project to Keyword Classifier and extended it to support new features. <a href='http://winterdom.com/2009/06/classifier-sample-update'> Details  here</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=tKGwM7pVNpM:g85zOIl3ikc:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=tKGwM7pVNpM:g85zOIl3ikc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=tKGwM7pVNpM:g85zOIl3ikc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/tKGwM7pVNpM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/06/flow-control-classifier-sample/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Watch Notes in the VS2010 Debugger</title>
		<link>http://winterdom.com/2009/06/watch-notes-in-the-vs2010-debugger</link>
		<comments>http://winterdom.com/2009/06/watch-notes-in-the-vs2010-debugger#comments</comments>
		<pubDate>Thu, 04 Jun 2009 04:13:37 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/06/watch-notes-in-the-vs2010-debugger</guid>
		<description><![CDATA[One interesting new feature I noticed in the Visual Studio 2010 beta 1 debugger: You can now turn watch expressions into little detached “post-it”-like notes that float around your debugger window. I’m calling them Watch Notes for now, since I have no clue what the feature is actually called.
 
You can create them by hovering [...]]]></description>
			<content:encoded><![CDATA[<p>One interesting new feature I noticed in the Visual Studio 2010 beta 1 debugger: You can now turn watch expressions into little detached “post-it”-like notes that float around your debugger window. I’m calling them Watch Notes for now, since I have no clue what the feature is actually called.</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-notes-1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_bg_notes_1" border="0" alt="vs10_bg_notes_1" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-notes-1-thumb.png" width="640" height="390" /></a> </p>
<p>You can create them by hovering the mouse over an expression. Like in previous versions, you’ll get the watch popup with the details and value of the expression, but notice the little Note-icon on the right:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_bg_notes_2" border="0" alt="vs10_bg_notes_2" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-notes-2.png" width="286" height="54" /> </p>
</p>
<p>If you click on it, the watch expression window will be moved to turn yellow and get detached. It keeps around during your debugging and works just like any expression in the real watch window (that is, it’s context sensitive and insensitive at the same time). </p>
<p>I think this is pretty nifty for some debugging helpers. They will even persist across debugger sessions! More interesting, you can add a brief descriptive text to each watch note and keep it visible (or hidden).</p>
<p>I think these will be very useful when debugging complex issues in small pieces of code, because for general debugging sessions when you go through lots of places in the code, they will get a bit in the way.</p>
<h2>Something Fishy</h2>
<p>Something I did not like, though, is that the note icon used to create these gets hidden away whenever you look into a complex expression that can be drilled down (i.e. one that has [+] next to it):</p>
<p>As soon as the expression properties is expanded, the note icon disappears, and since they always expand automatically as soon as you hover the the cursor over the expression <em>and</em> you need to move over it anyway to reach the note icon (otherwise, the whole popup disappears), then you have to go right away to collapse the properties before being able to create a watch note from the expression. This can get annoying real quick.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=IY_4gtxbB_E:aWXb_3HALKg:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=IY_4gtxbB_E:aWXb_3HALKg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=IY_4gtxbB_E:aWXb_3HALKg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/IY_4gtxbB_E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/06/watch-notes-in-the-vs2010-debugger/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>VS2010 Editor And Explicit Background Colors</title>
		<link>http://winterdom.com/2009/06/vs2010-editor-and-explicit-background-colors</link>
		<comments>http://winterdom.com/2009/06/vs2010-editor-and-explicit-background-colors#comments</comments>
		<pubDate>Wed, 03 Jun 2009 02:42:11 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/06/vs2010-editor-and-explicit-background-colors</guid>
		<description><![CDATA[In general terms, I’m liking the Visual Studio 2010 beta 1 experience quite a bit; there are lots of goodies in there. The Text Editor shows a lot of promise, though it’s still a bit on the buggy side  .
I’ve noticed something that’s nagging me a bit, and that’s full line highlights when you’ve [...]]]></description>
			<content:encoded><![CDATA[<p>In general terms, I’m liking the Visual Studio 2010 beta 1 experience quite a bit; there are lots of goodies in there. The Text Editor shows a lot of promise, though it’s still a bit on the buggy side <img src='http://winterdom.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I’ve noticed something that’s nagging me a bit, and that’s full line highlights when you’ve got elements that have an explicit background set. In my current VS2010 color scheme, I’ve got strings set up so that they will be rendered with a dark green background, different from the almost black, default background color:</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_bg_1" border="0" alt="vs10_bg_1" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-1.png" width="474" height="74" /> </p>
</p>
<p>If I put a breakpoint on that line, the line will be marked with the usual (default) crimson background. But here’s what happens with the string:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_bg_2" border="0" alt="vs10_bg_2" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-2.png" width="476" height="74" /> </p>
<p>So now the string background is preserved, but the foreground color is set to white. It’s readable (by happy change), but it might also blind you.</p>
<p>Now let’s try debugging and see what happens when that line is the current statement:</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-3.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="vs10_bg_3" border="0" alt="vs10_bg_3" src="http://winterdom.com/wp-content/uploads/2009/06/vs10-bg-3-thumb.png" width="488" height="75" /></a> </p>
</p>
<p>Again, the background color is preserved, but now text is black and completely unreadable.</p>
<p>Now, I don’t know if this can be considered a bug or a feature. In general, the VS2010 editor does a much better job of dealing with syntax coloring, and I love that text selection is now semi-translucent and keeps syntax highlighting visible. It’s a simple thing, but it makes the editor much nicer to use.</p>
<p>Given the issues exhibited above, what I really wished happened is that both kinds of line highlighting were handled exactly like text selection: Make the marker a semi-translucent background and don’t force the foreground text color. It’s bound to be rather ugly.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=K4cbRFGWuVc:Ur061pmXdyI:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=K4cbRFGWuVc:Ur061pmXdyI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=K4cbRFGWuVc:Ur061pmXdyI:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/K4cbRFGWuVc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/06/vs2010-editor-and-explicit-background-colors/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oslo SDK May 2009 CTP</title>
		<link>http://winterdom.com/2009/05/oslo-sdk-may-2009-ctp</link>
		<comments>http://winterdom.com/2009/05/oslo-sdk-may-2009-ctp#comments</comments>
		<pubDate>Wed, 27 May 2009 01:48:58 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Oslo]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/05/oslo-sdk-may-2009-ctp</guid>
		<description><![CDATA[The May 2009 CTP drop of the Microsoft Oslo SDK was released today. I was just installing it to check out what’s new, and thought it was a bit funny how Oslo’s minimalistic UI design extends all the way to the CTP installation program:

]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=827122a5-3ca0-4389-a79e-87af37cbf60d&amp;displaylang=en">May 2009 CTP</a> drop of the Microsoft <a href="http://msdn.microsoft.com/en-us/oslo/default.aspx">Oslo</a> SDK was released today. I was just installing it to check out what’s new, and thought it was a bit funny how Oslo’s minimalistic UI design extends all the way to the CTP installation program:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="oslo_sdk_install" border="0" alt="oslo_sdk_install" src="http://winterdom.com/wp-content/uploads/2009/05/oslo-sdk-install.png" width="590" height="435" /></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=dhch-keMdxQ:1LpfQ2KYLN8:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=dhch-keMdxQ:1LpfQ2KYLN8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=dhch-keMdxQ:1LpfQ2KYLN8:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/dhch-keMdxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/05/oslo-sdk-may-2009-ctp/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>VirtualBox, VirtualPC and Crashes</title>
		<link>http://winterdom.com/2009/05/virtualbox-virtualpc-and-crashes</link>
		<comments>http://winterdom.com/2009/05/virtualbox-virtualpc-and-crashes#comments</comments>
		<pubDate>Mon, 25 May 2009 21:25:00 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/05/virtualbox-virtualpc-and-crashes</guid>
		<description><![CDATA[I take advantage of both VirtualBox and VirtualPC as core parts of my development environment. I keep several sets of Virtual Machines around on both platforms that I use for core development (writing code) and testing on different platforms.
Because of this, I’m constantly switching between the two, depending on which VM I need to use [...]]]></description>
			<content:encoded><![CDATA[<p>I take advantage of both <a href="http://www.virtualbox.org/">VirtualBox</a> and <a href="http://www.microsoft.com/windows/virtual-pc/">VirtualPC</a> as core parts of my development environment. I keep several sets of Virtual Machines around on both platforms that I use for core development (writing code) and testing on different platforms.</p>
<p>Because of this, I’m constantly switching between the two, depending on which VM I need to use to try something. I’m finding myself using VirtualBox a lot lately because of the need to run a couple of VMs at the same time, which is something that it does quite a bit better than VirtualPC.</p>
<p>I don’t try to run both of them at the same time, nor do I need them to. I take advantage of hardware virtualization support in my desktop machine (which has an Intel Q6600 processor) in both platforms, which can speed things quite a bit.</p>
<p>The problem, however, is that both tools seem to pretty much assume that they are the only ones that will try to probe the processor virtualization support. </p>
<p>Occasionally, I’ll make a mistake and click on the wrong icon in the Quick Launch toolbar and end up starting the wrong application. Sometimes I end up starting VPC when I’m already working on VBox, and sometimes I’ll end up starting VBox when I’ve already got a VM in VPC open.</p>
<p>The end result is almost always the same: Windows crashing right away with a Blue Screen of Death (BSOD), usually with a fault in vmm.sys.</p>
<p>Again, I have no need to use both tools at the same time, but it sure would be nice if accidentally clicking the wrong icon didn’t force me to spend 10 minutes while my machine comes back up and I can setup my environment as it was before the crash, and probably lose some recent work, as well!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=FoNakEMF3A8:myB8ggZk-qw:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=FoNakEMF3A8:myB8ggZk-qw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=FoNakEMF3A8:myB8ggZk-qw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/FoNakEMF3A8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/05/virtualbox-virtualpc-and-crashes/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comments on the WF 4.0 Designer</title>
		<link>http://winterdom.com/2009/05/comments-on-the-wf-40-designer</link>
		<comments>http://winterdom.com/2009/05/comments-on-the-wf-40-designer#comments</comments>
		<pubDate>Mon, 25 May 2009 15:40:14 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/05/comments-on-the-wf-40-designer</guid>
		<description><![CDATA[I’ve been testing a few of the new features in Workflow Foundation 4.0 and getting to know the completely revamped Workflow Designer in Visual Studio 2010 beta 1. In a broad sense, I think it’s an improvement over the old designer in VS2005/8, but in the end I’m still far from happy with it. Here [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been testing a few of the new features in Workflow Foundation 4.0 and getting to know the completely revamped Workflow Designer in Visual Studio 2010 beta 1. In a broad sense, I think it’s an improvement over the old designer in VS2005/8, but in the end I’m still far from happy with it. Here are some comments on what I like and don’t like:</p>
<h2>What I like</h2>
<ul>
<li>It’s hard to argue that the new designer isn’t a big improvement in the looks category. It sports a somewhat minimalistic view, making much less use of gradients and other bling that was common in its previous incarnation. </li>
<li>The option to zoom in/out of the current workflow view is great. Not only is it useful, it’s very smooth as well. </li>
<li>The mini-map rocks when navigating a large map, and I find it particularly useful when I’m working on a zoomed designer window:      <br /><a href="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-minimap.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_minimap" border="0" alt="vs10_wf_minimap" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-minimap-thumb.png" width="240" height="224" /></a> </li>
<li>I like the breadcrumbs navigation list at the top-left of the designer as you dive deeper into nested activities. It could be a bit more visible, though.      <br /><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_nav" border="0" alt="vs10_wf_nav" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-nav.png" width="229" height="61" /> </li>
<li>The variables and arguments windows are useful, and certainly the underlying concept is, in general, far more solid than the activity binding model supported in previous versions of the runtime. </li>
<li>The new Flowchart workflows types, and it’s associated designer is, in my humble opinion, a massive improvement over the previous models. It feels a lot more natural to write flows like this and it’s a lot easier to organize the workflow visually into something that makes sense. </li>
<li>There’s a Save As Image option in the designer popup menu that can be used to save a JPG file with an image of the workflow as it’s currently shown in the designer. It’s useful, though not thrilled that warnings/errors are rendered into the saved image. </li>
</ul>
<h2>What I don’t like</h2>
<p>Unfortunately, this might very well be a far longer list:</p>
<p>The overall way of writing workflows through the designer remains extremely clunky, and it’s a pretty slow and awkward process. Maybe it’s just me, but I don’t find the overall experience very pleasant. </p>
<p>To start with, doing almost anything requires way too many clicks here and there. You find yourself constantly jumping between the workflow window, the variables window, the properties window and one or more popup tool windows to enter data and edit data.</p>
<p>To make things a bit worse, I find the lack of connections between all these to be somewhat unsettling, because no part of the process is oriented towards doing tasks but just small parts of tasks at a time. Because they are not connected across the entire process, I would find myself jumping back and forth between windows.</p>
<p>For example, let’s say I add a new activity and want to bind some data to one of it’s properties. When I go to the properties window and fire up the expression window, I realize I needed to move data from somewhere else and would like a workflow variable for that. So now I have to back out of the current spot, go back to the Variables window, add the variable, back to the properties window and into the expression window. Too many steps!</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-inline.png"><img style="border-right-width: 0px; margin: 0px 0px 5px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_inline" border="0" alt="vs10_wf_inline" align="right" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-inline-thumb.png" width="240" height="124" /></a> Another thing I’m not a big fan of is having activities provide lots of built-in editing windows right on the designer surface. For example, the <code>InvokeMethod&lt;T&gt;</code> activity allows you to enter the expressions for Target Type, Target Object and Method Name right into the designer.</p>
<p>At first glance, this would seem like a good thing; after all, it saves you from a few trips to the properties window. But later, it becomes a bit more cumbersome, as it is data that you’re simply not interested in looking at the whole time. Also, most of the time the activity’s display surface will be too small to display entire values, so it’s not even that useful then.</p>
<h3>Tool Windows</h3>
<p>Tool Windows in the current beta are horrible to work with; they have very poor usability. I’m referring to windows such as the expression editor, the type selection window and so forth.</p>
<p><a href="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-exprwnd.png"><img style="border-right-width: 0px; margin: 0px 10px 0px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_exprwnd" border="0" alt="vs10_wf_exprwnd" align="left" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-exprwnd-thumb.png" width="240" height="123" /></a> The first problem I ran into is that almost none of the popup windows are resizable. For most windows, this is really annoying, and what’s worse is that this includes the all around common Expression Editor window. Seriously, have we learned nothing from all the complaints around this from the BizTalk Orchestration designer?</p>
<p>For some windows, though, it gets even worse. Some windows, such as those that have grids, are not only not resizable by the user, but they also change size on their own. Drives me nuts! </p>
<p>A good example of this is the window that comes up when you try to edit the <code>Parameters</code> property of the <code>InvokePowerShell</code> activity: Initially, it contains just enough space to display a single row. After adding one row, the window resizes to show the original row and a blank new row, and keeps doing that as you add data to it. If you delete a row, the window becomes smaller again. There’s also no built-in scrolling at all, so if you need to add more rows than fit vertically on your screen, well, you’re hosed.</p>
<p>Another thing that gives a bad initial impression is that some windows react strangely to input from the user. For example, consider the Expression Editor Window. When it comes up, it has one size. Click on the actual text box to change the expression, and the window jumps around resizing itself twice (to end up with the initial size). Annoying.</p>
<p>To be fair to the Expression Editor window, user input isn’t always handled correctly in other places. For example, try to enter an expression for the default value of a new variable in the Variables window and try selecting the “All” button under the IntelliSense window when it pops up. Yep, it all goes away.</p>
<p>Here’s another that doesn’t make much sense to me: The Browse for Types window that comes up when selecting the type for a variable lists types by assembly, and inside each one ordered by type name, without consideration for namespaces. Yes, types are not grouped around namespaces at all.</p>
<p>Oh, and while we’re at it: All those new tool windows have nice and shiny white backgrounds all over the place. Considering plucking my eyes out as a workaround.</p>
<h3>The Flowchart Designer</h3>
<p>Flowcharts are (to me) the single most important feature in WF 4. They are a much nicer model to work with, I think. That said, the designer is not without faults:</p>
<ul>
<li>Connection points are too sensitive, making them hard to target and pinpoint accurately. Sometimes links just end up going where you don’t want them to. </li>
<li>Arrows are too small, making it hard to grasp the flow at a glance (particularly when the view is zoomed out). </li>
<li>The automatic routing of arrows is sometimes quirky (though I guess it’s OK). </li>
<li>Sometimes selection isn’t handled correctly. Many times I’ve selected an arrow, seen it clearly rendered as selected, hit the Delete key only to find the entire workflow is deleted. At least Undo seems to work. </li>
<li>I love that you can resize the flowchart designer area. I hate that you have to scroll all the way to the bottom right to do it. </li>
</ul>
<h2>Variable Scope</h2>
<p>In WF 4.0, Variables are scoped to composite activities. That is, you can define a variable either on the top level workflow, or on a specific activity, like a <code>Sequence</code> or a <code>CancellationScope</code> already in the workflow.</p>
<p>Unfortunately, the way this is exposed at the designer level is incredibly clunky:</p>
<ul>
<li>The scope is not represented visually in the Variables window. Instead all you get is the Scope column in the variables list:      <br /><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_scope" border="0" alt="vs10_wf_scope" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-scope.png" width="214" height="124" />       <br />Even BizTalk 2004 got it right: It needs to be shown visually. Nested scopes are a tree, don’t try to represent it with a list; it doesn’t work. </li>
<li>The variable window will show / hide variables based on the scope. If you select a composite activity, it will only show variables declared at its scope and that of its ancestors. Variables defined in children of the activity are not included.      <br />I understand it’s trying to be useful, but this just gets in the way. If you want to define or look at a variable defined 3 levels deep, then you get to first navigate all the workflow to get there just to be able to get the Variables window to show you the definition. Gah! </li>
<li>When adding a new variable, scope defaults to the activity currently selected in the designer. This almost makes sense, but if you decide that’s not right, well, surprise! Scopes shown in the drop down list for the Scope column follow the same rules as above. That means you can’t add a new variable in a scope without being physically nested within it (i.e. can’t add to a sibling activity). Annoying. </li>
</ul>
<h2>Conclusion</h2>
<p>Many of the issues I’ve brought up here are basic usability problems, but many correctable. One can hope there’s still time in the Visual Studio 2010 timeframe to see some of those UX issues addressed.</p>
<p>I’m not very hopeful, though, about having a designer that’s really more pleasurable to use and that addresses the bigger issues related to the experience of creating and editing a workflow more conveniently and with less clicking, as those might very well require rethinking the entire process over. It’s really more of a conceptual issue than a technical issue, in a way.</p>
<p>Don’t get me wrong, the new designer is an improvement over the old one. Unfortunately, that’s all it is: An improvement. It provides an interesting foundation to address some of the technical shortcomings that the original Workflow Designer has, but it doesn’t really provide a more meaningful/powerfull way of designing workflows. In that sense, I do think it’s a bit of a missed opportunity. </p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=qt5ab4ncj3o:8ujJD-sQ0cc:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=qt5ab4ncj3o:8ujJD-sQ0cc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=qt5ab4ncj3o:8ujJD-sQ0cc:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/qt5ab4ncj3o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/05/comments-on-the-wf-40-designer/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>InvokePowerShell Activity</title>
		<link>http://winterdom.com/2009/05/invokepowershell-activity</link>
		<comments>http://winterdom.com/2009/05/invokepowershell-activity#comments</comments>
		<pubDate>Fri, 22 May 2009 13:10:59 +0000</pubDate>
		<dc:creator>Tomas Restrepo</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Workflow]]></category>

		<guid isPermaLink="false">http://winterdom.com/2009/05/invokepowershell-activity</guid>
		<description><![CDATA[ I’ve been fooling a bit with the new Windows PowerShell-related activities included in Windows Workflow Foundation 4.0 alongside the Visual Studio 2010 Beta 1 release. It’s pretty cool seeing PowerShell being directly supported right out of the box!
There are two different activities: InvokePowerShell and InvokePowerShell&#60;T&#62;. The difference (as far as I can see) is [...]]]></description>
			<content:encoded><![CDATA[<p><img style="border-right-width: 0px; margin: 0px 10px 10px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_ps" border="0" alt="vs10_wf_ps" align="left" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-ps.png" width="234" height="117" /> I’ve been fooling a bit with the new Windows PowerShell-related activities included in Windows Workflow Foundation 4.0 alongside the Visual Studio 2010 Beta 1 release. It’s pretty cool seeing PowerShell being directly supported right out of the box!</p>
<p>There are two different activities: <code>InvokePowerShell</code> and <code>InvokePowerShell&lt;T&gt;</code>. The difference (as far as I can see) is that the latter allows you to capture the output of the PowerShell command being executed (that is, the results from the pipeline). I can understand why both variants might be needed, but not thrilled about the naming. At the least, it’s not immediately obvious what the difference between the two is, so it’s going to be confusing.</p>
<h2>Using InvokePowerShell</h2>
<p>I struggled a bit understanding how the <code>InvokePowerShell</code> activity was meant to be used. In particular, I didn’t grasp immediately the significance of the <code>IsScript</code> property of the activity:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="vs10_wf_ps_params" border="0" alt="vs10_wf_ps_params" src="http://winterdom.com/wp-content/uploads/2009/05/vs10-wf-ps-params.png" width="433" height="182" /> </p>
<p>If I understand it correctly, here’s the key difference: If <code>IsScript</code> is not checked (the default), then <code>CommandText</code> cannot be an arbitrary PowerShell expression. Instead it must be the <em>name</em> of the PowerShell cmdlet to invoke, but you cannot add any extra information there (such as the value of a parameter). By contrast, if <code>IsScript</code> is checked, then <code>CommandText</code> can be a list of (more or less) arbitrary PowerShell expressions, including variable declarations and all.</p>
<p>I believe that for a lot of people, enabling <code>IsScript</code> will make the activity behave in a more natural way.</p>
<p>There are a few more interesting details about the PowerShell activities:</p>
<h3>Passing Data into PowerShell</h3>
<p>There are two ways to pass data into the PowerShell script to execute:</p>
<ol>
<li>If you’re executing a cmdlet, then the Parameters collection can be used to provide input arguments to the cmdlet call. For example, if <code>CommandText</code> is <code>“Get-Process”</code>, then you can add a <code>Name</code> parameter to the <code>Parameters</code> collection with the value set to an expression returning a string, and it will be the same as if you had invoked <code>“Get-Process -Name &lt;value&gt;”</code>. I’m not 100% sure yet, but it would seem like this would only really apply if <code>IsScript</code> is <em>unchecked</em> (otherwise, it’s not very clear what you’re passing the parameters to). </li>
<li>You can have WF push variables into the PowerShell runspace before the invocation. This is what the <code>PowerShellVariables</code> property is for. If you add a variable there call <code>Error</code>, then the PowerShell expression in <code>CommandText</code> can reference the value by using <code>$Error</code>. Again, this would appear to be mostly useful when <code>IsScript</code> is <em>checked</em>. </li>
</ol>
<p>Based on this, one might suspect that the <code>Parameters</code> and <code>PowerShellVariables</code> properties are basically there to support both modes of operation of the activity: One when invoking a cmdlet directly and one when executing a more free-form script. Is this good? I’m not sure yet. I can see a sort of logic to both ways of using the <code>InvokePowerShell</code> activity, but it seems a bit complex and potentially confusing. I sure know I was confused the first time I tried to use it.</p>
<h3>Pipeline Input</h3>
<p>It should be obvious by now that I wasn’t exactly right when I said there were two ways to pass data into the PowerShell script. There’s a third (main?) one: Provide an object (or collection of objects) as the pipeline input, which is what the <code>Input</code> property of the activity is for.</p>
<p>It should be fairly obvious how to use it: If the command is a cmdlet, then the input will be feed just like if you had piped something to it in PowerShell. You might expect that if the command is a free-form script, then you’d be able to access it the inputs <code>$_</code>; however, I haven’t been successful in that so not sure if it’s supported.</p>
<h3>Pipeline Output</h3>
<p>Handling pipeline output is only done in the <code>InvokePowerShell&lt;T&gt;</code> activity, and it’s basically very simple: When adding the activity to your workflow, the designer will ask you to bind <code>T</code> to a type, and that’s what you expect your PowerShell command to return. I can imagine that in most cases, this should be some sort of collection (like <code>IEnumerable</code>) since most PowerShell commands will return multiple objects.</p>
<p>Then, just bind the <code>Output</code> property of the activity to a variable in your workflow that will receive the pipeline output after the activity executes.</p>
<h3>Pipeline Errors</h3>
<p>Errors resulting from executing the <code>InvokePowerShell</code> activity can surface in one of two ways:</p>
<ul>
<li>Certain errors, such as trying to invoke a malformed expression or a non-existent cmdlet will result in an exception being thrown and the Workflow faulting, unless you have the activity inside try/catch blocks. </li>
<li>Anything that gets written by the command to the error stream (through the Write-Error cmdlet) will get exposed through the <code>Errors</code> property of the <code>InvokePowerShell</code> activity. To handle those, you’ll want to create a new variable in your workflow (of type <code>Collection&lt;ErrorRecord&gt;</code> or just <code>IEnumerable</code>), and then bind it to the <code>Errors</code> property.&#160; Now you should be able to simply iterate over your variable right after <code>InvokePowerShell</code> finishes executing. </li>
</ul>
<h3>Designer Support</h3>
<p>I’m not totally happy with the designer support for the PowerShell activities. Besides my general complaints about the Workflow Designer (a subject for another blog post), there’s something that really bugs me: There’s no proper editor support for entering the <code>CommandText</code> in the activity.</p>
<p>Sure, you can attempt to write your script directly into the text editor in the activity designer, but that’s way too small for anything more complex than, say, calling <code>Get-Process</code>. You could also attempt to use the property window, but that’s even worse because all it has is a single-line text box. At the very least, it needs to popup into a multi-line text editor window.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Commonality?a=g_QxlF0DKHY:A2D60W7Jc_U:cGdyc7Q-1BI"><img src="http://feeds.feedburner.com/~ff/Commonality?d=cGdyc7Q-1BI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Commonality?a=g_QxlF0DKHY:A2D60W7Jc_U:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Commonality?i=g_QxlF0DKHY:A2D60W7Jc_U:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Commonality/~4/g_QxlF0DKHY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://winterdom.com/2009/05/invokepowershell-activity/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<item><title>Links for 2009-05-18 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-05-18</link><pubDate>Tue, 19 May 2009 00:00:00 PDT</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-05-18</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://sms.cam.ac.uk/collection/545358"&gt;SMS: &amp;quot;Tim Gowers - Computational Complexity and Quantum Compuation&amp;quot;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/rcamo4M3rnc" height="1" width="1"/&gt;</description></item><item><title>Links for 2009-05-12 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-05-12</link><pubDate>Wed, 13 May 2009 00:00:00 PDT</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-05-12</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.e-booksdirectory.com/programming.php"&gt;Free Programming Books&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/YNGJWzA94lY" height="1" width="1"/&gt;</description></item><item><title>Links for 2009-05-10 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-05-10</link><pubDate>Mon, 11 May 2009 00:00:00 PDT</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-05-10</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://lecturefox.com/computerscience/"&gt;university lectures computer science&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/jhIHNjd65jU" height="1" width="1"/&gt;</description></item><item><title>Links for 2009-03-09 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-03-09</link><pubDate>Tue, 10 Mar 2009 00:00:00 PDT</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-03-09</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://colorschemedesigner.com/"&gt;Color Scheme Designer 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/ruXQhq5A-A8" height="1" width="1"/&gt;</description></item><item><title>Links for 2009-02-08 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-02-08</link><pubDate>Mon, 09 Feb 2009 00:00:00 PST</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-02-08</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.theleagueofmoveabletype.com/"&gt;The League of Moveable Type&lt;/a&gt;&lt;br/&gt;
open source types &amp;amp; fonts&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/wccF9eHpMeU" height="1" width="1"/&gt;</description></item><item><title>Links for 2009-01-31 [del.icio.us]</title><link>http://del.icio.us/tomas.restrepo#2009-01-31</link><pubDate>Sun, 01 Feb 2009 00:00:00 PST</pubDate><guid isPermaLink="true">http://del.icio.us/tomas.restrepo#2009-01-31</guid><description>&lt;ul&gt;
&lt;li&gt;&lt;a href="http://haikumonkey.net/?p=99"&gt;Lavoisier Font&lt;/a&gt;&lt;br/&gt;
A nice free font&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/Commonality/~4/XxsZLTvN9IU" height="1" width="1"/&gt;</description></item></channel>
</rss><!-- Dynamic page generated in 0.367 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-07-02 17:44:16 -->
