<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://bloggingabout.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Vagif Abilov's blog on .NET</title><link>http://bloggingabout.net/blogs/vagif/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>First look at NDepend 3.0</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/03/11/first-look-at-ndepend-3-0.aspx</link><pubDate>Thu, 11 Mar 2010 22:20:46 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482956</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482956</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482956</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/03/11/first-look-at-ndepend-3-0.aspx#comments</comments><description>&lt;p&gt;I installed to today the latest version of &lt;a href="http://www.ndepend.com/" target="_blank"&gt;NDepend&lt;/a&gt; and gave it a try. &lt;a href="http://bloggingabout.net/blogs/vagif/archive/2009/08/11/improving-code-quality-using-ndepend.aspx" target="_blank"&gt;Last time I blogged about NDepend&lt;/a&gt;, I used it on a small solution, and while the generated report was full of useful information, I did not use the product at full strength, because as it’s name suggests, NDepend is about analyzing dependencies, and my solution was too small for interesting observations. This time I plan to analyze a large solution consisting of all of our projects with an exception of a Web administration projects that are not so interesting for such analysis. The solution file was generated using a utility &lt;a href="http://bloggingabout.net/blogs/vagif/archive/2009/12/03/utility-to-generate-solution-files-can-now-create-solution-folders.aspx" target="_blank"&gt;described earlier&lt;/a&gt; and contains 140 projects. I never worked with such large solutions (usually I group projects in much smaller solutions), so I was a bit uncertain about how long it will take to load on my Dell D830 notebook. But it started up relatively quickly.&lt;/p&gt;  &lt;p&gt;The biggest news about NDepend 3.0 is that it is now fully integrated into Visual Studio development environment. So now all its menus and windows are parts of development session, and windows of course can be docked. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/8712.NDepend10_5F00_7015AC5A.png"&gt;&lt;img title="NDepend10" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="475" alt="NDepend10" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2117.NDepend10_5F00_thumb_5F00_3862F22A.png" width="758" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The very first impression from NDepend: it’s fast, blazingly fast. As you can see from the summary below, it used only 18 seconds to analyze 1188 source files in 140 projects of my solutions: 15 milliseconds on each file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2860.NDepend02_5F00_213777AC.png"&gt;&lt;img title="NDepend02" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="644" alt="NDepend02" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/6278.NDepend02_5F00_thumb_5F00_5C8ADD6A.png" width="618" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So these are the metrics for my large solution, though I disagree with one detail: the report states that the solution has only 1 attribute class. Yes, it has only one class with .NET Attribute as its immediate parent, but there are several other classes that derive from Attribute, but not directly. One class derives from TypeMock.DecoratorAttribute that inherits from Attritbute. In addition there are several classes inheriting from PostSharp.Laos.OnMethodBoundaryAspect, and walking its inheritance tree brings us to MulticastAttribute that inherits from Attribute. I believe all such classes should be classified as attribute classes (since this is how they are used).&lt;/p&gt;  &lt;p&gt;Enough with class attributes. I browsed the report and noticed that I’d like to change a few metrics’ parameters right away. For example, a list of too long type names included all types with names longer than 35 characters. While this seems to be a reasonable limit, some exclusions from such rule can also be reasonable. The top 10 entires in this list ended with either “Exception”, “Preset”, “Response” or “Request”. “Preset” is a suffix for a special category of classes that we use in tests, “Response”/”Request” are used in Web service communication, and “Exception” is of course a suffix for exceptions. I want to see classes with “really” long names, so how do I exclude these special classes from the rule?&lt;/p&gt;  &lt;p&gt;It appeared to be very easy. I displayed a CQL Query Explorer and double-clicked on the rule. NDepend displayed a CQL Query Edit window, and it was obvious what I had to do to customize the rule. Below is an updated query:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/1004.NDepend04_5F00_5EC76626.png"&gt;&lt;img title="NDepend04" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="336" alt="NDepend04" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3107.NDepend04_5F00_thumb_5F00_5A50E55F.png" width="500" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The simplicity of rule customization encouraged me to start inspecting other report’s details. One of the most important ones was the list of methods to refactor. And it also had to be customized. Because this is what I saw:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4401.NDepend05_5F00_19AE98F0.png"&gt;&lt;img title="NDepend05" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="344" alt="NDepend05" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4721.NDepend05_5F00_thumb_5F00_49D87464.png" width="837" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Firstly, I think the table will look more informative if it highlights the figures that violates the metrics. Otherwise you have to browse every column and compare its data with the values from the respective CQL query. But what deserves customization is that the top of the list is occupied by class constructors with number of parameters exceeding recommended maximum (5). Should an exception be made for constructors? I believe it should, at least these days, when developers tend to use IoC containers and compose large applications with constructor injection. But how do I specify constructor exclusion? Luckily, I didn’t even have to browse NDepend online documentation - NDepend supports intellisense.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/8875.NDepend08_5F00_52C806A3.png"&gt;&lt;img title="NDepend08" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="305" alt="NDepend08" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0143.NDepend08_5F00_thumb_5F00_674D5621.png" width="507" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Exclusion constructors from the query resulted in much more interesting list of methods (below). They are candidates for refactoring for different reasons: number of lines, number of IL instructions, netsing deptsh, number of variables, etc. Again, I would appreciate if offending figures were highlighted.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/1830.NDepend07_5F00_0285AF23.png"&gt;&lt;img title="NDepend07" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="646" alt="NDepend07" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0333.NDepend07_5F00_thumb_5F00_4FB5A8AE.png" width="765" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It took me just minutes to apply these customizations, and what’s most encouraging is that I did not have to read anything about what these metrics are and how to adjust them to fit my needs: everything is intuitive, with additional explanation text shown along the queries and reports. I need more time to interpret metrics&amp;#160; and diagrams related to dependencies – the solution is too big to give a simple picture. I leave it to a second look. To be continued…&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482956" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/NDepend/default.aspx">NDepend</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Solution/default.aspx">Solution</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>Using “yield” to enumerate endless sequence</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/03/11/using-yield-to-traverse-endless-sequence.aspx</link><pubDate>Thu, 11 Mar 2010 09:41:09 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482955</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482955</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482955</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/03/11/using-yield-to-traverse-endless-sequence.aspx#comments</comments><description>&lt;p&gt;Craig Andera in &lt;a href="http://www.pluralsight-training.net/community/blogs/craig/archive/2010/03/10/creating-a-lazy-enumeration-of-directory-descendants-in-c.aspx" target="_blank"&gt;his blog&lt;/a&gt; post showed yet another Fibonacci algorithm, this one with “yeild” operator.&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;private IEnumerable Fibonacci()
{
    yield return 0;
    yield return 1;

    int a = 0;
    int b = 1;
    while (true)
    {
        int temp = a + b;
        a = b;
        b = temp;
        yield return b;
    }
}&lt;/pre&gt;

