<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Kristof&#039;s blog</title>
	<atom:link href="http://kristofmattei.be/feed/" rel="self" type="application/rss+xml" />
	<link>http://kristofmattei.be</link>
	<description>A blog on my experiences in programming, work, and life!</description>
	<lastBuildDate>Thu, 17 May 2012 17:49:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Community Day 2012 is getting closer</title>
		<link>http://kristofmattei.be/2012/05/17/community-day-2012-is-getting-closer/</link>
		<comments>http://kristofmattei.be/2012/05/17/community-day-2012-is-getting-closer/#comments</comments>
		<pubDate>Thu, 17 May 2012 17:47:56 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1169</guid>
		<description><![CDATA[Last week the registrations opened for Community Day 2012. This (completely free) event joins all the Belgian usergroups to offer you 6 tracks with over 40 deep-technical sessions and the best networking opportunities available. Together with Bart Wullems I will give a session about Git &#8230; <a href="http://kristofmattei.be/2012/05/17/community-day-2012-is-getting-closer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Last week the registrations opened for <a title="Community Day 2012" href="http://communityday.be" target="_blank">Community Day 2012</a>. This (completely free) event joins all the Belgian usergroups to offer you 6 tracks with over <a title="Community Day 2012 Agenda" href="http://www.communityday.be/cd/tabid/130/Default.aspx" target="_blank">40 deep-technical sessions</a> and the best networking opportunities available.</p>
<p>Together with <a title="The Art of Simplicity" href="http://bartwullems.blogspot.com/">Bart Wullems</a> I will give a session about Git and GitHub for .NET developers.</p>
<p><img src="http://www.communityday.be/data/downloads/ComDay2012-imaspeaker.png" alt="" width="222" height="222" /></p>
<p>Register <a title="Register" href="http://www.communityday.be/cd/tabid/58/Default.aspx" target="_blank">here</a>.</p>
<p>Below you can find all the details of the event:</p>
<p><strong>Location:</strong> Utopolis Mechelen (<a href="http://www.bing.com/maps/?v=2&amp;where1=Spuibeekstraat%205%2C%202800%20Mechelen%2C%20Belgium&amp;q=Spuibeekstraat%205%2C%202800%20Mechelen%2C%20Belgium&amp;form=LMLTSN&amp;cp=51.02584076363099~4.4990701999999905&amp;lvl=18&amp;sty=r&amp;encType=1" target="_blank">Map</a>)<br />
<strong>Address: </strong>Spuibeekstraat 5 2800 Mechelen<br />
<strong>Event date: </strong>Thursday June 21th<br />
<strong>Start &amp; end time: </strong>8.30 &#8211; 19.00<br />
<strong>Add Community Day 2012 to your agenda: </strong><a href="http://www.communityday.be/data/Community_Day_2012.ics" target="_blank">Outlook *.ics file</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2012/05/17/community-day-2012-is-getting-closer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get your facts right.</title>
		<link>http://kristofmattei.be/2012/03/12/get-your-facts-right/</link>
		<comments>http://kristofmattei.be/2012/03/12/get-your-facts-right/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 09:14:41 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Various]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1149</guid>
		<description><![CDATA[I just read this article: http://www.simple-talk.com/dotnet/.net-framework/10-reasons-why-visual-basic-is-better-than-c/ . And I’m pissed. Why? Allow me to elaborate First of all, because on the top right there is “a service from redgate”. You’d expect to get their facts right. And that’s the main &#8230; <a href="http://kristofmattei.be/2012/03/12/get-your-facts-right/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just read this article: <a href="http://www.simple-talk.com/dotnet/.net-framework/10-reasons-why-visual-basic-is-better-than-c/">http://www.simple-talk.com/dotnet/.net-framework/10-reasons-why-visual-basic-is-better-than-c/</a> . And I’m pissed. Why? Allow me to elaborate</p>
<p>First of all, because on the top right there is “a service from redgate”. You’d expect to get their facts right.</p>
<p>And that’s the main issue with this article. There will always be fights among developers about which language is better, VB.NET or C#. I don’t care. Use what works best for you. And I’m always interested in a well argumented comparison between the two. (and I’m not going to show my preference here, I worked in both languages, and I like to think I know what I’m talking about).</p>
<p>Alright, let’s take a look at Andy Brown’s points:</p>
<h1>Point number 1</h1>
<p>Not a good point to start with, very personal point, so I’m like: ‘whatever dude’</p>
<h1>Point number 2</h1>
<p>Again, bad point, it’s a language feature, I have no problem with typing out an if else statement. However the second part of your argument is utterly wrong. C# doesn’t allow fall through in a case statement, meaning the compiler will complain if you omit the break statement:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/03/image.png" rel="lightbox"><img style="display: inline" title="case fallthrough C#" alt="case fallthrough C#" src="http://kristofmattei.be/wp-content/uploads/2012/03/image_thumb.png" width="318" height="204"></a></p>
<h1>Point number 3</h1>
<p>If I change the name of my control in the designer it just updates everything. I guess your Visual Studio 2010 is broken.</p>
<h1>Point number 4</h1>
<p>The one I hate the most. Not only are you PUSHING your personal preference to other people, you’re doing it with the wrong arguments. Allow me to explain:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/2a723cdk(v=vs.100).aspx" target="_blank">&amp;&amp;</a> in C# is NOT <a href="http://msdn.microsoft.com/en-us/library/sdbcfyzh.aspx" target="_blank">And</a> in VB.NET. The <a href="http://msdn.microsoft.com/en-us/library/2a723cdk(v=vs.100).aspx" target="_blank">&amp;&amp;</a> is a <a href="http://msdn.microsoft.com/en-us/library/sdbcfyzh.aspx" target="_blank">Contitional And</a>, the And operator is logical, meaning it will execute both sides. We can read this on the <a href="http://msdn.microsoft.com/en-us/library/sdbcfyzh.aspx" target="_blank">MSDN page</a> on this topic.</p>
<p>Let me prove it to you with an example:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/03/image1.png" rel="lightbox"><img style="display: inline" title="C# &amp;&amp;" alt="C# &amp;&amp;" src="http://kristofmattei.be/wp-content/uploads/2012/03/image_thumb1.png" width="522" height="515"></a></p>
<p>As you can see it only executes the Foo one, it completely omits the Bar!</p>
<p>If we follow the ‘comparison’ Andy wrote this would translate to the following VB.NET code:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/03/image2.png" rel="lightbox"><img style="display: inline" title="VB.NET And" alt="VB.NET And" src="http://kristofmattei.be/wp-content/uploads/2012/03/image_thumb2.png" width="410" height="371"></a></p>
<p>Well, it seems that we need the <a href="http://msdn.microsoft.com/en-us/library/cb8x3kfz.aspx" target="_blank">AndAlso</a> operator in VB.NET to get the same behavior. You can get the And behavior in C# by using a single <a href="http://msdn.microsoft.com/en-us/library/sbf85k1c(v=vs.100).aspx" target="_blank">&amp;</a> instead of a double.</p>
<p>The same is for the <a href="http://msdn.microsoft.com/en-us/library/6373h346.aspx" target="_blank">||</a> and the <a href="http://msdn.microsoft.com/en-us/library/06s37a7f.aspx" target="_blank">Or</a>, you need the <a href="http://msdn.microsoft.com/en-us/library/ea1sssb2.aspx" target="_blank">OrElse</a> to achieve the || result, or, to use the Or in C#, you need the single <a href="http://msdn.microsoft.com/en-us/library/6373h346.aspx" target="_blank">|</a> instead of a double.</p>
<h1>Point number 5</h1>
<p>First of all this is a IDE feature, not a language feature. But fine, I’ll bite: you have that too in C#. Type prop+&lt;tab&gt;+&lt;tab&gt; and you’ve got your property.</p>
<h1>Point number 6</h1>
<p>You are relying on the Microsoft.VisualBasic namespace. If you want to you can even add it to your C# project. The issue with this function is the following: reading the <a href="http://msdn.microsoft.com/en-us/library/6cd3f6w1(v=vs.90).aspx" target="_blank">documentation</a> doesn’t give me a single clue on what the restrictions are, what culture does it use?</p>
<p>You can always do <a href="http://msdn.microsoft.com/en-us/library/zf50za27.aspx" target="_blank">int.TryParse</a> or <a href="http://msdn.microsoft.com/en-us/library/3s27fasw.aspx" target="_blank">double.TryParse</a>. Hec, you can even do a Regular Expression like ^[0-9]$ and then something else for the commas. I’m not a Regex Expert, and probably never will be <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Smile with tongue out" src="http://kristofmattei.be/wp-content/uploads/2012/03/wlEmoticon-smilewithtongueout.png">.</p>
<p>And for your PMT function (click, decompiled from the dll): </p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/03/image4.png" rel="lightbox"><img style="display: inline" title="PMT" alt="PMT" src="http://kristofmattei.be/wp-content/uploads/2012/03/image_thumb4.png" width="240" height="152"></a></p>
<h1>Point number 7</h1>
<p>Language feature, personal preference. No argument there.</p>
<h1>Point number 8</h1>
<p>First you start off by writing how to declare and define variables and then you come up with the <a href="http://msdn.microsoft.com/en-us/library/ee332485.aspx" target="_blank">out</a> keyword? And if you have problems with the out keyword, you do realize that VB.NET doesn’t offer a way to the programmer to restrict him to give either an initialized variable or a non initialized variable. VB.NET only supports ByVal and ByRef, where the first is always a pointer (like in C#) and the second one is <a href="http://msdn.microsoft.com/en-us/library/14akc2c7.aspx" target="_blank">ref</a>. No out available <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://kristofmattei.be/wp-content/uploads/2012/03/wlEmoticon-sadsmile.png">. And then there is this behavior: <a href="http://msdn.microsoft.com/en-us/library/chy4288y.aspx" target="_blank">Force an Argument to Be Passed by Value</a>. </p>
<h1>Point number 9</h1>
<p>An enum in C# is an enum, even though it inherits from int. It’s just the compiler that complains. Of all the things you mentioned you have a fair point here. I’ll give you that.</p>
<h1>Point number 10</h1>
<p>You say it yourself, the whole point of an array is that it is fixed size. Use a list. They’re there for a reason.</p>
<p>I do not want to rant. I just want to get the facts right. And I feel bad. From your bio I read that you are a trainer. While they don’t have to go too deep for an introduction, you should get your facts right. </p>
<p>Signing off,</p>
<p>-Kristof</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2012/03/12/get-your-facts-right/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Your project dependencies matter (when using NuGet)</title>
		<link>http://kristofmattei.be/2012/02/27/your-project-dependencies-matter-when-using-nuget/</link>
		<comments>http://kristofmattei.be/2012/02/27/your-project-dependencies-matter-when-using-nuget/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 21:34:58 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1147</guid>
		<description><![CDATA[At work we had the following issue, we had a Silverlight project consuming some NuGet package, this project was being exposed in a Web application. In order to keep our solution clean &#8211; we didn’t want an ‘assemblies’ folder – &#8230; <a href="http://kristofmattei.be/2012/02/27/your-project-dependencies-matter-when-using-nuget/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At work we had the following issue, we had a Silverlight project consuming some NuGet package, this project was being exposed in a Web application. </p>
<p>In order to keep our solution clean &#8211; we didn’t want an ‘assemblies’ folder – we used NuGet package restore.</p>
<p>We did it like the book said, don’t check in the packages folder, enable NuGet package restore, add the required repositories to the nuget.targets, you know the drill.</p>
<p>When building locally we didn’t have any issues. Everybody was able to run the project perfectly. The packages were downloaded from the repository when unavailable locally.</p>
<p>The issue rose when we committed our code to our source control system and ran builds of it with MSBuild. </p>
<p>In order to explain my issue I managed to create a very simple test case.</p>
<p>I created a solution with 2 projects, a web project, and a Silverlight project. </p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image3.png" rel="lightbox"><img style="display: inline" title="Solution window" alt="Solution window" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb3.png" width="314" height="461"></a></p>
<p>The NuGetTest.Client had a NuGet reference to the package ‘MvvmLight’. </p>
<p>When you commit code to source control and run builds of it with MSBuild, it is supposed to download the NuGet package, and then build of that.</p>
<p>However, if we invoke the build we are presented with the following error:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image4.png" rel="lightbox"><img style="display: inline" title="Ugh, error." alt="Ugh, error." src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb4.png" width="640" height="116"></a></p>
<p>What? Why?</p>
<p>So I went to check the packages folder on the Build location:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image5.png" rel="lightbox"><img style="display: inline" title="It's there!" alt="It's there!" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb5.png" width="747" height="323"></a></p>
<p>It’s there! How could it not find the dll?</p>
<p>Time to dig deeper.</p>
<p>The command line executed for the project was simple:</p>
<pre>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\NuGetTest\New Build Definition 1\Sources\Dev\NuGetTest.sln" /m:1 /fl /flp:"logfile=C:\Builds\1\NuGetTest\New Build Definition 1\Sources\Dev\NuGetTest.log;encoding=Unicode;verbosity=diagnostic" /p:SkipInvalidConfigurations=true  /p:OutDir="C:\Builds\1\NuGetTest\New Build Definition 1\Binaries\\" /p:VCBuildOverride="C:\Builds\1\NuGetTest\New Build Definition 1\Sources\Dev\NuGetTest.sln.vsprops"  /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Diagnostic;BuildUri=vstfs:///Build/Build/8;InformationNodeId=622;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;TFSUrl=http://localhost:8080/tfs/DefaultCollection;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 2010\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Diagnostic;"</pre>
<p>I slimmed it down to the real deal (removed logging), and ended up with this:</p>
<pre>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe "C:\Builds\1\NuGetTest\New Build Definition 1\Sources\Dev\NuGetTest.sln" /m:1 /p:SkipInvalidConfigurations=true</pre>
<p>Now I download the latest version of the project locally, and execute that command line:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image6.png" rel="lightbox"><img style="display: inline" title="&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.sln&quot; (default target) (1) -&gt;&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Host\NuGetTest.Host.csproj&quot; (default target) (2) -&gt;&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj&quot; (default target) (3:2) -&gt;(CoreCompile target) -&gt;  ViewModel\MainViewModel.cs(1,7): error CS0246: The type or namespace name 'GalaSoft' could not be found (are you missing a using directive or an assembly reference?) [d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]  ViewModel\MainViewModel.cs(17,34):errorCS0246: The type or namespace name 'ViewModelBase' could not be found (are you missing a using directive or an assembly reference?) [d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]  ViewModel\ViewModelLocator.cs(15,7): error CS0246: The type or namespace name 'GalaSoft' could not be found (are you missing a using directive or an assemblyreference?)[d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]" alt="&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.sln&quot; (default target) (1) -&gt;&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Host\NuGetTest.Host.csproj&quot; (default target) (2) -&gt;&quot;d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj&quot; (default target) (3:2) -&gt;(CoreCompile target) -&gt;  ViewModel\MainViewModel.cs(1,7): error CS0246: The type or namespace name 'GalaSoft' could not be found (are you missing a using directive or an assembly reference?) [d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]  ViewModel\MainViewModel.cs(17,34):errorCS0246: The type or namespace name 'ViewModelBase' could not be found (are you missing a using directive or an assembly reference?) [d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]  ViewModel\ViewModelLocator.cs(15,7): error CS0246: The type or namespace name 'GalaSoft' could not be found (are you missing a using directive or an assemblyreference?)[d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj]" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb6.png" width="313" height="480"></a></p>
<p>&nbsp;</p>
<p>And we’re greeted with a lot of text, and at the end the same error. So it’s not the user that executes the build (he has sufficient rights).</p>
<p>What seems to happen here?</p>
<p>If we check the log we can see that the NuGetTest.Client is built because NuGetTest.Host depends on it:</p>
<pre>Project "d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Host\NuGetTest.Host.csproj" (2) is building "d:\Personal\Documents\Visual Studio 2010\Projects\NuGetTest\NuGetTest.Client\NuGetTest.Client.csproj" (3) on node 1 (GetXapOutputFile target(s)).</pre>
<p>If we then continue reading the log file we can see that NuGet’s RestorePackages task is only executed after this task, which results in MSBuild trying to build the Silverlight project before all the required assemblies are downloaded.</p>
<p>How can we solve this? We can specify that the Silverlight project should be built before the web project, and thus forcing the RestorePackages to execute in order (before the build of the Silverlight project).</p>
<p>We can do this by going to project dependencies in the Solution Explorer, just do a right mouse on your solution and go to “Properties”.</p>
<p>In that window go to “Project Dependencies”:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image7.png" rel="lightbox"><img style="display: inline" title="Properties for solution, build order" alt="Properties for solution, build order" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb7.png" width="640" height="402"></a></p>
<p>In the “Project” dropdown you select your host project (here “NuGetTest.Host”), and check the checkbox of every Silverlight Project it depends on. This will make MSBuild explicitly build that project before continuing to the web project.</p>
<p>Good luck &amp; have a good one!</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2012/02/27/your-project-dependencies-matter-when-using-nuget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thoughts on a Resharper 6 refactoring</title>
		<link>http://kristofmattei.be/2012/02/15/thoughts-on-a-resharper-6-refactoring/</link>
		<comments>http://kristofmattei.be/2012/02/15/thoughts-on-a-resharper-6-refactoring/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 16:25:00 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Resharper]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1133</guid>
		<description><![CDATA[Consider the following code: If we want to know if there are no items in the list we have 3 possibilities (probably more, but I&#8217;ll limit myself to 3 possibilities in this scope). Which just uses List&#8217;s implementation of ICollection.Count. &#8230; <a href="http://kristofmattei.be/2012/02/15/thoughts-on-a-resharper-6-refactoring/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Consider the following code:</p>
<p><script src="https://gist.github.com/1835946.js"></script>
<p>If we want to know if there are no items in the list we have 3 possibilities (probably more, but I&#8217;ll limit myself to 3 possibilities in this scope).</p>
<p><script src="https://gist.github.com/1835950.js"></script>
<p>Which just uses List&#8217;s implementation of <a href="http://msdn.microsoft.com/en-us/library/system.collections.icollection.count.aspx" target="_blank">ICollection.Count</a>. </p>
<p>Second option is:</p>
<p><script src="https://gist.github.com/1835956.js"> </script>
<p>Last option is:</p>
<p><script src="https://gist.github.com/1835961.js?file=gistfile1.cs"></script>
<p>As you might know, since ReSharper 6, the second option is suggested to be refactored to the last option.</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image.png" rel="lightbox"><img style="display: inline" title="image" alt="image" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb.png" width="350" height="78"></a></p>
<p>However it is not the same to do an <a href="http://msdn.microsoft.com/en-us/library/bb535181(v=vs.100).aspx" target="_blank">Enumerable.Count()</a> and a <a href="http://msdn.microsoft.com/en-us/library/bb534972.aspx" target="_blank">Enumerable.Any()</a> on an <a href="http://msdn.microsoft.com/en-us/library/system.collections.icollection.aspx" target="_blank">ICollection</a>.</p>
<p>If we take a closer look using a decompile tool (<a href="http://www.reflector.net/" target="_blank">Reflector</a>, <a href="http://blogs.jetbrains.com/dotnet/2011/02/resharper-6-bundles-decompiler-free-standalone-tool-to-follow/" target="_blank">Resharper Decompile</a>, <a href="http://www.telerik.com/products/decompiler.aspx" target="_blank">JustDecompile</a>, …) at the Count() and Any() extension methods we see the following:</p>
<p>Count:<br /><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image1.png" rel="lightbox"><img style="display: inline" title="image" alt="image" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb1.png" width="484" height="393"></a></p>
<p>Any:<br /><a href="http://kristofmattei.be/wp-content/uploads/2012/02/image2.png" rel="lightbox"><img style="display: inline" title="image" alt="image" src="http://kristofmattei.be/wp-content/uploads/2012/02/image_thumb2.png" width="479" height="221"></a></p>
<p>We can clearly see that when using the Count() extension method the system actually first tries to see if the the IEnumerable&lt;TSource&gt; is an ICollection&lt;TSource&gt; or an ICollection, and using the Count property if possible, before enumerating over the entire list. </p>
<p>So I say: not everything Resharper says is correct, always use it carefully, think before you do an automatic refactoring. And more importantly: think about the design of your code. Is it needed that you pass in an IEnumerable? Is a ICollection&lt;TSource&gt; or an IList&lt;TSource&gt; more useful?</p>
<p>Have a good one!</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2012/02/15/thoughts-on-a-resharper-6-refactoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Team Foundation 2010: Associate work item with changeset AFTER check in.</title>
		<link>http://kristofmattei.be/2012/01/09/team-foundation-2010-associate-work-item-with-changeset-after-check-in/</link>
		<comments>http://kristofmattei.be/2012/01/09/team-foundation-2010-associate-work-item-with-changeset-after-check-in/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 13:41:16 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[TFS]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1123</guid>
		<description><![CDATA[Today I was struggling associating a work item with a changeset after a check in. There is however no options for this in the UI. Or is there? Let’s check: Ok, so not through the changeset UI. Let’s check the &#8230; <a href="http://kristofmattei.be/2012/01/09/team-foundation-2010-associate-work-item-with-changeset-after-check-in/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I was struggling associating a work item with a changeset after a check in. There is however no options for this in the UI. Or is there? Let’s check:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/01/image.png" rel="lightbox"><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="Cannot edit work items from changeset window" border="0" alt="Cannot edit work items from changeset window" src="http://kristofmattei.be/wp-content/uploads/2012/01/image_thumb.png" width="564" height="402"></a></p>
<p>Ok, so not through the changeset UI.</p>
<p>Let’s check the <a href="http://msdn.microsoft.com/en-us/library/w51xa47k(v=VS.100).aspx" target="_blank">command line</a>.</p>
<pre>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC&gt;tf changeset /?
TF - Team Foundation Version Control Tool, Version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Displays information about a changeset and lets you change the associated
attributes, such as comments and check-in notes.

tf changeset <strong>[/comment:("comment"|@commentfile)]</strong>
             <strong>[/notes:("NoteFieldName"="NoteFieldValue"|@notefile)]</strong> [/noprompt]
             [/collection:TeamProjectCollectionUrl]
             [changesetnumber | /latest] [/login:username,[password]]</pre>
<p>(emphasis mine).</p>
<p>So not through the command line. Now what? Let’s think: we want to associate a changeset with a work item. Why not look the other way around? </p>
<p>After the successful commit remember the changeset # (in our example 25464), go to the work item you want to associate the changeset to.</p>
<p>Right bottom you’ll see a tab called ‘Links’ (1), click it, and then click the ‘Link to’ (2) button.</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/01/associate.png" rel="lightbox"><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="Associate work item with changeset" border="0" alt="Associate work item with changeset" src="http://kristofmattei.be/wp-content/uploads/2012/01/associate_thumb.png" width="961" height="727"></a></p>
<p>In the next window, select ‘Changeset’ (1) and enter the number in the box (2). Hit&nbsp; ‘OK’ (3).</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/01/link.png" rel="lightbox"><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="Associate part II" border="0" alt="Associate part II" src="http://kristofmattei.be/wp-content/uploads/2012/01/link_thumb.png" width="561" height="275"></a></p>
<p>After that hit ‘CTR+S’ to save your work item.</p>
<p>After that go back to your changeset:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2012/01/its-there.png" rel="lightbox"><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="It's there!" border="0" alt="It's there!" src="http://kristofmattei.be/wp-content/uploads/2012/01/its-there_thumb.png" width="564" height="402"></a></p>
<p>It works!</p>
<p>Have a good one!</p>
<p>-Kristof</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2012/01/09/team-foundation-2010-associate-work-item-with-changeset-after-check-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight 4: Bug in TabControl.TabStripPlacement = Dock.Left and OnApplyTemplate</title>
		<link>http://kristofmattei.be/2011/09/12/silverlight-4-bug-in-tabcontrol-tabstripplacement-dock-left-and-onapplytemplate/</link>
		<comments>http://kristofmattei.be/2011/09/12/silverlight-4-bug-in-tabcontrol-tabstripplacement-dock-left-and-onapplytemplate/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 23:42:45 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Various]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=1103</guid>
		<description><![CDATA[At work I ran into a bug with the Silverlight TabControl, more specifically when setting the TabStripPlacement to Dock.Left and hiding one of the TabItems in the parent’s OnApplyTemplate. The way to get to this bug is quite specific. For &#8230; <a href="http://kristofmattei.be/2011/09/12/silverlight-4-bug-in-tabcontrol-tabstripplacement-dock-left-and-onapplytemplate/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>At work I ran into a bug with the Silverlight <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol(v=VS.95).aspx">TabControl</a>, more specifically when setting the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol.tabstripplacement(v=VS.95).aspx">TabStripPlacement</a> to <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.dock(v=VS.95).aspx#Y0">Dock.Left</a> and hiding one of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.tabitem(v=VS.95).aspx">TabItems</a> in the parent’s <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.onapplytemplate(v=vs.95).aspx">OnApplyTemplate</a>.</p>
<p>The way to get to this bug is quite specific. For example, you can’t do it when you’re using a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.usercontrol(v=VS.95).aspx">UserControl</a>, since in that kind of class OnApplyTemplate is <a href="http://forums.silverlight.net/p/14765/48752.aspx">never called</a>.</p>
<p>You need to build a class which inherits from <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.control(v=VS.95).aspx">Control</a>.</p>
<pre class="code"><span style="color: blue;">public class </span><span style="color: #2b91af;">TabControlTest </span>: <span style="color: #2b91af;">Control</span></pre>
<p>Then we have the style of this particular class:</p>
<pre class="code"><span style="color: blue;">&lt;</span><span style="color: #a31515;">Style </span><span style="color: red;">TargetType</span><span style="color: blue;">="TabControlTest:TabControlTest"&gt; &lt;</span><span style="color: #a31515;">Setter </span><span style="color: red;">Property</span><span style="color: blue;">="Template"&gt; &lt;</span><span style="color: #a31515;">Setter.Value</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">ControlTemplate </span><span style="color: red;">TargetType</span><span style="color: blue;">="TabControlTest:TabControlTest"&gt; &lt;</span><span style="color: #a31515;">Grid </span><span style="color: red;">x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">="LayoutRoot" </span><span style="color: red;">Background</span><span style="color: blue;">="White"&gt; &lt;</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">="*" /&gt; &lt;</span><span style="color: #a31515;">RowDefinition </span><span style="color: red;">Height</span><span style="color: blue;">="38" /&gt; &lt;/</span><span style="color: #a31515;">Grid.RowDefinitions</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabControl </span><span style="color: red;">TabStripPlacement</span><span style="color: blue;">="{</span><span style="color: #a31515;">TemplateBinding </span><span style="color: red;">TabStripPlacement</span><span style="color: blue;">}" </span><span style="color: red;">Grid.Row</span><span style="color: blue;">="0"&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem </span><span style="color: red;">Header</span><span style="color: blue;">="First"&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">TextBlock </span><span style="color: red;">Text</span><span style="color: blue;">="A" /&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem </span><span style="color: red;">Header</span><span style="color: blue;">="Second" </span><span style="color: red;">x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">="middleTabItem"&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">TextBlock </span><span style="color: red;">Text</span><span style="color: blue;">="B" /&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem </span><span style="color: red;">Header</span><span style="color: blue;">="Last"&gt; &lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">TextBlock </span><span style="color: red;">Text</span><span style="color: blue;">="C" /&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem.Content</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabItem</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabControl</span><span style="color: blue;">&gt; &lt;</span><span style="color: #a31515;">Button </span><span style="color: red;">HorizontalAlignment</span><span style="color: blue;">="Center" </span><span style="color: red;">Grid.Row</span><span style="color: blue;">="1" </span><span style="color: red;">Content</span><span style="color: blue;">="{</span><span style="color: #a31515;">TemplateBinding </span><span style="color: red;">ShowOrHide</span><span style="color: blue;">}" </span><span style="color: red;">Command</span><span style="color: blue;">="{</span><span style="color: #a31515;">TemplateBinding </span><span style="color: red;">ShowOrHideCommand</span><span style="color: blue;">}" /&gt; &lt;/</span><span style="color: #a31515;">Grid</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">ControlTemplate</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">Setter.Value</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">Setter</span><span style="color: blue;">&gt; &lt;/</span><span style="color: #a31515;">Style</span><span style="color: blue;">&gt;</span></pre>
<p>As you can see I’ve named the middle TabItem (“middleTabItem”) so I can retrieve it in the OnApplyTemplate:</p>
<pre class="code"><span style="color: blue;">public override void </span>OnApplyTemplate()
{
    <span style="color: blue;">this</span>._middleTabItem = (<span style="color: #2b91af;">TabItem</span>) <span style="color: blue;">this</span>.GetTemplateChild(<span style="color: #a31515;">"middleTabItem"</span>);
    <span style="color: blue;">this</span>._middleTabItem.Visibility = <span style="color: #2b91af;">Visibility</span>.Collapsed;

    <span style="color: blue;">base</span>.OnApplyTemplate();
}</pre>
<p>Now if the following 2 conditions are matched:</p>
<ol>
<li><strong>TabStripPlacement is set to Dock.Left </strong>(it doesn’t happen on ‘Top’)</li>
<li>We set the <a href="http://msdn.microsoft.com/en-us/library/system.windows.visibility(v=VS.95).aspx">Visibility</a> of the said TabItem to Collapsed in the OnApplyTemplate of the surrounding Control</li>
</ol>
<p>Then we cannot make the TabItem Visible anymore.</p>
<p>To show or hide I use the following code:</p>
<pre class="code"><span style="color: blue;">this</span>.ShowOrHideCommand = <span style="color: blue;">new </span><span style="color: #2b91af;">Command</span>(() =&gt;
                                         {
                                            <span style="color: blue;">this</span>.ShowOrHideText = <span style="color: blue;">string</span>.Format(SwitchTo, <span style="color: blue;">this</span>._middleTabItem.Visibility);
                                            <span style="color: blue;">this</span>._middleTabItem.Visibility = <span style="color: blue;">this</span>._middleTabItem.Visibility == <span style="color: #2b91af;">Visibility</span>.Visible ? <span style="color: #2b91af;">Visibility</span>.Collapsed : <span style="color: #2b91af;">Visibility</span>.Visible;
                                         });</pre>
<p>The solution to this is to call the OnApplyTemplate of the TabControl itself so that it recalculates it’s children’s location (or something, I’m not sure):</p>
<p>Give the TabControl a name, fetch it in OnApplyTemplate of your Control:</p>
<pre class="code"><span style="color: blue;">&lt;</span><span style="color: #a31515;">sdk</span><span style="color: blue;">:</span><span style="color: #a31515;">TabControl </span><span style="color: red;">TabStripPlacement</span><span style="color: blue;">="{</span><span style="color: #a31515;">TemplateBinding </span><span style="color: red;">TabStripPlacement</span><span style="color: blue;">}" </span><span style="color: red;">x</span><span style="color: blue;">:</span><span style="color: red;">Name</span><span style="color: blue;">="TabControl" </span><span style="color: red;">Grid.Row</span><span style="color: blue;">="0"&gt;</span></pre>
<pre class="code"><span style="color: blue;">public override void </span>OnApplyTemplate()
{
    <span style="color: blue;">this</span>._middleTabItem = (<span style="color: #2b91af;">TabItem</span>) <span style="color: blue;">this</span>.GetTemplateChild(<span style="color: #a31515;">"middleTabItem"</span>);
    <span style="color: blue;">this</span>._middleTabItem.Visibility = <span style="color: #2b91af;">Visibility</span>.Collapsed;
    <span style="color: blue;">this</span>._tabControl = (<span style="color: #2b91af;">TabControl</span>) <span style="color: blue;">this</span>.GetTemplateChild(<span style="color: #a31515;">"TabControl"</span>);
    <span style="color: blue;">base</span>.OnApplyTemplate();
}</pre>
<p>And call the _tabControl’s OnApplyTemplate after switching the Visibility to Visible:</p>
<pre class="code"><span style="color: blue;">this</span>.ShowOrHideCommand = <span style="color: blue;">new </span><span style="color: #2b91af;">Command</span>(() =&gt;
                                         {
                                            <span style="color: blue;">this</span>.ShowOrHideText = <span style="color: blue;">string</span>.Format(SwitchTo, <span style="color: blue;">this</span>._middleTabItem.Visibility);
                                            <span style="color: blue;">this</span>._middleTabItem.Visibility = <span style="color: blue;">this</span>._middleTabItem.Visibility == <span style="color: #2b91af;">Visibility</span>.Visible ? <span style="color: #2b91af;">Visibility</span>.Collapsed : <span style="color: #2b91af;">Visibility</span>.Visible;
                                            <span style="color: blue;">this</span>._tabControl.OnApplyTemplate();
                                         });</pre>
<p>This will make the UI respond correctly. For your convenience I’ve added the SL project, and you can download it <a title="link to project" href="http://kristofmattei.be/wp-content/uploads/2011/09/TabControlTest.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2011/09/12/silverlight-4-bug-in-tabcontrol-tabstripplacement-dock-left-and-onapplytemplate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I won!</title>
		<link>http://kristofmattei.be/2011/06/30/i-won/</link>
		<comments>http://kristofmattei.be/2011/06/30/i-won/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 15:11:22 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Various]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/2011/06/30/i-won/</guid>
		<description><![CDATA[In reference to my last post: I won! YES! I’m going to Build! Anaheim, CA is in Germany. Right? Like Hanover is in England. Right?]]></description>
			<content:encoded><![CDATA[<p>In reference to my last <a href="http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/" target="_blank">post</a>: I won! YES! </p>
<p>I’m going to <a href="http://www.buildwindows.com" target="_blank">Build</a>!</p>
<p>Anaheim, CA is in Germany. Right? Like Hanover is in England. Right? </p>
<p><img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smilewithtongueout" alt="Smile with tongue out" src="http://kristofmattei.be/wp-content/uploads/2011/06/wlEmoticon-smilewithtongueout.png"></p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2011/06/30/i-won/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Community Day 2011: Win the ticket Build in Anaheim, CA!</title>
		<link>http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/</link>
		<comments>http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 10:11:00 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[Various]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/</guid>
		<description><![CDATA[On September 13th until September 16th Microsoft hosts the Build event in Anaheim California. You can find more information on www.buildwindows.com ! With this I hope to win the ticket to Build, here at Community Day 2011! It would be &#8230; <a href="http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On September 13th until September 16th Microsoft hosts the Build event in Anaheim California. You can find more information on <a href="http://www.buildwindows.com">www.buildwindows.com</a> !</p>
<p>With this I hope to win the ticket to Build, here at <a href="http://communityday.be/" target="_blank">Community Day 2011</a>! It would be awesome for me to get the first look at Windows 8! </p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/06/fdvjh.jpg" rel="lightbox"><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="Me and some Smurfs" border="0" alt="Me and some Smurfs" src="http://kristofmattei.be/wp-content/uploads/2011/06/fdvjh_thumb.jpg" width="244" height="183"></a></p>
<p>You can follow <a href="https://twitter.com/#!/search?q=%23bldwin">#bldwin</a> also on Twitter! </p>
<p>Stay tuned and thumbs up for me! (please <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-openmouthedsmile" alt="Open-mouthed smile" src="http://kristofmattei.be/wp-content/uploads/2011/06/wlEmoticon-openmouthedsmile.png">)</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2011/06/23/community-day-2011-win-the-ticket-build-in-anaheim-ca/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clear all event logs on Windows using PowerShell</title>
		<link>http://kristofmattei.be/2011/06/14/clear-all-event-logs-on-windows-using-powershell/</link>
		<comments>http://kristofmattei.be/2011/06/14/clear-all-event-logs-on-windows-using-powershell/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 12:16:34 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[7]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Various]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/?p=932</guid>
		<description><![CDATA[I was bored with the vast amount of data in the eventlogs which were really not useful for me. So, in order to improve readability on my machine I decided to look for something to clear all of the eventlogs. &#8230; <a href="http://kristofmattei.be/2011/06/14/clear-all-event-logs-on-windows-using-powershell/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was bored with the vast amount of data in the eventlogs which were really not useful for me. So, in order to improve readability on my machine I decided to look for something to clear all of the eventlogs. Easy.</p>
<p>Since I always use the Administrative Events filter to view every warning and error I get a lot of junk (who cares for Kernel-Power warnings?)</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/06/all-errors.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Administrative Events" border="0" alt="Administrative Events" src="http://kristofmattei.be/wp-content/uploads/2011/06/all-errors_thumb.png" width="238" height="244"></a></p>
<p>Since I didn&#8217;t feel like doing the following steps for each frigging event log there is on my machine. You would need to go to the following steps:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/06/step_1.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Step 1" border="0" alt="Step 1" src="http://kristofmattei.be/wp-content/uploads/2011/06/step_1_thumb.png" width="236" height="328"></a></p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/06/step_2.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Step 2" border="0" alt="Step 2" src="http://kristofmattei.be/wp-content/uploads/2011/06/step_2_thumb.png" width="430" height="93"></a></p>
<p>Now this is an excerpt&nbsp; from the eventlogs I have on this machine:</p>
<pre>Analytic
Application
DirectShowFilterGraph
DirectShowPluginControl
EndpointMapper
ForwardedEvents
HardwareEvents
Internet Explorer
Key Management Service
MF_MediaFoundationDeviceProxy
MediaFoundationDeviceProxy
MediaFoundationPerformance
MediaFoundationPipeline
MediaFoundationPlatform
Microsoft-IE/Diagnostic
Microsoft-IEDVTOOL/Diagnostic
Microsoft-IEFRAME/Diagnostic
Microsoft-IIS-Configuration/Administrative
Microsoft-IIS-Configuration/Analytic
Microsoft-IIS-Configuration/Debug
Microsoft-IIS-Configuration/Operational
Microsoft-PerfTrack-IEFRAME/Diagnostic
Microsoft-PerfTrack-MSHTML/Diagnostic
Microsoft-Windows-ADSI/Debug
Microsoft-Windows-API-Tracing/Operational
Microsoft-Windows-ATAPort/General
Microsoft-Windows-ATAPort/SATA-LPM
Microsoft-Windows-ActionQueue/Analytic
Microsoft-Windows-AltTab/Diagnostic
Microsoft-Windows-AppID/Operational
Microsoft-Windows-AppLocker/EXE and DLL
Microsoft-Windows-AppLocker/MSI and Script
Microsoft-Windows-Application Server-Applications/Admin
Microsoft-Windows-Application Server-Applications/Analytic
Microsoft-Windows-Application Server-Applications/Debug</pre>
<p>And so on (for about 10 times as large). I’m not going to clear them by hand.</p>
<p>So let’s call Powershell to the rescue! (Play Thunderbirds theme song!)</p>
<p>First of all (and nothing to do with Powershell): <a href="http://technet.microsoft.com/en-us/library/cc732848(WS.10).aspx" target="_blank">wevtutil</a></p>
<p>We’re going to use this tool to display every available event source on this machine:</p>
<pre>wevtutil el</pre>
<p>The help states:
<pre>el | enum-logs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List log names.</pre>
<p>Good, that’s what we need. Next up, we pass every line of this list to a command using a pipe and the Powershell <a href="http://technet.microsoft.com/en-us/library/dd347608.aspx" target="_blank">Foreach-Object</a> cmdlet</p>
<pre>wevtutil el | Foreach-Object { … commands go here … }</pre>
<p>The commands are going to be</p>
<pre>wevtutil cl “$_”</pre>
<p>The help states:
<pre>cl | clear-log&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Clear a log.</pre>
<p>And <abbr title="Within the script block, the current input object is represented by the $_ variable.">$_</abbr> is the current variable in the enumeration of Foreach-Object. I added the quotes since there are event sources with spaces and we need to have the full name in order to have wevtutil to be able to clear that log.</p>
<p>Now let’s add some diagnostics output to see which one we’re currently clearing:</p>
<pre>wevtutil el | Foreach-Object {Write-Host "Clearing $_"; wevtutil cl "$_"}</pre>
<p>Now just run it through Powershell, and bam, a clean event log.</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/06/image.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Result" border="0" alt="Result" src="http://kristofmattei.be/wp-content/uploads/2011/06/image_thumb.png" width="353" height="242"></a></p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2011/06/14/clear-all-event-logs-on-windows-using-powershell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 SP1: DebuggerTypeProxy works again! *yay*</title>
		<link>http://kristofmattei.be/2011/03/20/visual-studio-2010-sp1-debuggertypeproxy-works-again-yay/</link>
		<comments>http://kristofmattei.be/2011/03/20/visual-studio-2010-sp1-debuggertypeproxy-works-again-yay/#comments</comments>
		<pubDate>Sun, 20 Mar 2011 16:43:43 +0000</pubDate>
		<dc:creator>Kristof</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://kristofmattei.be/2011/03/20/visual-studio-2010-sp1-debuggertypeproxy-works-again-yay/</guid>
		<description><![CDATA[A while ago I bumped into a bug in Visual Studio 2010 + Silverlight 4. While working with a List / Dictionary / … it didn’t show the items in the list, instead it showed the normal ‘raw view’: As &#8230; <a href="http://kristofmattei.be/2011/03/20/visual-studio-2010-sp1-debuggertypeproxy-works-again-yay/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while ago I bumped into a bug in Visual Studio 2010 + Silverlight 4. </p>
<p>While working with a List / Dictionary / … it didn’t show the items in the list, instead it showed the normal ‘raw view’:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/03/silverlight4Debug1.png" rel="lightbox"><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="No debug view" border="0" alt="No debug view" src="http://kristofmattei.be/wp-content/uploads/2011/03/silverlight4Debug1_thumb.png" width="244" height="77"></a></p>
<p>As you can see, there was no view to see the items.</p>
<p>What you would expect to see is this:</p>
<p><a href="http://kristofmattei.be/wp-content/uploads/2011/03/consoleDebug1.png" rel="lightbox"><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="DebugView!" border="0" alt="DebugView!" src="http://kristofmattei.be/wp-content/uploads/2011/03/consoleDebug1_thumb.png" width="244" height="78"></a></p>
<p>I reported the bug (many others did too!). The problem was that it was fixed in SL3, but not ported to SL4.</p>
<p>Now it’s fixed! This makes my work a lot easier. When we get SP1 @ work too that is!</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://kristofmattei.be/2011/03/20/visual-studio-2010-sp1-debuggertypeproxy-works-again-yay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.941 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-19 08:30:13 -->
<!-- Compression = gzip -->