&lt;p&gt;Now it&amp;#39;s possible to fetch Fibonacci numbers in this manner:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;static void Main(string[] args)
{
    foreach (int a in Fibonacci())
    {
        Console.Write(a);
        Console.Write(&amp;quot; more (y/n)?&amp;quot;);

        string more = Console.ReadLine();
        if (more.ToUpper() != &amp;quot;Y&amp;quot;)
            break;
    }
}&lt;/pre&gt;

&lt;p&gt;As you can see, code in Main procedure uses “foreach” statement, but the Fibonacci sequence is endless, so it can’t be populated in advance. Without “yield” we would have to create a temporary state variable (actually two: to store “a” and “b”) and pass them to a GetNextFibonacci that would produce a next number and return updated “a” and “b”. But with yield it’s possible to compute results on demand. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482955" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/yield/default.aspx">yield</category></item><item><title>NUnitForVS: integrating NUnit tests into Visual Studio</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/03/06/nunitforvs-integrating-nunit-tests-into-visual-studio.aspx</link><pubDate>Sat, 06 Mar 2010 20:23:45 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482927</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482927</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482927</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/03/06/nunitforvs-integrating-nunit-tests-into-visual-studio.aspx#comments</comments><description>&lt;p&gt;Roy Osherove &lt;a href="http://weblogs.asp.net/rosherove/archive/2010/03/05/nunit-vs-mstest-nunit-wins-for-unit-testing.aspx" target="_blank"&gt;listed advantages&lt;/a&gt; of NUnit over MsTest but also mentioned one MsTest’s strength that can be crucial for many developers: “the integration with other team system tools and reporting is just beyond compare and the reporting alone helps alot to find recurring breaking tests, code churn vs. new tests and others”. This reminded me about what I recently read in a book by Jeff McWherter and Ben Hall &lt;a href="http://www.testingaspnet.com/" target="_blank"&gt;Testing ASP.NET Web Applications&lt;/a&gt; where they said that forthcoming release of Visual Studio 2010 will make it possible to configure VS test runner to execute tests that use syntax different from MsTest.&lt;/p&gt;  &lt;p&gt;I am a faithful user of &lt;a href="http://www.testdriven.net/" target="_blank"&gt;TestDriven.Net&lt;/a&gt;, but I know that ability to use built-in Visual Studio test runner is an important factor that may affect the choice of unit test framework. So it would be nice to separate these decisions: selection of a unit test framework and selection of a test runner. I &lt;a href="http://social.msdn.microsoft.com/Forums/en-SG/vstsprerelease/thread/92da13df-0c4f-4212-be3b-cf1a9795a6ac" target="_blank"&gt;asked in Microsoft’s VS 2010 forum&lt;/a&gt; it new version of Visual Studio is really that flexible when it comes to configuring it’s test runner. Unfortunately not. Microsoft’s Euan Garden answered: “this was something we wanted to do in the release but never made it into the product.” However, Euan gave a couple of hints: Gallio and NUnit integration CodePlex project.&lt;/p&gt;  &lt;p&gt;I checked CodePlex and found &lt;a href="http://nunitforvs.codeplex.com/" target="_blank"&gt;NUnitForVS&lt;/a&gt;: NUnit integration for Visual Studio 2008. I downloaded an ran the installer and within 5 minutes was able to make Visual Studio development environment to treat NUnit tests as they were native MsTest. The only preparation (in addition to installing NUnitForVS) was to open test project file in a text editor and add the following entry to the first PropertyGroup:&lt;/p&gt;  &lt;p&gt;&amp;lt;ProjectTypeGuids&amp;gt;{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&amp;lt;/ProjectTypeGuids&amp;gt;&lt;/p&gt;  &lt;p&gt;This has to be done to &lt;em&gt;every&lt;/em&gt; test project that uses NUnit, but otherwise Visual Studio won’t be able to classify the project as a test project (why should it? – the only type of test projects that it natively recognizes is MsTest). After this change Visual Studio accepts NUnit tests, and you will see all your tests in the Test View window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/5270.NUnitForVS1_5F00_0D2E65EA.png"&gt;&lt;img title="NUnitForVS1" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="251" alt="NUnitForVS1" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0027.NUnitForVS1_5F00_thumb_5F00_2EAD9579.png" width="299" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So far so good. Next checkpoint is to run and debug some of these tests. This also works well and test results are displayed in a respective window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2425.NUnitForVS2_5F00_0A1C07F5.png"&gt;&lt;img title="NUnitForVS2" style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="254" alt="NUnitForVS2" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/6254.NUnitForVS2_5F00_thumb_5F00_17821AFB.png" width="594" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Note the very last test in this list, the one that is called “Add(2,3,5)”. This is a parameterized test implemented using TestCase attribute:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;[TestCase(2, 3, 5)]
public void Add(int x, int y, int sum)
{
    Calculator calc = new Calculator();
    decimal result = calc.Add(x, y);
    Assert.AreEqual(sum, result, &amp;quot;Incorrect result&amp;quot;);
}&lt;/pre&gt;

&lt;p&gt;So using NUnitForVS we can exploit features of NUnit 2.5 that don’t exist in MsTest, and still Visual Studio correctly treats them. This is good news.&lt;/p&gt;

&lt;p&gt;When it comes to collecting code coverage, the situation is a little trickier. When I open code coverage window, I see not very encouraging message “Code Coverage is not enabled for this test run”:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3146.NUnitForVS3_5F00_2790E9B2.png"&gt;&lt;img title="NUnitForVS3" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="129" alt="NUnitForVS3" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/1234.NUnitForVS3_5F00_thumb_5F00_0709AA00.png" width="398" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Actually this is correct message: you have to explicitly enable code coverage instrumentation. But how? Apparently our solution sill lacks some piece, but luckily it’s easy to fix. All we need is to add a test configuration file with extension “testrunconfig”. Then we can activate its configuration and enable code coverage collection. One simple way to add such file is to add and then delete a test project to a solution (a “real” MsTest project). The MsTest project will be gone but will a trace in a form of test configuration file:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/6303.NUnitForVS4_5F00_348AC9C3.png"&gt;&lt;img title="NUnitForVS4" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="292" alt="NUnitForVS4" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3348.NUnitForVS4_5F00_thumb_5F00_49101941.png" width="328" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;If you now enable code coverage instrumentation for assemblies in your solution and rerun the tests, you will see the coverate summary:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3482.NUnitForVS5_5F00_1D5F4F45.png"&gt;&lt;img title="NUnitForVS5" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="242" alt="NUnitForVS5" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/5556.NUnitForVS5_5F00_thumb_5F00_3FB6E4BE.png" width="813" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Pretty useless, isn’t it? The summary displays coverage only for the test assembly and not for the actual code under test. Why?&lt;/p&gt;

&lt;p&gt;More googling, and the explanation came from Peter Stephen’s blog post: even though coverage instrumentation is enabled for all assemblies in our solution, one of assemblies was taken from a wrong place: the assembly under the test lies both in its own “bin” folder and in the “bin” folder of the test assembly, and it is there it has to be taken from. To resolve the problem you just need to add the assembly from a right place:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/5305.NUnitForVS6_5F00_28F79D35.png"&gt;&lt;img title="NUnitForVS6" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="471" alt="NUnitForVS6" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/8877.NUnitForVS6_5F00_thumb_5F00_288B6A40.png" width="642" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Note 2 copies of UnitTestDemo.dll. The unchecked one is the one that was added initially, the checked one was added manually. And everything works:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0317.NUnitForVS7_5F00_2AC7F2FC.png"&gt;&lt;img title="NUnitForVS7" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="717" alt="NUnitForVS7" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/8686.NUnitForVS7_5F00_thumb_5F00_5129D647.png" width="817" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Of course, I only tried NUnitForVS on a very simple project. I plan to check it out with more complex code. But so far it looks quite promising opening Visual Studio test runner for NUnit - the most popular unit test framework.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482927" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/unit+testing/default.aspx">unit testing</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/NUnit/default.aspx">NUnit</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/NUnitForVS/default.aspx">NUnitForVS</category></item><item><title>Fluent object construction</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/02/17/fluent-configuration.aspx</link><pubDate>Wed, 17 Feb 2010 12:13:59 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482846</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482846</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482846</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/02/17/fluent-configuration.aspx#comments</comments><description>&lt;p&gt;I like an idea to replace constructor overloads that take optional parameters with more fluent approach, so there will be less (and easier for understanding) constructor overloads and more readable code. Perhaps also more writeable.&lt;/p&gt;  &lt;p&gt;Let’s take an example, well-known StreamWriter. It has the following constructors:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;public StreamWriter(Stream stream);
public StreamWriter(string path);
public StreamWriter(Stream stream, Encoding encoding);
public StreamWriter(string path, bool append);
public StreamWriter(Stream stream, Encoding encoding, int bufferSize);
public StreamWriter(string path, bool append, Encoding encoding);
public StreamWriter(string path, bool append, Encoding encoding, int bufferSize);&lt;/pre&gt;

&lt;p&gt;Stream and path parameters are mutually exclusive and one of them must be sent to a constructor, other parameters (encoding, append and bufferSize) are optional, and append flag can only be used together with the path. There are in total 8 constructor overloads, and they don’t cover all possible valid combination: there is no overload that only takes path, encoding and bufferSize (you will have to send append flag too).&lt;/p&gt;

&lt;p&gt;What if this class had fewer constructors but provided additional methods to enrich stream writer setup? Like this:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;public class FluentStreamWriter
{
    public Encoding Encoding { get; private set; }
    public int BufferSize { get; private set; }

    public FluentStreamWriter(Stream stream) { }
    public FluentStreamWriter(string path) { }
    public FluentStreamWriter(string path, bool append) { }

    public FluentStreamWriter With(Encoding encoding, int bufferSize) { this.Encoding = encoding; this.BufferSize = bufferSize; return this; }
    public FluentStreamWriter WithEncoding(Encoding encoding) { this.Encoding = encoding; return this; }
    public FluentStreamWriter WithBufferSize(int bufferSize) { this.BufferSize = bufferSize; return this; }
}&lt;/pre&gt;

&lt;p&gt;And the code using classic and fluently constructed stream writer would look like this:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;var writer1 = new StreamWriter(&amp;quot;temp.txt&amp;quot;, false, Encoding.UTF8);
var writer2 = new StreamWriter(&amp;quot;temp.txt&amp;quot;, true, Encoding.UTF8, 1000);

var writer3 = new FluentStreamWriter(&amp;quot;temp.txt&amp;quot;).With(Encoding.UTF8, 1000);
var writer4 = new FluentStreamWriter(&amp;quot;temp.txt&amp;quot;).WithEncoding(Encoding.UTF8);
var writer5 = new FluentStreamWriter(&amp;quot;temp.txt&amp;quot;).WithEncoding(Encoding.UTF8).WithBufferSize(1000);&lt;/pre&gt;

&lt;p&gt;What I like in this approach is the separation between mandatory and optional set of constuctor arguments: what is sent to the constructor is mandatory (either individual parameters or set of mutually exclusive parameters). Everything that is optional may be added using methods prefixed with “With” that return the same class instance.&lt;/p&gt;

&lt;p&gt;The drawback of this approach is that since it moves some object construction options to custom methods, they can be overlooked by developers that are not aware of API style and may conclude that object construction possibilities are limited by the list of constructor overloads. So perhaps this approach is not suitable for a small API where fluent construction will be the only deviation from traditional type design style. But in large frameworks with fluent API style it can feel natural and be easily accepted.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482846" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/coding+guidelines/default.aspx">coding guidelines</category></item><item><title>Time to buy ReSharper?</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/01/19/time-to-buy-resharper.aspx</link><pubDate>Tue, 19 Jan 2010 14:32:20 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482713</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482713</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482713</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/01/19/time-to-buy-resharper.aspx#comments</comments><description>&lt;p&gt;Today I spent a few hours on mysterious error. One automated test failed, and since it was actually an integration test with complex setup, tracking down the failure was not easy. The problem that I’ve eventually found can be illustrated with a couple of tests:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;[Test]
public void BadClosureTest()
{
    int[] numbers = new int[]
    {
        1, 2, 3
    };

    List&amp;gt; functions = new List&amp;gt;();
    foreach (int n in numbers)
    {
        functions.Add(new Func(() =&amp;gt; n));
    }

    // Will fail on first assertion!
    Assert.That(functions[0].DynamicInvoke(), Is.EqualTo(1));
    Assert.That(functions[1].DynamicInvoke(), Is.EqualTo(2));
    Assert.That(functions[2].DynamicInvoke(), Is.EqualTo(3));
}

[Test]
public void GoodClosureTest()
{
    int[] numbers = new int[]
    {
        1, 2, 3
    };

    List&amp;gt; functions = new List&amp;gt;();
    foreach (int n in numbers)
    {
        int m = n;
        functions.Add(new Func(() =&amp;gt; m));
    }

    Assert.That(functions[0].DynamicInvoke(), Is.EqualTo(1));
    Assert.That(functions[1].DynamicInvoke(), Is.EqualTo(2));
    Assert.That(functions[2].DynamicInvoke(), Is.EqualTo(3));
}&lt;/pre&gt;

&lt;p&gt;As you can see, the only difference between these tests is a line in the second test assigning iterator “n” to a variable “m” defined within the “foreach” scope. Why does this matter?&lt;/p&gt;

&lt;p&gt;Well, for us, procedural languages veterans the difference may be not so obvious at first glance. But if you happen to have ReSharper, it will immediately give you a warning about the first test: “Access to modified closure”. And will suggest to copy “n” to a local variable. I didn’t have ReSharper, so I came to the same conclusion in a hard way.&lt;/p&gt;

&lt;p&gt;A lambda-expression “() =&amp;gt; n” is not just a delegate – it’s a closure. It uses a variable that is defined outside its scope. Such variables are always treated by reference, even though they may be of a value type. So as long as the variable “n” lives, any changes applied to it will affect every closure where it is referenced.&lt;/p&gt;

&lt;p&gt;And apparently ReSharper can warn us about improper use of closures.&lt;/p&gt;

&lt;p&gt;By the way, if instead of “foreach” test had a “for” loop with an index, the first test would fail with IndexOutOfRangeException. Because closures were accessed after the array elements are iterated and index would be set to 3.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482713" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/functional+programming/default.aspx">functional programming</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/ReSharper/default.aspx">ReSharper</category></item><item><title>Programmer’s calendar for 2010</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/01/19/programmer-s-calendar-for-2010.aspx</link><pubDate>Tue, 19 Jan 2010 13:46:23 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482712</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482712</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482712</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/01/19/programmer-s-calendar-for-2010.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4212.Calendar2010_5F00_7D147A87.png"&gt;&lt;img title="Calendar2010" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="462" alt="Calendar2010" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/4130.Calendar2010_5F00_thumb_5F00_2A2BF807.png" width="654" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Don’t know who made it, but holidays hint me that it comes from Russia.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482712" width="1" height="1"&gt;</description></item><item><title>WCF and large hierarchical data</title><link>http://bloggingabout.net/blogs/vagif/archive/2010/01/14/wcf-and-large-hierarchical-data.aspx</link><pubDate>Thu, 14 Jan 2010 18:44:03 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482693</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482693</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482693</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2010/01/14/wcf-and-large-hierarchical-data.aspx#comments</comments><description>&lt;p&gt;If you need to send large amount of information using a single WCF call, you will need to customize binding configuration that is by default tuned for efficient transfer of small messages. And if your data contracts happen to have types with circular (or self-) references, this behavior needs to be configured too. Here what I had to tweak in order to enable transfer of very large (up to 100 MB) collections of hierarchical data.&lt;/p&gt;  &lt;h3&gt;1. Binding configuration&lt;/h3&gt;  &lt;p&gt;The following binding attribute may need adjustments:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;maxBufferSize &lt;/li&gt;    &lt;li&gt;maxBufferPoolSize &lt;/li&gt;    &lt;li&gt;maxReceivedMessageSize &lt;/li&gt;    &lt;li&gt;openTimeout &lt;/li&gt;    &lt;li&gt;closeTimeout &lt;/li&gt;    &lt;li&gt;sendTimeout &lt;/li&gt;    &lt;li&gt;receiveTimeout &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Binding element has “readerQuotas” sub-element where the following attributes may be tweaked for large amount of data transfer:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;maxDepth &lt;/li&gt;    &lt;li&gt;maxStringContentLength &lt;/li&gt;    &lt;li&gt;maxArrayLength &lt;/li&gt;    &lt;li&gt;maxBytesPerRead &lt;/li&gt;    &lt;li&gt;maxNameTableCharCount      &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;In addition, transferMode can be set to either “Buffered” or “Streamed” depending on how data should be received by the client.&lt;/p&gt;  &lt;h3&gt;2. Behavior configuration&lt;/h3&gt;  &lt;p&gt;In case large amount of data are sent as standard collections (arrays, lists etc.), no behavior customization is needed in order to increase data transfer limits. But if the data represent more complex topology, there is an additional attribute to adjust, and this attribute belongs to behavior, not binding. It is called “maxItemsInObjectGraph” and can be specified either on serviceBehavior or endpointBehavior level. The customize behaviors element may look like this:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;&amp;lt;behaviors&amp;gt;
	&amp;lt;servicebehaviors&amp;gt;
		&amp;lt;behavior name=&amp;quot;LargeTreeBehavior&amp;quot;&amp;gt;
			&amp;lt;servicedebug includeexceptiondetailinfaults=&amp;quot;true&amp;quot; /&amp;gt;
			&amp;lt;datacontractserializer maxitemsinobjectgraph=&amp;quot;2147483647&amp;quot; /&amp;gt;
		&amp;lt;/behavior&amp;gt;
	&amp;lt;/servicebehaviors&amp;gt;
	&amp;lt;endpointbehaviors&amp;gt;
		&amp;lt;behavior name=&amp;quot;HighlightBehaviorLarge&amp;quot;&amp;gt;
			&amp;lt;datacontractserializer maxitemsinobjectgraph=&amp;quot;2147483647&amp;quot; /&amp;gt;
		&amp;lt;/behavior&amp;gt;
	&amp;lt;/endpointbehaviors&amp;gt;
&amp;lt;/behaviors&amp;gt;&lt;/pre&gt;

&lt;h3&gt;3. Serialization of object graphs with circular references&lt;/h3&gt;

&lt;p&gt;.NET 3.5 SP1 introduced a new attribute IsReference that can be used with DataContracts to enable serialization of object graphs with circular references. Previously it was not possible without writing custom code. Now it requires only a single attribute specification:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;[DataContract(IsReference = true)]
public class Node
{
	[DataMember]
	Node Parent { get; set; }
	....
}&lt;/pre&gt;

&lt;p&gt;That should be it. Now you can send graphs with millions of nodes over the wire using WCF. In may cases sending so much data in a single call is not a good idea, but that’s another topic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482693" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/WCF/default.aspx">WCF</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/serialization/default.aspx">serialization</category></item><item><title>When NUnit stops working on a build machine…</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/12/10/when-nunit-stops-working-on-a-build-machine.aspx</link><pubDate>Thu, 10 Dec 2009 12:13:58 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482574</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482574</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482574</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/12/10/when-nunit-stops-working-on-a-build-machine.aspx#comments</comments><description>&lt;p&gt;… then it’s time to check the registry entries. Make sure you see something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3157.NUnitRegistry_5F00_1300746A.png"&gt;&lt;img title="NUnitRegistry" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="173" alt="NUnitRegistry" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2465.NUnitRegistry_5F00_thumb_5F00_7C412CE0.png" width="372" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In case the build runs in the context of a dedicated user, not the one who logs on to a build machine and install applications, then it is likely that the build user does not have correct setup for NUnit assemblies. You can of course import missing registry entries into that user registry part, but the best is just to create them for everyone under LOCAL_MACHINE folder using path &lt;span style="font-size:10pt;font-family:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;"&gt;\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFolderEx.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482574" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/unit+testing/default.aspx">unit testing</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/registry/default.aspx">registry</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/NUnit/default.aspx">NUnit</category></item><item><title>Utility to generate solution files can now create solution folders</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/12/03/utility-to-generate-solution-files-can-now-create-solution-folders.aspx</link><pubDate>Thu, 03 Dec 2009 10:10:00 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482534</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482534</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482534</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/12/03/utility-to-generate-solution-files-can-now-create-solution-folders.aspx#comments</comments><description>&lt;p&gt;If somebody wants more from the program you wrote, it&amp;rsquo;s a good sign. It means that at last you did something useful :-)&lt;/p&gt;
&lt;p&gt;Recently my colleague mentioned that the &lt;a href="http://bloggingabout.net/blogs/vagif/archive/2009/08/04/utility-to-generate-visual-studio-solution-file-for-a-group-of-projects.aspx" target="_blank"&gt;utility that I wrote to generate project solution file&lt;/a&gt; should support creation of solution folders. Our development team has in total more than 200 projects, and grouping them within the solution makes a lot of sense.&lt;/p&gt;
&lt;p&gt;So I extended the tool, and you can specify number of solution folder levels using &amp;ldquo;/l&amp;rdquo; command line switch.&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:xx-small;font-family:courier;"&gt;&lt;span style="font-size:xx-small;"&gt;GenerateSolutionFile /p &amp;lt;path&amp;gt; /s &amp;lt;solution&amp;gt; [/i includeFilter] [/e excludeFilter] [/l [*]solutionFolderLevels]&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;You can specify solution folder levels using an integer number &amp;ndash; project names will be split using &amp;ldquo;.&amp;rdquo; as separator, and resulting words will be used as solution folder names. Since it&amp;rsquo;s a good practice to start project name with a name of the company that won&amp;rsquo;t be useful as a solution folder, it&amp;rsquo;s possible to skip common project prefix by using an asterisk letter in front of the number specifying the number of levels.&lt;/p&gt;
&lt;p&gt;Here are a few examples. If you generate solution file without instructing the tool to create solution folders, you will get a flat structure of projects:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/6254.Folders1_5F00_6B19FD47.png"&gt;&lt;img title="Folders1" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" alt="Folders1" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/1638.Folders1_5F00_thumb_5F00_02480877.png" width="207" border="0" height="95" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-size:xx-small;font-family:courier;"&gt;&lt;span style="font-size:xx-small;"&gt;&lt;span style="font-family:Tahoma;font-size:x-small;"&gt;If you add a command line switch &amp;ldquo;/l 1&amp;rdquo;, then the program will extract a first word from compound project names and create a root solution folder:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2313.Folders2_5F00_56973E7A.png"&gt;&lt;img title="Folders2" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" alt="Folders2" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0486.Folders2_5F00_thumb_5F00_3D2F3B40.png" width="227" border="0" height="116" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;You can add number of levels with &amp;ldquo;/l 2&amp;rdquo; switch:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/5381.Folders3_5F00_51B48ABE.png"&gt;&lt;img title="Folders3" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" alt="Folders3" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/2860.Folders3_5F00_thumb_5F00_6639DA3C.png" width="244" border="0" height="125" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;To skip &amp;ldquo;MyCompany&amp;rdquo; from solution folder tree add an asterisk when specifying number of folder levels: &amp;ldquo;/l *1&amp;rdquo;:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/1778.Folders4_5F00_1A6E0383.png"&gt;&lt;img title="Folders4" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" alt="Folders4" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3056.Folders4_5F00_thumb_5F00_680A3003.png" width="228" border="0" height="113" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;And of course you can increase number of levels, here&amp;rsquo;s how it looks when using &amp;ldquo;/l *2&amp;rdquo; switch:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/3617.Folders5_5F00_4EA22CC9.png"&gt;&lt;img title="Folders5" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" alt="Folders5" src="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/vagif.metablogapi/0724.Folders5_5F00_thumb_5F00_7C234C8C.png" width="244" border="0" height="159" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482534" width="1" height="1"&gt;</description><enclosure url="http://bloggingabout.net/cfs-file.ashx/__key/CommunityServer.Components.PostAttachments/00.00.48.25.34/GenerateSolutionFile.zip" length="11757" type="application/x-zip" /><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Solution/default.aspx">Solution</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>A danger of being too clever</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/11/10/a-danger-of-being-too-clever.aspx</link><pubDate>Tue, 10 Nov 2009 14:34:04 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482438</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482438</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482438</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/11/10/a-danger-of-being-too-clever.aspx#comments</comments><description>&lt;p&gt;A friend of mine applied for a job and received a test task to write an application that should be using a singleton. He decided to follow the fourth approach among the ones listed &lt;a href="http://www.yoda.arachsys.com/csharp/singleton.html" target="_blank"&gt;here&lt;/a&gt; (“not quite as lazy, but thread-safe without using locks”). I also think that this is most elegant although .NET-specific singleton implementation. Yes, it is not as lazy as other alternatives, but it is lock-free, and I’d always go for minimalistic code first and make it more complex later based on additional requirements.&lt;/p&gt;  &lt;p&gt;Unfortunately, my friend’s suggestion has been rejected. And one of the reasons: “not thread-safe singleton”. I guess the guy who verified the code was looking for locks and refused to believe that code can be made thread-safe without using them. The suggested solution was just too clever for him.&lt;/p&gt;  &lt;p&gt;So my friend was not hired, but I said to him that he should not regret. I am not sure I’d personally enjoy working for somebody so fixated on his own decisions. Still there may be a lesson learned from such failure. Perhaps when presenting our solutions to others we should evaluate if they can be unexpected for those who is going to review them, and in case of such risk add a brief explanation about why we made our choice and what other alternatives could be considered.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482438" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/singleton/default.aspx">singleton</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/threading/default.aspx">threading</category></item><item><title>Expression tree serialization</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/10/29/expression-tree-serialization.aspx</link><pubDate>Thu, 29 Oct 2009 20:16:30 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482394</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482394</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482394</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/10/29/expression-tree-serialization.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://reverseblade.blogspot.com/2008/11/how-to-serialize-lambda-expressions.html" target="_blank"&gt;Serializing lambda expressions&lt;/a&gt; using &lt;a href="http://www.codeplex.com/metalinq" target="_blank"&gt;MetaLinq&lt;/a&gt;, by Onur Gumus.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://metastatic.org/text/Concern/2008/03/08/remoting-lambda-expressions/" target="_blank"&gt;Remoting lambda expressions&lt;/a&gt;, by Casey Marshall.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://code.msdn.microsoft.com/exprserialization" target="_blank"&gt;Expression tree serialization&lt;/a&gt; project.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482394" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/lambda/default.aspx">lambda</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/serialization/default.aspx">serialization</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/functional+programming/default.aspx">functional programming</category></item><item><title>Selecting IoC framework</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/10/27/selecting-ioc-framework.aspx</link><pubDate>Tue, 27 Oct 2009 09:10:04 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482378</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482378</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482378</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/10/27/selecting-ioc-framework.aspx#comments</comments><description>&lt;p&gt;No, I haven’t chosen one to use yet. But I kind of feel that instead of investing more time in home-made and fairly inefficient DI classes, I should rewire the code to use one of the available IoC frameworks. And here are some blog posts that can help to make a choice.&lt;/p&gt;  &lt;p&gt;Comparing .NET DI (IoC) Frameworks (&lt;a href="http://blog.ashmind.com/index.php/2008/08/19/comparing-net-di-ioc-frameworks-part-1/" target="_blank"&gt;part1&lt;/a&gt; and &lt;a href="http://blog.ashmind.com/index.php/2008/09/08/comparing-net-di-ioc-frameworks-part-2/" target="_blank"&gt;part2&lt;/a&gt;) by Andrey Shchekin. Very good comparison with source code uploaded to &lt;a href="http://code.google.com/p/net-ioc-frameworks/" target="_blank"&gt;Google Code&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://elegantcode.com/2009/01/07/ioc-libraries-compared/" target="_blank"&gt;IoC libraries compared&lt;/a&gt; by Chirs Brandsma. Focuses on most common case - constructor injection. Source code is &lt;a href="https://cid-b0ed6c076f2f2bfe.skydrive.live.com/self.aspx/Public/IocDemo.zip" target="_blank"&gt;also available&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Having read these two posts, I’d probably go with either StructureMap or Autofac. But I would also like to have a closer look at MEF that was not covered in these blog posts (I guess because it’s not a pure IoC container). &lt;a href="http://ayende.com/Blog/archive/2008/09/25/the-managed-extensibility-framework.aspx" target="_blank"&gt;Here’s&lt;/a&gt; an excellent Ayende’s post explaining why.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482378" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Dependency+injection/default.aspx">Dependency injection</category></item><item><title>.NET mocking framework comparison</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/10/14/net-mocking-framework-comparison.aspx</link><pubDate>Wed, 14 Oct 2009 14:03:21 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482325</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482325</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482325</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/10/14/net-mocking-framework-comparison.aspx#comments</comments><description>&lt;p&gt;A couple of good sources for those who need to decide:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.phpvs.net/2009/04/25/net-mocking-frameworks-capability-comparison/" target="_blank"&gt;Capability comparison&lt;/a&gt; made by &lt;span class="Apple-style-span" style="word-spacing:0px;font:medium &amp;#39;Times New Roman&amp;#39;;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;span class="Apple-style-span" style="font-size:12px;line-height:18px;font-family:verdana, tahoma, arial, serif;"&gt;Morgan Soley. Half year old but with a feature comparison table.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;font:medium &amp;#39;Times New Roman&amp;#39;;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;span class="Apple-style-span" style="font-size:12px;line-height:18px;font-family:verdana, tahoma, arial, serif;"&gt;&lt;a href="http://codevanced.net/post/Mocking-frameworks-comparison.aspx" target="_blank"&gt;Recently updated comparison&lt;/a&gt; by Andrew Kazyrevich.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;font:medium &amp;#39;Times New Roman&amp;#39;;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;span class="Apple-style-span" style="font-size:12px;line-height:18px;font-family:verdana, tahoma, arial, serif;"&gt;TypeMock Isolator is a clear winner if it fits in your budget. Otherwise Rhino Mocks or Moq seem to be the most mature frameworks. According to a &lt;a href="http://weblogs.asp.net/rosherove/archive/2009/09/30/poll-which-mocking-isolation-framework-do-you-use.aspx" target="_blank"&gt;recent Roy Osherove’s pole&lt;/a&gt; they are in the lead with Rhino Mocks having 47% and Moq on second place with 34%. If I had to choose a free mocking framework today, I’d probably go with Moq because of Rhino Mocks’ confusing “very large array of syntaxes”. Or wait for Rhino Mocks 4.0 that will be radically simplified and, like Isolator, will go for AAA abd single “fake” concept.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span class="Apple-style-span" style="word-spacing:0px;font:medium &amp;#39;Times New Roman&amp;#39;;text-transform:none;text-indent:0px;white-space:normal;letter-spacing:normal;border-collapse:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0px;"&gt;&lt;span class="Apple-style-span" style="font-size:12px;line-height:18px;font-family:verdana, tahoma, arial, serif;"&gt;But for mocking without severe limitations there is no alternative to Isolator. Still in the lead.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482325" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/TypeMock/default.aspx">TypeMock</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/unit+testing/default.aspx">unit testing</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/Isolator/default.aspx">Isolator</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/mocking/default.aspx">mocking</category></item><item><title>Twitter Geek Quiz with TypeMock</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/10/13/twitter-geek-quiz-with-typemock.aspx</link><pubDate>Mon, 12 Oct 2009 23:04:57 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482309</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482309</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482309</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/10/13/twitter-geek-quiz-with-typemock.aspx#comments</comments><description>&lt;p&gt;I am kind of slow with adoption of communication channels. But motivation works sometimes. Perhaps Twitter Geek Quiz that TypeMock is arranging this Wednesday can help me retraining my Twitter skills.&lt;/p&gt;  &lt;p&gt;There will be prizes (from WiFi-detecting T-shirt to XBox), and to join is just to tweet any message with the quiz&amp;#39;s hash tag – #GeekQuiz. Rules are listed &lt;a href="http://blog.typemock.com/2009/10/twitter-geek-quiz-show-off-your.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482309" width="1" height="1"&gt;</description></item><item><title>Functional programming for C# developers</title><link>http://bloggingabout.net/blogs/vagif/archive/2009/10/12/functional-programming-for-c-developers.aspx</link><pubDate>Mon, 12 Oct 2009 21:23:35 GMT</pubDate><guid isPermaLink="false">813b6dfd-644e-4573-a816-eebab56ba0d0:482307</guid><dc:creator>Vagif Abilov</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/rsscomments.aspx?PostID=482307</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://bloggingabout.net/blogs/vagif/commentapi.aspx?PostID=482307</wfw:comment><comments>http://bloggingabout.net/blogs/vagif/archive/2009/10/12/functional-programming-for-c-developers.aspx#comments</comments><description>&lt;p&gt;Latest &lt;a href="http://msdn.microsoft.com/en-us/magazine/ee309512.aspx" target="_blank"&gt;Jeremy Miller’s article in MSDN Magazine&lt;/a&gt; will be very helpful for C# developers who haven’t started yet exploring functional programming. What is good about this article is that it gives practical advices on how to inject some fairly small pieces of functional programming into existing C# code in order to make it better – for example by removing code duplicates.&lt;/p&gt;  &lt;p&gt;What seems to be radical for many C# developers is how functional programming handles blocks of code with variables that are not resolved within those blocks – &lt;a href="http://martinfowler.com/bliki/Closure.html" target="_blank"&gt;closures&lt;/a&gt;. A piece of code with variables defined somewhere else is traditionally viewed by programmers with background in procedural languages as an invalid construction that will cause a compiler error. But closures are fully supported now in C# (in form of anonymous delegates or lambda-expressions), and Jeremy’s article demonstrates advantages of using this technique to pass around code blocks as data.&lt;/p&gt;  &lt;p&gt;I think however that the example with ConnectedSystemConsumer could be presented somewhat simpler, without focus on Interface Segregation Principle. Here’s how the original class looks before refactoring:&lt;/p&gt;  &lt;pre class="brush: csharp;"&gt;class ConnectedSystemConsumer
{
    private readonly IConnectedResource _resource;

    public ConnectedSystemConsumer(IConnectedResource resource)
    {
        _resource = resource;
    }

    public void ManipulateConnectedResource()
    {
        try
        {
            // First, you have to open a connection
            _resource.Open();
            // Now, manipulate the connected system
            _resource.Update(buildUpdateMessage());
        }
        finally
        {
            _resource.Close();
        }
    }

    // The rest of the class is skipped
}&lt;/pre&gt;

&lt;p&gt;The article then introduces two new interfaces and one class: IResourceInvocation, IResource and Resource, where IResourceInvocation contains the “interesting” part of IConnectedResource (methods FetchData and Update) and IResource defines and Resource implements a single method Invoke that takes care of all ceremony stuff. While this helps splitting the original ConnectedSystemConsumer class into smaller logical blocks, for developer doing his first experiments with functional programming it may leave false impression that adding additional classes are required (or at least expected) steps to take advantage of functional programming in C# code. But the same effect can be achieved without adding new interfaces or classes, just by extracting all ceremony code in a separate method:&lt;/p&gt;

&lt;pre class="brush: csharp;"&gt;class ConnectedSystemConsumer
{
    private readonly IConnectedResource _resource;

    public ConnectedSystemConsumer(IConnectedResource resource)
    {
        _resource = resource;
    }

    public void ManipulateConnectedResource()
    {
        InvokeResource(x =&amp;gt;
        {
            x.Update(buildUpdateMessage());
        });
    }

    private void InvokeResource(Action&amp;lt;IConnectedResource&amp;gt; action)
    {
        try
        {
            // First, you have to open a connection
            _resource.Open();
            // Now, manipulate the connected system
            action(_resource);
        }
        finally
        {
            _resource.Close();
        }
    }

    // The rest of the class is skipped
}&lt;/pre&gt;

&lt;p&gt;As you can see, ManipulateConnectedResource no longer contains ceremonial code that opens and closes resource and handles exceptions. This code is now moved to InvokeResource method that takes as an argument a block or a closure defined in ManipulateConnectedResource or any other method that requires the same ceremony.&lt;/p&gt;

&lt;p&gt;After reading Jeremy Miller’s article I browsed some of my old code and found several classes that can be simplified using the same approach. Perhaps at first they will not look simpler – functional programming style adoption requires some time. But they will become more compact, with less or without code repetition, and this alone is worth it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://bloggingabout.net/aggbug.aspx?PostID=482307" width="1" height="1"&gt;</description><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/lambda/default.aspx">lambda</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://bloggingabout.net/blogs/vagif/archive/tags/functional+programming/default.aspx">functional programming</category></item></channel></rss>