<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Dr. Random - Tools</title>
    <link>http://www.drrandom.org/</link>
    <description>Random Thoughts for Random People</description>
    <language>en-us</language>
    <copyright>Casey Kramer</copyright>
    <lastBuildDate>Mon, 07 Dec 2009 19:17:46 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>casey.kramer@gmail.com</managingEditor>
    <webMaster>casey.kramer@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.drrandom.org/Trackback.aspx?guid=ae83bded-50a9-4c93-85da-78a0da965f14</trackback:ping>
      <pingback:server>http://www.drrandom.org/pingback.aspx</pingback:server>
      <pingback:target>http://www.drrandom.org/PermaLink,guid,ae83bded-50a9-4c93-85da-78a0da965f14.aspx</pingback:target>
      <dc:creator>Casey Kramer</dc:creator>
      <wfw:comment>http://www.drrandom.org/CommentView,guid,ae83bded-50a9-4c93-85da-78a0da965f14.aspx</wfw:comment>
      <wfw:commentRss>http://www.drrandom.org/SyndicationService.asmx/GetEntryCommentsRss?guid=ae83bded-50a9-4c93-85da-78a0da965f14</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As of right about now, you should be able to mosey on over to the <a href="http://code.google.com/p/dxcorecommunityplugins/" target="_blank">DxCore
Community Plug-ins page</a>, and grab a copy of <a href="http://code.google.com/p/dxcorecommunityplugins/wiki/CR_MoveFile" target="_blank">CR_MoveFile</a>. 
This is a plug-in I created primarily as a tool to aid in working in a TDD environment,
but which certainly has uses for non-TDD applications.  It does basically what <a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/AnnouncingCR_MoveFileDxCorepluginformovi_8466/CR_MoveFile_ScreenShot_5.png"><img style="border-right-width: 0px; margin: 10px 0px 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CR_MoveFile_ScreenShot" border="0" alt="CR_MoveFile_ScreenShot" align="right" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/AnnouncingCR_MoveFileDxCorepluginformovi_8466/CR_MoveFile_ScreenShot_thumb_1.png" width="660" height="439" /></a>the
name suggests, it allows you to move a file from one directory in your solution/project
structure to another, even one in a different project.  I implemented this as
a code provider (since it could change the functionality if you move the file from
one project to another), so it will appear in the Code menu when you have the cursor
somewhere within the beginning blocks of a file (“using” sections, namespace declaration,
or class/interface/struct declarations).  Once selected you are presented with
a popup window which has a tree that represents your current solution structure, with
your current directory highlighted.  You can use the arrow keys to navigate the
directories and choose a new home for your file.
</p>
        <p>
If you move files between projects, the plug-in will create project references for
you, so you don’t need to worry about that.  When the file is moved the file
contents remain unchanged, so all namespaces will be the same as they were originally. 
I did this mostly to keep the plug-in simple, but also because I could see situations
where this would be good, and situations where this would be bad, and it seemed like
this was a bad choice to make for people.  I’ve been using this plug-in on a
day-to-day basis for a while now, and things seem pretty clean, I did run into a small
issue, however, using it within a solution that was under source control.  At
this point you need to make sure the project files effected by the move are checked
out, otherwise the plug-in goes through the motions, but doesn’t actually do anything,
which is quite annoying.  There is also no checking going on to make sure the
language is the same between the source and target project, so if you work on a solution
that contains C# <strong>and</strong> VB.Net projects, you have to be careful not
to move files around to projects that can’t understand what they are (oh, and the
project icons used on the tree view are all the same, so there is no visual indication
of what project contains what type of files).
</p>
        <p>
That’s pretty much it.  Clean, simple, basic.  Used with other existing
CodeRush/Refactor tools like “Move Type To File” and “Move to Namespace”, this provides
for some pretty powerful code re-organization.  Just make sure you run all of
your tests :).
</p>
        <img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=ae83bded-50a9-4c93-85da-78a0da965f14" />
      </body>
      <title>Announcing CR_MoveFile: DxCore plug-in for moving files around in a solution</title>
      <guid isPermaLink="false">http://www.drrandom.org/PermaLink,guid,ae83bded-50a9-4c93-85da-78a0da965f14.aspx</guid>
      <link>http://www.drrandom.org/2009/12/07/AnnouncingCRMoveFileDxCorePluginForMovingFilesAroundInASolution.aspx</link>
      <pubDate>Mon, 07 Dec 2009 19:17:46 GMT</pubDate>
      <description>&lt;p&gt;
As of right about now, you should be able to mosey on over to the &lt;a href="http://code.google.com/p/dxcorecommunityplugins/" target="_blank"&gt;DxCore
Community Plug-ins page&lt;/a&gt;, and grab a copy of &lt;a href="http://code.google.com/p/dxcorecommunityplugins/wiki/CR_MoveFile" target="_blank"&gt;CR_MoveFile&lt;/a&gt;.&amp;nbsp;
This is a plug-in I created primarily as a tool to aid in working in a TDD environment,
but which certainly has uses for non-TDD applications.&amp;nbsp; It does basically what &lt;a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/AnnouncingCR_MoveFileDxCorepluginformovi_8466/CR_MoveFile_ScreenShot_5.png"&gt;&lt;img style="border-right-width: 0px; margin: 10px 0px 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CR_MoveFile_ScreenShot" border="0" alt="CR_MoveFile_ScreenShot" align="right" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/AnnouncingCR_MoveFileDxCorepluginformovi_8466/CR_MoveFile_ScreenShot_thumb_1.png" width="660" height="439"&gt;&lt;/a&gt;the
name suggests, it allows you to move a file from one directory in your solution/project
structure to another, even one in a different project.&amp;nbsp; I implemented this as
a code provider (since it could change the functionality if you move the file from
one project to another), so it will appear in the Code menu when you have the cursor
somewhere within the beginning blocks of a file (“using” sections, namespace declaration,
or class/interface/struct declarations).&amp;nbsp; Once selected you are presented with
a popup window which has a tree that represents your current solution structure, with
your current directory highlighted.&amp;nbsp; You can use the arrow keys to navigate the
directories and choose a new home for your file.
&lt;/p&gt;
&lt;p&gt;
If you move files between projects, the plug-in will create project references for
you, so you don’t need to worry about that.&amp;nbsp; When the file is moved the file
contents remain unchanged, so all namespaces will be the same as they were originally.&amp;nbsp;
I did this mostly to keep the plug-in simple, but also because I could see situations
where this would be good, and situations where this would be bad, and it seemed like
this was a bad choice to make for people.&amp;nbsp; I’ve been using this plug-in on a
day-to-day basis for a while now, and things seem pretty clean, I did run into a small
issue, however, using it within a solution that was under source control.&amp;nbsp; At
this point you need to make sure the project files effected by the move are checked
out, otherwise the plug-in goes through the motions, but doesn’t actually do anything,
which is quite annoying.&amp;nbsp; There is also no checking going on to make sure the
language is the same between the source and target project, so if you work on a solution
that contains C# &lt;strong&gt;and&lt;/strong&gt; VB.Net projects, you have to be careful not
to move files around to projects that can’t understand what they are (oh, and the
project icons used on the tree view are all the same, so there is no visual indication
of what project contains what type of files).
&lt;/p&gt;
&lt;p&gt;
That’s pretty much it.&amp;nbsp; Clean, simple, basic.&amp;nbsp; Used with other existing
CodeRush/Refactor tools like “Move Type To File” and “Move to Namespace”, this provides
for some pretty powerful code re-organization.&amp;nbsp; Just make sure you run all of
your tests :).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=ae83bded-50a9-4c93-85da-78a0da965f14" /&gt;</description>
      <comments>http://www.drrandom.org/CommentView,guid,ae83bded-50a9-4c93-85da-78a0da965f14.aspx</comments>
      <category>.Net</category>
      <category>C#</category>
      <category>CodeRush</category>
      <category>DxCore</category>
      <category>TDD</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.drrandom.org/Trackback.aspx?guid=7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11</trackback:ping>
      <pingback:server>http://www.drrandom.org/pingback.aspx</pingback:server>
      <pingback:target>http://www.drrandom.org/PermaLink,guid,7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11.aspx</pingback:target>
      <dc:creator>Casey Kramer</dc:creator>
      <wfw:comment>http://www.drrandom.org/CommentView,guid,7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11.aspx</wfw:comment>
      <wfw:commentRss>http://www.drrandom.org/SyndicationService.asmx/GetEntryCommentsRss?guid=7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Anyone who has been around me for more than a few hours while coding, or who pays
any attention to me on <a href="http://www.twitter.com/drrandom">Twitter</a> will
know that I am a huge fan of <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/">CodeRush
and Refactor Pro!</a> from <a href="http://www.devexpress.com">DevExpress</a>. 
I consider these sorts of tools essential to getting the most out of your development
environment, and I think CodeRush is one of the best tools available for a number
of reasons, not the least of which is it’s extensibility.  CodeRush is built
on top of <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/">DxCore</a>,
which is a freely available library for building Visual Studio plug-ins (incidentally,
DevExpress also have a free version of CodeRush called <a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/">CodeRush
XPress</a>, which is built on the same platform).  DxCore provides any developer
who wants it access to the same tools that the folks at DevExpress have for building
plug-ins and extensions on top of VisualStudio, and several developers (including
yours truly) have <a href="http://code.google.com/p/dxcorecommunityplugins/">done
just that</a>.
</p>
        <p>
One of the more recent additions to the CodeRush arsenal are the CodeIssues. 
As of the v9 release, CodeRush included an extensive collection of these mini code
analyzers which will look at your code in real time and do everything from let you
know when you have undisposed resources, to suggesting alternate language features
you may not even be aware of.  A lot of these are also tied in to the refactoring
and code generation tools that already exist within CodeRush and Refactor Pro! so
that not only do you see that there is an issue or suggestion, but in a lot of cases
you can tell the tool to correct it for you.  Pretty impressive stuff.
</p>
        <p>
So what I would like to do is dig in to how the CodeIssue functionality works within
CodeRush by creating a custom CodeIssue Provider.  Because I’m a TDD guy, one
of the things I’ve been trying to do is build in some tooling around the TDD process
to make it that much easier to write code TDD.  So based on that I’m going to
show you how to implement a CodeRush CodeIssueProvider which will generate a warning
whenever you have created a Unit Test method with no assertions (which would indicate
that you are either dealing with an Integration Test, or your test is not correctly
factored).  <strong>Note:</strong> Since the CodeIssue UI elements are part of
the full CodeRush product, and not CodeRush XPress, this plug-in will note do anything
unless you are running the full version of CodeRush.
</p>
        <p>
Okay, so the first thing to do is to create a new Plug-In project.  This can
either be done from the Visual Studio File –&gt; New Project menu, or by selecting
the New Plug-in option from the DevExpress menu in visual studio (if you are using
CodeRush XPress and you don’t have the DevExpress menu, my man Rory Becker has a solution
for you).  Regardless of which way you go, you will get a “New DxCore Plug-in
Project” window, which will ask you what Language you want to write your plug-in in
(C# or Visual Basic .Net), and what kind of plug-in you want, along with the standard
stuff about what to name the solution and where to store the files.  For our
purposes we’re going to go with C# as the Language, a Standard Plug-in, and we’ll
call it CR_TestShouldAssert (the CR_ is a naming convention used by the CodeRush team
to indicate it’s a CodeRush plug-in, as opposed to a Refactoring or DxCore plug-in).
</p>
        <p>
          <a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_2.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb.png" width="745" height="393" />
          </a>
        </p>
        <p>
Net up is the “DxCore Plug-in Project Settings” dialog.  This allows you to give
your plug-in a title, and set some more advanced options which deal with how the plug-in
gets loaded by the DxCore framework.  We’ll just leave everything as-is and move
on to the good stuff.
</p>
        <p>
          <a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_4.png">
            <img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb_1.png" width="401" height="255" />
          </a>
        </p>
        <p>
Once your project loads you will be presented with a design surface, this is because
a large number of the components that are available via DXCore can actually be found
in the Visual Studio toolbox, and you can just drag them out onto your plug-in designer
to get started.  The CodeIssueProvider is an exception, though, so we will have
to crack open the designer file to add it to our plug-in.  So open up the PlugIn1.designer.cs
file, and add the following line of code under the “Windows Form Designer Generated
Code” section:
</p>
        <pre class="brush: csharp" name="code">CodeIssueProvider cipTestsShouldAssert;</pre>You'll
need to add a using statement for the DevExpress.CodeRush.Core namespace as well. 
Next we need to instantiate it, so we need to do this in the the InitializeComponents
method.  When you are finished your InitializeComponents method should look like
this:<pre class="brush: csharp" name="code">this.components = new System.ComponentModel.Container();
cipTestsShouldAssert = new CodeIssueProvider(this.components);
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();</pre><p>
Now if we switch back over to the designer, we will see our new provider on the design
surface.  At this point we can use the Properties window to configure the provider. 
The things we need to worry about filling out are the Description, DisplayName, and
ProviderName properties.  The Description is the text that will be displayed
in the Code Issue catalog, so it needs to clearly explain what the CodeIssueProvider
is intended to do.  Let’s go with something like: “A Unit Test should have at
least one explicit or implicit assertion.”  As for DisplayName, lets say something
like “Unit Test Method Should Assert”, and make the ProviderName the same.
</p><p>
Ok, so now it’s time to actually do the work of finding a TestMethod that violates
this condition.  So we need to switch over to the Events list for our provider,
and Double-Click in the CheckCodeIssues drop-down so it generates an event handler
for us.  You will now be taken to the code editor and presented with a empty
handler that looks something like:
</p><pre class="brush: csharp" name="code">private void cipTestsShouldAssert_CheckCodeIssues(object sender, CheckCodeIssuesEventArgs ea)
{

}</pre><p>
This looks pretty much like your normal event handler, we’ve got the sender object
(which would be our provider instance, and then we have a custom EventArgs object.
Looking at this event args object, you can see quite a few methods, and a couple of
properties.  The first few methods you see deal with actually adding your code
issue, if it exists, to the list of issues reported by the UI.  You’ve got one
method for each type of CodeIssue (AddDeadCode, AddError, AddHint, AddSmell,AddWarning),
and then one method (AddIssue), which allows you to specify the CodeIssue Type. 
Now this is where things start to get interesting because basically we’re at the point
where the good folks who wrote DxCore have said “All right, go off and find your problem
and report your finding back to me when your done”.  So from here we have to
figure out whether or not there are any test methods without asserts floating around
anywhere.  The good news is that there are a few tools in the CodeRush bag of
tricks that can help us.
</p><p>
Perhaps the best tool for figuring out this sort of thing is the “Expression Lab”
plug-in.  You can open this up by going to the DevExpress menu, opening the Tool
Windows-&gt;Diagnostics-&gt;Expressions Lab.  This shows you in real time what
the AST that CodeRush produces for your code looks like as you move about in a file. 
You can also see all of the properties associated with the various syntax elements,
and view how things are related.  This is a very handy tool to have.  Before
we dig too deep into the Expressions Lab, lets get a start on finding our CodeIssue. 
We know that we are going to be looking at methods here, since we are ultimately searching
for test methods, so the first thing to do is to limit the scope of our search to
just methods.  The CheckCodeIssues event is fired at a file level, so you are
basically handed an entire file to search by the DxCore framework.  We need to
filter that down a bit and only pay attention to the methods contained in the current
file.  To do that we’re going to use the ResolveScope() method of the CheckCodeIssuesEventArgs
object.  Calling the ResolveScope() method gives us a ScopreResolveResult object,
which doesn’t sound very interesting, but this object has a wonderful little method
on it called GetElementEnumerator().  This method will allow you to pass in a
filter expression, and return all of the elements that match that filter expression
as an enumerable collection. So to get to this, lets add the following to the body
of our event handler:
</p><pre class="brush: csharp" name="code">var resolveScope = ea.ResolveScope();
foreach(IMethodElement method in resolveScope.GetElementEnumerator(ea.Scope,new ElementTypeFilter(LanguageElementType.Method)))
{
}</pre><p>
This looks pretty straightforward, but there are a couple of things I want to point
out. First is the ea.Scope property that we are passing in to the GetElementEnumerable()
method. This is the AST object that represents the top of the parse-tree that we are
going to be searching for code issues in. Typically this is a file-level object, but
I don't know that you can count on that always being the case (changing the parse
settings could potentially effect how much of the code is considered invalid at a
time, and so you could get larger or smaller segments of code).  The other interesting
bit is the ElementTypeFilter().  This allows us to filter the list of AST elements
given to us in our enumerable based on their LangueElementType (LanguageElement is
the base class for syntax elements within the DxCore AST structure.  All nodes
have an ElementType property which exposes a LanguageElementType enum value). In our
case we’re only interested in methods, so we’re using LanguageElementType.Method. 
The result is a collection of all of the methods within our Scope.
</p><p>
Now that we have all of our methods, we need to figure out if they are Test methods. 
To do this we’ll have to look for the existence of an Attribute on the method. 
Taking a look at Expressions Lab, we can see that a Method object has an Attributes
collection associated with it. So we should be able to search the list of attributes
for one with a Name property of “Test”.  Using Linq, we can do this pretty easily
like this:
</p><pre class="brush: csharp" name="code">method.Attributes.OfType&lt;IAttributeElement&gt;().Count(a =&gt; a.Name == "Test")</pre>This
will give a a count of the "Test" attributes on our method. We can put this into an
if statement like so:<pre class="brush: csharp">if(method.Attributes.OfType&lt;IAttributeElement&gt;().Count(a =&gt; a.Name == "Test") &gt; 0)
{
}</pre>A
quick note; I'm using the OfType&lt;T&gt;() method to convert the collection returned
by the Attributes Property into an enumerable of IAttributeElements just as an easy
way of enabling Linq expressions against the collection. Since DxCore is written to
work with all versions of VisualStudio, there really isn't any official Linq support.
As a matter of fact, using the expression we did limits the plug-in to only those
people with .Net Framework 3.5 installed on their development machines. I think that
in this day and age, this is a fairly safe assumption, so I'm not that worried about
it. I would like to point out also, that having this expression in place does not
prevent the plug-in from working with Visual Studio 2005, as long as the 3.5 framework
is installed. 
<p></p><p>
Ok, so now we have a list of methods, and we’re filtering them based on whether or
not they are Test methods (defined by the existence of a Test attribute).  The
next thing to do is look for an Assert statement within the text of our method. 
This is another place where the Expressions Lab proves invaluable.  Looking at
Expressions Lab we discover that our Assert statement is in fact an ElementReferenceExpression
and is a child node of our Method object.  With this knowledge in hand we can
use the FindElementByName method on our Method object to look for an Assert reference:
</p><pre class="brush: csharp">var assert = method.FindChildByName("Assert") as IElementReferenceExpression</pre>Now
all we have to do is test whether or not our assert variable is null, and we know
whether or not this method violates our rule. Once we do that test we can add the
appropriate Code Issue Type to the CodeIssues list using our event args. The last
piece of the puzzle then will look something like this:<pre class="brush: csharp">if(assert == null)
{
    ea.AddIssue(CodeIssueType.CodeSmell,(SourceRange)method.NameRanges[0],"A Test Method should have at least one Assert");
}</pre><p>
With this in place we should now be able to run our project and try it out. Using
F5 to debug a DxCore plug-in will launch a new instance of Visual Studio. From there
if you create a new project, or open an existing project, and write a test method
which does not have an Assert, you should see a red squiggle underneath the name of
the method. Hovering over that with your mouse you'll see our Code Issue test presented.
Adding an Assert will make the Code Issue disappear.
</p><p><a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb_2.png" width="498" height="136" /></a></p><p>
Well, things are looking good here, we’ve got code that is searching for an issue,
and displaying the appropriate warning if our condition is met.  There is one
other condition we should probably consider, however.  The one case I can think
of when our rule does not apply is when we are expecting the code under test to throw
an exception.  In that case there would be an ExpectedException attribute on
the test class.  To make our users happy we should probably implement this functionality.
</p><p>
The good news is we already know how to accomplish this, since we are using the same
technique to determine if the method we’re looking at is a test method.  All
we need to do is change the test condition in our Count() method so it looks for “ExpectedException”
instead of “Test”.  While we’re at it it seems like a reasonable thing to get
an instance of the attribute and then check it for null, similar to how we’re handling
the assert.  With all of this done the code should look like this:
</p><pre class="brush: csharp">var assert = method.FindChildByName("Assert") as IElementReferenceExpression;
var expectedException = method.Attributes.OfType&lt;IAttributeElement&gt;().FirstOrDefault(a =&gt; a.Name == "ExpectedException");
if (assert == null &amp;&amp; expectedException == null)
{
    ea.AddIssue(CodeIssueType.CodeSmell, (SourceRange)method.NameRanges[0], "A Test Method should have at least one implicit or explicit Assertion");
}</pre>So
now we should be able to run this, and see that the code issue disappears if we have
a test method with either an assert statement, or an expected exception attribute.
Pretty cool. You’ll notice that I also updated our issue message so it reflects the
fact that we are able to handle implicit assertions (in the form of our ExpectedException)
attribute.  For the sake of completeness, here is what our finished CheckCodeIssues
method looks like:<pre class="brush: csharp">private void cipTestShouldAssert_CheckCodeIssues(object sender, CheckCodeIssuesEventArgs ea)
{
    var resolveScope = ea.ResolveScope();
    foreach (IMethodElement method in resolveScope.GetElementEnumerator(ea.Scope, new ElementTypeFilter(LanguageElementType.Method)))
    {
        if (method.Attributes.OfType&lt;IAttributeElement&gt;().Count(a =&gt; a.Name == "Test") &gt; 0)
        {
            var assert = method.FindChildByName("Assert") as IElementReferenceExpression;
            var expectedException = method.Attributes.OfType&lt;IAttributeElement&gt;().FirstOrDefault(a =&gt; a.Name == "ExpectedException");
            if (assert == null &amp;&amp; expectedException == null)
            {
                ea.AddIssue(CodeIssueType.CodeSmell, (SourceRange)method.NameRanges[0], "A Test Method should have at least one implicit or explicit Assertion");
            }
        }
    }
}</pre><p>
And that's it. Granted there are some things here I would like to change before releasing
this into the wild. We are specifically looking for NUnit/MbUnit style test method
declarations for one, and we are also looking only for the short version of the attribute
names, but this should give you a good idea of how things work. 
</p><p>
If you are interested in seeing a more polished final version, you can either download
the <a href="http://www.drrandom.org/downloads/CR_TestShouldAssert.zip">finished source
for this post</a>, or have a look at my <a href="http://code.google.com/p/dxcorecommunityplugins/wiki/CR_CreateTestMethod">CR_CreateTestMethod</a> (admittedly
poorly named) plug-in on the <a href="http://code.google.com/p/dxcorecommunityplugins/">DxCore
Community Plug-In's site</a>.
</p><img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11" /></body>
      <title>Getting a CodeRush: Inside a CodeRush CodeIssue</title>
      <guid isPermaLink="false">http://www.drrandom.org/PermaLink,guid,7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11.aspx</guid>
      <link>http://www.drrandom.org/2009/10/07/GettingACodeRushInsideACodeRushCodeIssue.aspx</link>
      <pubDate>Wed, 07 Oct 2009 17:22:35 GMT</pubDate>
      <description>&lt;p&gt;
Anyone who has been around me for more than a few hours while coding, or who pays
any attention to me on &lt;a href="http://www.twitter.com/drrandom"&gt;Twitter&lt;/a&gt; will
know that I am a huge fan of &lt;a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/Coding_Assistance/"&gt;CodeRush
and Refactor Pro!&lt;/a&gt; from &lt;a href="http://www.devexpress.com"&gt;DevExpress&lt;/a&gt;.&amp;nbsp;
I consider these sorts of tools essential to getting the most out of your development
environment, and I think CodeRush is one of the best tools available for a number
of reasons, not the least of which is it’s extensibility.&amp;nbsp; CodeRush is built
on top of &lt;a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/DXCore/"&gt;DxCore&lt;/a&gt;,
which is a freely available library for building Visual Studio plug-ins (incidentally,
DevExpress also have a free version of CodeRush called &lt;a href="http://www.devexpress.com/Products/Visual_Studio_Add-in/CodeRushX/"&gt;CodeRush
XPress&lt;/a&gt;, which is built on the same platform).&amp;nbsp; DxCore provides any developer
who wants it access to the same tools that the folks at DevExpress have for building
plug-ins and extensions on top of VisualStudio, and several developers (including
yours truly) have &lt;a href="http://code.google.com/p/dxcorecommunityplugins/"&gt;done
just that&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
One of the more recent additions to the CodeRush arsenal are the CodeIssues.&amp;nbsp;
As of the v9 release, CodeRush included an extensive collection of these mini code
analyzers which will look at your code in real time and do everything from let you
know when you have undisposed resources, to suggesting alternate language features
you may not even be aware of.&amp;nbsp; A lot of these are also tied in to the refactoring
and code generation tools that already exist within CodeRush and Refactor Pro! so
that not only do you see that there is an issue or suggestion, but in a lot of cases
you can tell the tool to correct it for you.&amp;nbsp; Pretty impressive stuff.
&lt;/p&gt;
&lt;p&gt;
So what I would like to do is dig in to how the CodeIssue functionality works within
CodeRush by creating a custom CodeIssue Provider.&amp;nbsp; Because I’m a TDD guy, one
of the things I’ve been trying to do is build in some tooling around the TDD process
to make it that much easier to write code TDD.&amp;nbsp; So based on that I’m going to
show you how to implement a CodeRush CodeIssueProvider which will generate a warning
whenever you have created a Unit Test method with no assertions (which would indicate
that you are either dealing with an Integration Test, or your test is not correctly
factored).&amp;nbsp; &lt;strong&gt;Note:&lt;/strong&gt; Since the CodeIssue UI elements are part of
the full CodeRush product, and not CodeRush XPress, this plug-in will note do anything
unless you are running the full version of CodeRush.
&lt;/p&gt;
&lt;p&gt;
Okay, so the first thing to do is to create a new Plug-In project.&amp;nbsp; This can
either be done from the Visual Studio File –&amp;gt; New Project menu, or by selecting
the New Plug-in option from the DevExpress menu in visual studio (if you are using
CodeRush XPress and you don’t have the DevExpress menu, my man Rory Becker has a solution
for you).&amp;nbsp; Regardless of which way you go, you will get a “New DxCore Plug-in
Project” window, which will ask you what Language you want to write your plug-in in
(C# or Visual Basic .Net), and what kind of plug-in you want, along with the standard
stuff about what to name the solution and where to store the files.&amp;nbsp; For our
purposes we’re going to go with C# as the Language, a Standard Plug-in, and we’ll
call it CR_TestShouldAssert (the CR_ is a naming convention used by the CodeRush team
to indicate it’s a CodeRush plug-in, as opposed to a Refactoring or DxCore plug-in).
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb.png" width="745" height="393"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Net up is the “DxCore Plug-in Project Settings” dialog.&amp;nbsp; This allows you to give
your plug-in a title, and set some more advanced options which deal with how the plug-in
gets loaded by the DxCore framework.&amp;nbsp; We’ll just leave everything as-is and move
on to the good stuff.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb_1.png" width="401" height="255"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Once your project loads you will be presented with a design surface, this is because
a large number of the components that are available via DXCore can actually be found
in the Visual Studio toolbox, and you can just drag them out onto your plug-in designer
to get started.&amp;nbsp; The CodeIssueProvider is an exception, though, so we will have
to crack open the designer file to add it to our plug-in.&amp;nbsp; So open up the PlugIn1.designer.cs
file, and add the following line of code under the “Windows Form Designer Generated
Code” section:&lt;pre class="brush: csharp" name="code"&gt;CodeIssueProvider cipTestsShouldAssert;&lt;/pre&gt;You'll
need to add a using statement for the DevExpress.CodeRush.Core namespace as well.&amp;nbsp;
Next we need to instantiate it, so we need to do this in the the InitializeComponents
method.&amp;nbsp; When you are finished your InitializeComponents method should look like
this:&lt;pre class="brush: csharp" name="code"&gt;this.components = new System.ComponentModel.Container();
cipTestsShouldAssert = new CodeIssueProvider(this.components);
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this)).EndInit();&lt;/pre&gt;
&lt;p&gt;
Now if we switch back over to the designer, we will see our new provider on the design
surface.&amp;nbsp; At this point we can use the Properties window to configure the provider.&amp;nbsp;
The things we need to worry about filling out are the Description, DisplayName, and
ProviderName properties.&amp;nbsp; The Description is the text that will be displayed
in the Code Issue catalog, so it needs to clearly explain what the CodeIssueProvider
is intended to do.&amp;nbsp; Let’s go with something like: “A Unit Test should have at
least one explicit or implicit assertion.”&amp;nbsp; As for DisplayName, lets say something
like “Unit Test Method Should Assert”, and make the ProviderName the same.
&lt;/p&gt;
&lt;p&gt;
Ok, so now it’s time to actually do the work of finding a TestMethod that violates
this condition.&amp;nbsp; So we need to switch over to the Events list for our provider,
and Double-Click in the CheckCodeIssues drop-down so it generates an event handler
for us.&amp;nbsp; You will now be taken to the code editor and presented with a empty
handler that looks something like:&lt;pre class="brush: csharp" name="code"&gt;private void cipTestsShouldAssert_CheckCodeIssues(object sender, CheckCodeIssuesEventArgs ea)
{

}&lt;/pre&gt;
&lt;p&gt;
This looks pretty much like your normal event handler, we’ve got the sender object
(which would be our provider instance, and then we have a custom EventArgs object.
Looking at this event args object, you can see quite a few methods, and a couple of
properties.&amp;nbsp; The first few methods you see deal with actually adding your code
issue, if it exists, to the list of issues reported by the UI.&amp;nbsp; You’ve got one
method for each type of CodeIssue (AddDeadCode, AddError, AddHint, AddSmell,AddWarning),
and then one method (AddIssue), which allows you to specify the CodeIssue Type.&amp;nbsp;
Now this is where things start to get interesting because basically we’re at the point
where the good folks who wrote DxCore have said “All right, go off and find your problem
and report your finding back to me when your done”.&amp;nbsp; So from here we have to
figure out whether or not there are any test methods without asserts floating around
anywhere.&amp;nbsp; The good news is that there are a few tools in the CodeRush bag of
tricks that can help us.
&lt;/p&gt;
&lt;p&gt;
Perhaps the best tool for figuring out this sort of thing is the “Expression Lab”
plug-in.&amp;nbsp; You can open this up by going to the DevExpress menu, opening the Tool
Windows-&amp;gt;Diagnostics-&amp;gt;Expressions Lab.&amp;nbsp; This shows you in real time what
the AST that CodeRush produces for your code looks like as you move about in a file.&amp;nbsp;
You can also see all of the properties associated with the various syntax elements,
and view how things are related.&amp;nbsp; This is a very handy tool to have.&amp;nbsp; Before
we dig too deep into the Expressions Lab, lets get a start on finding our CodeIssue.&amp;nbsp;
We know that we are going to be looking at methods here, since we are ultimately searching
for test methods, so the first thing to do is to limit the scope of our search to
just methods.&amp;nbsp; The CheckCodeIssues event is fired at a file level, so you are
basically handed an entire file to search by the DxCore framework.&amp;nbsp; We need to
filter that down a bit and only pay attention to the methods contained in the current
file.&amp;nbsp; To do that we’re going to use the ResolveScope() method of the CheckCodeIssuesEventArgs
object.&amp;nbsp; Calling the ResolveScope() method gives us a ScopreResolveResult object,
which doesn’t sound very interesting, but this object has a wonderful little method
on it called GetElementEnumerator().&amp;nbsp; This method will allow you to pass in a
filter expression, and return all of the elements that match that filter expression
as an enumerable collection. So to get to this, lets add the following to the body
of our event handler:&lt;pre class="brush: csharp" name="code"&gt;var resolveScope = ea.ResolveScope();
foreach(IMethodElement method in resolveScope.GetElementEnumerator(ea.Scope,new ElementTypeFilter(LanguageElementType.Method)))
{
}&lt;/pre&gt;
&lt;p&gt;
This looks pretty straightforward, but there are a couple of things I want to point
out. First is the ea.Scope property that we are passing in to the GetElementEnumerable()
method. This is the AST object that represents the top of the parse-tree that we are
going to be searching for code issues in. Typically this is a file-level object, but
I don't know that you can count on that always being the case (changing the parse
settings could potentially effect how much of the code is considered invalid at a
time, and so you could get larger or smaller segments of code).&amp;nbsp; The other interesting
bit is the ElementTypeFilter().&amp;nbsp; This allows us to filter the list of AST elements
given to us in our enumerable based on their LangueElementType (LanguageElement is
the base class for syntax elements within the DxCore AST structure.&amp;nbsp; All nodes
have an ElementType property which exposes a LanguageElementType enum value). In our
case we’re only interested in methods, so we’re using LanguageElementType.Method.&amp;nbsp;
The result is a collection of all of the methods within our Scope.
&lt;/p&gt;
&lt;p&gt;
Now that we have all of our methods, we need to figure out if they are Test methods.&amp;nbsp;
To do this we’ll have to look for the existence of an Attribute on the method.&amp;nbsp;
Taking a look at Expressions Lab, we can see that a Method object has an Attributes
collection associated with it. So we should be able to search the list of attributes
for one with a Name property of “Test”.&amp;nbsp; Using Linq, we can do this pretty easily
like this:&lt;pre class="brush: csharp" name="code"&gt;method.Attributes.OfType&amp;lt;IAttributeElement&amp;gt;().Count(a =&amp;gt; a.Name == "Test")&lt;/pre&gt;This
will give a a count of the "Test" attributes on our method. We can put this into an
if statement like so:&lt;pre class="brush: csharp"&gt;if(method.Attributes.OfType&amp;lt;IAttributeElement&amp;gt;().Count(a =&amp;gt; a.Name == "Test") &amp;gt; 0)
{
}&lt;/pre&gt;A
quick note; I'm using the OfType&amp;lt;T&amp;gt;() method to convert the collection returned
by the Attributes Property into an enumerable of IAttributeElements just as an easy
way of enabling Linq expressions against the collection. Since DxCore is written to
work with all versions of VisualStudio, there really isn't any official Linq support.
As a matter of fact, using the expression we did limits the plug-in to only those
people with .Net Framework 3.5 installed on their development machines. I think that
in this day and age, this is a fairly safe assumption, so I'm not that worried about
it. I would like to point out also, that having this expression in place does not
prevent the plug-in from working with Visual Studio 2005, as long as the 3.5 framework
is installed. 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Ok, so now we have a list of methods, and we’re filtering them based on whether or
not they are Test methods (defined by the existence of a Test attribute).&amp;nbsp; The
next thing to do is look for an Assert statement within the text of our method.&amp;nbsp;
This is another place where the Expressions Lab proves invaluable.&amp;nbsp; Looking at
Expressions Lab we discover that our Assert statement is in fact an ElementReferenceExpression
and is a child node of our Method object.&amp;nbsp; With this knowledge in hand we can
use the FindElementByName method on our Method object to look for an Assert reference:&lt;pre class="brush: csharp"&gt;var assert = method.FindChildByName("Assert") as IElementReferenceExpression&lt;/pre&gt;Now
all we have to do is test whether or not our assert variable is null, and we know
whether or not this method violates our rule. Once we do that test we can add the
appropriate Code Issue Type to the CodeIssues list using our event args. The last
piece of the puzzle then will look something like this:&lt;pre class="brush: csharp"&gt;if(assert == null)
{
    ea.AddIssue(CodeIssueType.CodeSmell,(SourceRange)method.NameRanges[0],"A Test Method should have at least one Assert");
}&lt;/pre&gt;
&lt;p&gt;
With this in place we should now be able to run our project and try it out. Using
F5 to debug a DxCore plug-in will launch a new instance of Visual Studio. From there
if you create a new project, or open an existing project, and write a test method
which does not have an Assert, you should see a red squiggle underneath the name of
the method. Hovering over that with your mouse you'll see our Code Issue test presented.
Adding an Assert will make the Code Issue disappear.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.drrandom.org/content/binary/WindowsLiveWriter/GettingaCodeRushInsideaCodeRushCodeIssue_D816/image_thumb_2.png" width="498" height="136"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Well, things are looking good here, we’ve got code that is searching for an issue,
and displaying the appropriate warning if our condition is met.&amp;nbsp; There is one
other condition we should probably consider, however.&amp;nbsp; The one case I can think
of when our rule does not apply is when we are expecting the code under test to throw
an exception.&amp;nbsp; In that case there would be an ExpectedException attribute on
the test class.&amp;nbsp; To make our users happy we should probably implement this functionality.
&lt;/p&gt;
&lt;p&gt;
The good news is we already know how to accomplish this, since we are using the same
technique to determine if the method we’re looking at is a test method.&amp;nbsp; All
we need to do is change the test condition in our Count() method so it looks for “ExpectedException”
instead of “Test”.&amp;nbsp; While we’re at it it seems like a reasonable thing to get
an instance of the attribute and then check it for null, similar to how we’re handling
the assert.&amp;nbsp; With all of this done the code should look like this:&lt;pre class="brush: csharp"&gt;var assert = method.FindChildByName("Assert") as IElementReferenceExpression;
var expectedException = method.Attributes.OfType&amp;lt;IAttributeElement&amp;gt;().FirstOrDefault(a =&amp;gt; a.Name == "ExpectedException");
if (assert == null &amp;amp;&amp;amp; expectedException == null)
{
    ea.AddIssue(CodeIssueType.CodeSmell, (SourceRange)method.NameRanges[0], "A Test Method should have at least one implicit or explicit Assertion");
}&lt;/pre&gt;So
now we should be able to run this, and see that the code issue disappears if we have
a test method with either an assert statement, or an expected exception attribute.
Pretty cool. You’ll notice that I also updated our issue message so it reflects the
fact that we are able to handle implicit assertions (in the form of our ExpectedException)
attribute.&amp;nbsp; For the sake of completeness, here is what our finished CheckCodeIssues
method looks like:&lt;pre class="brush: csharp"&gt;private void cipTestShouldAssert_CheckCodeIssues(object sender, CheckCodeIssuesEventArgs ea)
{
    var resolveScope = ea.ResolveScope();
    foreach (IMethodElement method in resolveScope.GetElementEnumerator(ea.Scope, new ElementTypeFilter(LanguageElementType.Method)))
    {
        if (method.Attributes.OfType&amp;lt;IAttributeElement&amp;gt;().Count(a =&amp;gt; a.Name == "Test") &amp;gt; 0)
        {
            var assert = method.FindChildByName("Assert") as IElementReferenceExpression;
            var expectedException = method.Attributes.OfType&amp;lt;IAttributeElement&amp;gt;().FirstOrDefault(a =&amp;gt; a.Name == "ExpectedException");
            if (assert == null &amp;amp;&amp;amp; expectedException == null)
            {
                ea.AddIssue(CodeIssueType.CodeSmell, (SourceRange)method.NameRanges[0], "A Test Method should have at least one implicit or explicit Assertion");
            }
        }
    }
}&lt;/pre&gt;
&lt;p&gt;
And that's it. Granted there are some things here I would like to change before releasing
this into the wild. We are specifically looking for NUnit/MbUnit style test method
declarations for one, and we are also looking only for the short version of the attribute
names, but this should give you a good idea of how things work. 
&lt;/p&gt;
&lt;p&gt;
If you are interested in seeing a more polished final version, you can either download
the &lt;a href="http://www.drrandom.org/downloads/CR_TestShouldAssert.zip"&gt;finished source
for this post&lt;/a&gt;, or have a look at my &lt;a href="http://code.google.com/p/dxcorecommunityplugins/wiki/CR_CreateTestMethod"&gt;CR_CreateTestMethod&lt;/a&gt; (admittedly
poorly named) plug-in on the &lt;a href="http://code.google.com/p/dxcorecommunityplugins/"&gt;DxCore
Community Plug-In's site&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11" /&gt;</description>
      <comments>http://www.drrandom.org/CommentView,guid,7bb82e3b-a7d0-4fa5-9ac1-0f8e4261ed11.aspx</comments>
      <category>.Net</category>
      <category>C#</category>
      <category>CodeRush</category>
      <category>DxCore</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.drrandom.org/Trackback.aspx?guid=24aaf20e-9858-42a8-abc0-75f6b7f128b4</trackback:ping>
      <pingback:server>http://www.drrandom.org/pingback.aspx</pingback:server>
      <pingback:target>http://www.drrandom.org/PermaLink,guid,24aaf20e-9858-42a8-abc0-75f6b7f128b4.aspx</pingback:target>
      <dc:creator>Casey Kramer</dc:creator>
      <wfw:comment>http://www.drrandom.org/CommentView,guid,24aaf20e-9858-42a8-abc0-75f6b7f128b4.aspx</wfw:comment>
      <wfw:commentRss>http://www.drrandom.org/SyndicationService.asmx/GetEntryCommentsRss?guid=24aaf20e-9858-42a8-abc0-75f6b7f128b4</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The folks at <a href="http://www.typemock.com/">TypeMock</a> have released a new UnitTesting
tool aimed specifically at catching deadlocks in multithreaded code called <a href="http://www.typemock.com/learn_about_typemock_racer.php">TypeMock
Racer</a>, and what's more they are <a href="http://blog.typemock.com/2009/06/easy-deadlock-detection-get-free.html" target="_blank">offering
free licenses to folks willing to review it during the 21 day free trial period</a>. 
As anyone who knows me can testify to, I am a whore for free-bees, so I decided to
take them up on this.
</p>
        <p>
          <strong>For the impatient, here is the executive summary:<br /></strong>This is a good tool.  Period.  It is, however, also a very specific
tool that is intended to help find very specific problems.  If you are not doing
any multithreaded code, there is no need to have it in your toolbox.  The cost
($890 US) is high enough that it doesn't really seem worth it to get it "just in case"
(unless, of course, you right a nice review on your blog and get a free license). 
If you <strong><em>do</em></strong> work with multithreaded code, and you<strong><em> are</em></strong> concerned
about deadlocks, this tool will save you lots of time, which ultimately means money.
</p>
        <p>
          <strong>Now, for the details</strong>
        </p>
        <p>
First of all, this is a tool from TypeMock, so I expected some pretty incredible things,
even at the 1.0 release.  After all, their flagship product <a href="http://www.typemock.com/learn_about_typemock_isolator.php">TypeMock
Isolator</a> is phenomenally powerful, so much so that the free license I was given
for <a href="http://www.drrandom.org/PermaLink,guid,5200ee4d-d92b-4931-9005-705f523228b1.aspx" target="_blank">posting
an advertisement</a> for the release of their ASP.Net product has gone largely unused. 
I'm just scared of it.  It's like having access to a 50 horse-power tablesaw
with no blade guard.  I may be careful enough to use it correctly most of the
time, but the fact that it can take off my forearm without pausing to ask my permission
makes me reluctant to get too close.  I do know that there are some very real
problems that the tool can solve that just can't be done with any other tool, so I
have every intent of getting up my courage, grabbing a first aid kit, and jumping
in to see what I can do...eventually.
</p>
        <p>
But Racer is different.  It is a very powerful tool with a very specific purpose. 
It makes it easier to run tests in multiple threads, and detect deadlocks.  As
far as I can tell, it just detects deadlocks, not race conditions, as it's name seems
to suggest.  Not that this is bad, just that it only covers half of the rather
shaky ground that is traveled while working with multithreaded code.  It is arguable,
however, that dealing with deadlocks is the more difficult of the two problems, so
getting this one tacked first is not a bad thing.
</p>
        <p>
          <strong>So how does it work?</strong>
        </p>
        <p>
Fairly straight forward really.  Start with a regular unit test, that is exercising
some code that is utilizing locks in an attempt to be thread safe.  It looks
like Racer supports just about every form of Synchronization supported by .Net, so
you can feel free to use whichever mechanism you are more comfortable with to get
the work done.  Now that you have a test, the simplest way to make use of Racer,
is to add the Typemock.Racer library reference to your test project, and then add
a ParrellelInspection attribute to the test.  This causes Racer to do it's thing,
which by default means running the test once with a single thread, and then run it
again using multiple threads (2 by default).  If there are no problems, nothing
much new happens.  You see some additional information about the test being run
first with one thread, and then multiple, and something about scenarios executed...nothing
that exciting.  The coolness happens when you actually get a deadlock. 
For starters you test output includes a bunch of new information, the most noticeable
of which is a big "DEADLOCK discovered when running the following" message. 
Also is a description of the scenario that caused the deadlock.  Something like
"Thread 1 acquired lock A, Thread 1 released lock A, Thread 2 attempted to acquire
lock B, etc".  Cooler yet is a message that says "To reproduce or debug this,
copy the following attribute, paste it on top of your test and rerun the test:", followed
by something that looks like 
<br /></p>
        <pre class="brush: csharp" name="code">[SpecificScenario("2", 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2)]</pre>
        <p>
          <br />
Which, while being completely incomprehensible to humans, causes your test to run
in the specific configuration which caused the deadlock to occur.  This means
that you can accurately recreate the exact situation that lead to the problem. 
If you have ever had to try to track down a deadlock in a live system, you will realize
that this information just saved you countless hours of trying to recreate the production
environment, and lots of trial and error getting things into the state that caused
the problem.  One word: Brilliant!
</p>
        <p>
          <strong>So what is the down side?</strong>
        </p>
        <p>
I have to say that I've not yet been able to figure out how Racer determines what
scenarios to run, or what the bits in the "SpecificScenario" attribute mean(well,
the first string parameter is the number of threads, and the other numbers refer to
the specific threads, and match the summary of the scenario, but beyond that, not
a clue).  It would be interesting to know these things, but not really critical,
as long as you are confident all appropriate scenarios are being executed.
</p>
        <p>
There is also an interesting feature that I can't quite get my head around. 
When you run a test with a deadlock, an image is generated, which is supposed to be
a visual representation of the scenario that created the deadlock.  Here is an
example:
</p>
        <p>
          <img src="content/binary/tmp442.tmp.png" border="0" />
          <br />
 
</p>
        <p>
Now, I see the three objects I was locking against (sync1, sync2, and sync3), and
I guess the odd rhombus shaped objects represent the threads, but I'm not really sure
what the diagram is trying to tell me.  This is, no doubt, something which is
still fairly raw in this early version.  I think it could be very useful if it
were clearer what the shapes and arrows represent, but at this point it is simply
a cleaver bit of kit that you can show somebody so that they can be confused too.
</p>
        <p>
The last issue I can see with it currently is the price.  At $890 US for a single
user license, it isn't an impulse buy.  Granted, I think it can pay for itself
easily after finding a few deadlocks in some production code (the earlier they are
found the more that find is worth), but I don't see it being a terribly easy sell
for management, at least if you are not actively trying to correct a threading issue. 
I feel pretty fortunate that I work for a company that understands the value of good
tools, and is willing to provide them if there is a need, but I think it would take
some convincing to get management to agree to purchase Racer simply because it is
a good tool, and could really pay off "one day".  If we were facing a threading
issue, and I could demonstrate that racer would allow us to find it, and accurately
reproduce it, it would be a fairly easy sell.  
</p>
        <p>
          <strong>So overall</strong>
        </p>
        <p>
I think this is an excellent tool.  Based on the fact that this is an early release,
I can only see it getting better over time.  It is a rather pricey tool, however,
so you may have to do some convincing to get the boss-man to get you a license. 
There is a 21-day trial, however, so if you find yourself in a situation where you
either have, or you could conceivably have, a risk of deadlock, then grab the trial,
and use the first detected deadlock as justification to get a full license.  
</p>
        <img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=24aaf20e-9858-42a8-abc0-75f6b7f128b4" />
      </body>
      <title>Review - TypeMock Racer and Unit Testing Multithreaded Applications</title>
      <guid isPermaLink="false">http://www.drrandom.org/PermaLink,guid,24aaf20e-9858-42a8-abc0-75f6b7f128b4.aspx</guid>
      <link>http://www.drrandom.org/2009/06/19/ReviewTypeMockRacerAndUnitTestingMultithreadedApplications.aspx</link>
      <pubDate>Fri, 19 Jun 2009 16:31:17 GMT</pubDate>
      <description>&lt;p&gt;
The folks at &lt;a href="http://www.typemock.com/"&gt;TypeMock&lt;/a&gt; have released a new UnitTesting
tool aimed specifically at catching deadlocks in multithreaded code called &lt;a href="http://www.typemock.com/learn_about_typemock_racer.php"&gt;TypeMock
Racer&lt;/a&gt;, and what's more they are &lt;a href="http://blog.typemock.com/2009/06/easy-deadlock-detection-get-free.html" target="_blank"&gt;offering
free licenses to folks willing to review it during the 21 day free trial period&lt;/a&gt;.&amp;nbsp;
As anyone who knows me can testify to, I am a whore for free-bees, so I decided to
take them up on this.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;For the impatient, here is the executive summary:&lt;br&gt;
&lt;/strong&gt;This is a good tool.&amp;nbsp; Period.&amp;nbsp; It is, however, also a very specific
tool that is intended to help find very specific problems.&amp;nbsp; If you are not doing
any multithreaded code, there is no need to have it in your toolbox.&amp;nbsp; The cost
($890 US) is high enough that it doesn't really seem worth it to get it "just in case"
(unless, of course, you right a nice review on your blog and get a free license).&amp;nbsp;
If you &lt;strong&gt;&lt;em&gt;do&lt;/em&gt;&lt;/strong&gt; work with multithreaded code, and you&lt;strong&gt;&lt;em&gt; are&lt;/em&gt;&lt;/strong&gt; concerned
about deadlocks, this tool will save you lots of time, which ultimately means money.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Now, for the details&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
First of all, this is a tool from TypeMock, so I expected some pretty incredible things,
even at the 1.0 release.&amp;nbsp; After all, their flagship product &lt;a href="http://www.typemock.com/learn_about_typemock_isolator.php"&gt;TypeMock
Isolator&lt;/a&gt; is phenomenally powerful, so much so that the free license I was given
for &lt;a href="http://www.drrandom.org/PermaLink,guid,5200ee4d-d92b-4931-9005-705f523228b1.aspx" target="_blank"&gt;posting
an advertisement&lt;/a&gt; for the release of their ASP.Net product has gone largely unused.&amp;nbsp;
I'm just scared of it.&amp;nbsp; It's like having access to a 50 horse-power tablesaw
with no blade guard.&amp;nbsp; I may be careful enough to use it correctly most of the
time, but the fact that it can take off my forearm without pausing to ask my permission
makes me reluctant to get too close.&amp;nbsp; I do know that there are some very real
problems that the tool can solve that just can't be done with any other tool, so I
have every intent of getting up my courage, grabbing a first aid kit, and jumping
in to see what I can do...eventually.
&lt;/p&gt;
&lt;p&gt;
But Racer is different.&amp;nbsp; It is a very powerful tool with a very specific purpose.&amp;nbsp;
It makes it easier to run tests in multiple threads, and detect deadlocks.&amp;nbsp; As
far as I can tell, it just detects deadlocks, not race conditions, as it's name seems
to suggest.&amp;nbsp; Not that this is bad, just that it only covers half of the rather
shaky ground that is traveled while working with multithreaded code.&amp;nbsp; It is arguable,
however, that dealing with deadlocks is the more difficult of the two problems, so
getting this one tacked first is not a bad thing.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;So how does it work?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Fairly straight forward really.&amp;nbsp; Start with a regular unit test, that is exercising
some code that is utilizing locks in an attempt to be thread safe.&amp;nbsp; It looks
like Racer supports just about every form of Synchronization supported by .Net, so
you can feel free to use whichever mechanism you are more comfortable with to get
the work done.&amp;nbsp; Now that you have a test, the simplest way to make use of Racer,
is to add the Typemock.Racer library reference to your test project, and then add
a ParrellelInspection attribute to the test.&amp;nbsp; This causes Racer to do it's thing,
which by default means running the test once with a single thread, and then run it
again using multiple threads (2 by default).&amp;nbsp; If there are no problems, nothing
much new happens.&amp;nbsp; You see some additional information about the test being run
first with one thread, and then multiple, and something about scenarios executed...nothing
that exciting.&amp;nbsp; The coolness happens when you actually get a deadlock.&amp;nbsp;
For starters you test output includes a bunch of new information, the most noticeable
of which is a big "DEADLOCK discovered when running the following" message.&amp;nbsp;
Also is a description of the scenario that caused the deadlock.&amp;nbsp; Something like
"Thread 1 acquired lock A, Thread 1 released lock A, Thread 2 attempted to acquire
lock B, etc".&amp;nbsp; Cooler yet is a message that says "To reproduce or debug this,
copy the following attribute, paste it on top of your test and rerun the test:", followed
by something that looks like 
&lt;br&gt;
&lt;/p&gt;
&lt;pre class="brush: csharp" name="code"&gt;[SpecificScenario("2", 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2)]&lt;/pre&gt;
&lt;p&gt;
&lt;br&gt;
Which, while being completely incomprehensible to humans, causes your test to run
in the specific configuration which caused the deadlock to occur.&amp;nbsp; This means
that you can accurately recreate the exact situation that lead to the problem.&amp;nbsp;
If you have ever had to try to track down a deadlock in a live system, you will realize
that this information just saved you countless hours of trying to recreate the production
environment, and lots of trial and error getting things into the state that caused
the problem.&amp;nbsp; One word: Brilliant!
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;So what is the down side?&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I have to say that I've not yet been able to figure out how Racer determines what
scenarios to run, or what the bits in the "SpecificScenario" attribute mean(well,
the first string parameter is the number of threads, and the other numbers refer to
the specific threads, and match the summary of the scenario, but beyond that, not
a clue).&amp;nbsp; It would be interesting to know these things, but not really critical,
as long as you are confident all appropriate scenarios are being executed.
&lt;/p&gt;
&lt;p&gt;
There is also an interesting feature that I can't quite get my head around.&amp;nbsp;
When you run a test with a deadlock, an image is generated, which is supposed to be
a visual representation of the scenario that created the deadlock.&amp;nbsp; Here is an
example:
&lt;/p&gt;
&lt;p&gt;
&lt;img src="content/binary/tmp442.tmp.png" border="0"&gt;
&lt;br&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Now, I see the three objects I was locking against (sync1, sync2, and sync3), and
I guess the odd rhombus shaped objects represent the threads, but I'm not really sure
what the diagram is trying to tell me.&amp;nbsp; This is, no doubt, something which is
still fairly raw in this early version.&amp;nbsp; I think it could be very useful if it
were clearer what the shapes and arrows represent, but at this point it is simply
a cleaver bit of kit that you can show somebody so that they can be confused too.
&lt;/p&gt;
&lt;p&gt;
The last issue I can see with it currently is the price.&amp;nbsp; At $890 US for a single
user license, it isn't an impulse buy.&amp;nbsp; Granted, I think it can pay for itself
easily after finding a few deadlocks in some production code (the earlier they are
found the more that find is worth), but I don't see it being a terribly easy sell
for management, at least if you are not actively trying to correct a threading issue.&amp;nbsp;
I feel pretty fortunate that I work for a company that understands the value of good
tools, and is willing to provide them if there is a need, but I think it would take
some convincing to get management to agree to purchase Racer simply because it is
a good tool, and could really pay off "one day".&amp;nbsp; If we were facing a threading
issue, and I could demonstrate that racer would allow us to find it, and accurately
reproduce it, it would be a fairly easy sell.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;So overall&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I think this is an excellent tool.&amp;nbsp; Based on the fact that this is an early release,
I can only see it getting better over time.&amp;nbsp; It is a rather pricey tool, however,
so you may have to do some convincing to get the boss-man to get you a license.&amp;nbsp;
There is a 21-day trial, however, so if you find yourself in a situation where you
either have, or you could conceivably have, a risk of deadlock, then grab the trial,
and use the first detected deadlock as justification to get a full license.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=24aaf20e-9858-42a8-abc0-75f6b7f128b4" /&gt;</description>
      <comments>http://www.drrandom.org/CommentView,guid,24aaf20e-9858-42a8-abc0-75f6b7f128b4.aspx</comments>
      <category>.Net</category>
      <category>Review</category>
      <category>TDD</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.drrandom.org/Trackback.aspx?guid=85ea64f1-6bb7-4046-9045-506697093ddd</trackback:ping>
      <pingback:server>http://www.drrandom.org/pingback.aspx</pingback:server>
      <pingback:target>http://www.drrandom.org/PermaLink,guid,85ea64f1-6bb7-4046-9045-506697093ddd.aspx</pingback:target>
      <dc:creator>Casey Kramer</dc:creator>
      <wfw:comment>http://www.drrandom.org/CommentView,guid,85ea64f1-6bb7-4046-9045-506697093ddd.aspx</wfw:comment>
      <wfw:commentRss>http://www.drrandom.org/SyndicationService.asmx/GetEntryCommentsRss?guid=85ea64f1-6bb7-4046-9045-506697093ddd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recently decided to take the plunge and get <a href="http://www.devexpress.com/Products/NET/IDETools/CodeRush/Index.xml">CodeRush</a> and <a href="http://www.devexpress.com/Products/NET/IDETools/Refactor/Index.xml">Refactor!
Pro</a> (along with <a href="http://www.devexpress.com/Products/NET/IDETools/DXCore/Index.xml">DxCore</a>) loaded
instead of <a href="http://www.jetbrains.com/resharper/">Resharper</a>.  Now,
don't get me wrong, there is a lot I like about Resharper, but overall the performance
was becoming an issue.  There were often problems with VS freezing for no
particular reason, and then coming back as if nothing was wrong...I swear it was like
my IDE had narcolepsy or something.
</p>
        <p>
One of the things I noticed immediately about CodeRush was the fact that there was
a single installer, and when I went to run it I was able to install it on all versions
of Visual Studio, including the Orcas Beta.  This was nice when compared to Resharper's
separate install for vs 2005 and vs 2003.  It also makes me feel good about improvements
in the product being available for all versions of the IDE.  One thing that I
noticed about R# was that there was some work being done in the VS 2005 version around
performance, but that did not seem to trickle down to the VS 2003 version.  I
think the big reason for this is the fact that CodeRush and Refactor! are implemented
on top of DxCore, which provides a very clean abstraction from the scariness that
is the Visual Studio integration layer.
</p>
        <p>
Here are the things I really like about CodeRush/Refactor:<br /></p>
        <ul>
          <li>
The visualizations are stunning!  No, seriously this is some amazing stuff. 
Circles, arrows, animations, eye candy yes, but useful eye candy.</li>
          <li>
The Refactoring Live Preview is crazy brilliant.  <a href="http://www.doitwith.net/">Mark
Miller</a> mentioned this on a <a href="http://www.dotnetrocks.com/default.aspx?showNum=185">DNR
episode</a>, and I agree with his comment that the live preview allows you to discover
new useful refactorings that may not be completely obvious from the name.</li>
          <li>
Performance is great.  'Nuf said.</li>
          <li>
It works with VB.Net.  Granted I don't use VB.Net, but some of my co-workers
do, and occasionally I have to work on VB.Net projects.</li>
          <li>
Dynamic Templates rock.  The fact that I can create a new mnemonic for my type,
and then use predefined prefixes and do <font face="Consolas" color="#808080">vee&lt;space&gt;</font> to
create a new Employee Entity for example is pure bliss.</li>
          <li>
Template contexts are way cool.  By default they have NUnit templates defined,
and with contexts, <font color="#808080">t&lt;space&gt;</font> creates both a TestFixture
class and a Test method</li>
          <li>
Markers and navigation are dreamy.</li>
          <li>
There are some crazy-cool template functions, like the ability to do a foreach within
a template, so things like creating a switch/case statement for all items in an enum
can be done easily.  This also powers a conditional to case refactoring that
is pretty sweet.</li>
        </ul>
        <p>
Here are the things that I miss from Resharper:
</p>
        <ul>
          <li>
Automatically adding a using statement in VS 2003 was sweet.  VS 2005 can do
it with the buit-in intellisense features, but I got very used to it.</li>
          <li>
The VS 2003 test runner was very nice.  I use the <a href="http://www.testdriven.net/">Testdriven.Net</a> plugin,
which I cannot live without, but I like the graphical runner in the IDE.  The <a href="http://www.jetbrains.com/unitrun/">free
test runner</a> from JetBrains is for VS 2005 only, so it doesn't help those of us
in VS 2003.  I do like the fact that they released it as a free tool, though.</li>
          <li>
The "Extract Field" refactoring doesn't exist in Refactor!...This shocked me a lot.</li>
          <li>
The Find Usages task.  This I think is part of the reason why R# was slow, but
it did a brilliant job.  I think the rename in R# was more powerful as well. 
I think there is a rename in Beta for Refactor! that is supposed to be able to work
accross an entire project/solution, but I haven't had a chance to really test it yet.</li>
          <li>
The pre-build error checking is nice.</li>
        </ul>
        <p>
The good news is that the DxCore extensibility model means that most if not all of
these items could be recreated.  The bad news is that there isn't a lot of documentation
around the extensibility model, particularly when it comes to creating new refactorings. 
The test runner is one of the most painful points for me right now, so I've started
exploring the process of creating one using the DxCore APIs.  It opens up the
possibility of refining things too, which would be nice.  What I would really
like would be the ability to detect and integrate with TestDriven.Net.
</p>
        <p>
The folks over at <a href="http://blog.eleutian.com/">Eleutian</a> are evidently <a href="http://blog.eleutian.com/2007/01/28/ProductivityToolsPart1.aspx">running
both</a>, which they claim is possible with some tweaking, but the performance
issues for VS 2003 are the biggest downer on the R# side, so I will probably not go
down that path.  I may load up the test runner for VS 2005, unless I get some
time to try and build one using DxCore, in which case I'll share it with the rest
of the world.
</p>
        <img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=85ea64f1-6bb7-4046-9045-506697093ddd" />
      </body>
      <title>Taking the CodeRush Plunge</title>
      <guid isPermaLink="false">http://www.drrandom.org/PermaLink,guid,85ea64f1-6bb7-4046-9045-506697093ddd.aspx</guid>
      <link>http://www.drrandom.org/2007/07/13/TakingTheCodeRushPlunge.aspx</link>
      <pubDate>Fri, 13 Jul 2007 15:00:21 GMT</pubDate>
      <description>&lt;p&gt;
I recently decided to take the plunge and get &lt;a href="http://www.devexpress.com/Products/NET/IDETools/CodeRush/Index.xml"&gt;CodeRush&lt;/a&gt; and &lt;a href="http://www.devexpress.com/Products/NET/IDETools/Refactor/Index.xml"&gt;Refactor!
Pro&lt;/a&gt; (along with &lt;a href="http://www.devexpress.com/Products/NET/IDETools/DXCore/Index.xml"&gt;DxCore&lt;/a&gt;)&amp;nbsp;loaded
instead of &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper&lt;/a&gt;.&amp;nbsp; Now,
don't get me wrong, there is a lot&amp;nbsp;I like about Resharper, but overall the performance
was becoming an&amp;nbsp;issue.&amp;nbsp; There were often problems with VS freezing for no
particular reason, and then coming back as if nothing was wrong...I swear it was like
my IDE had narcolepsy or something.
&lt;/p&gt;
&lt;p&gt;
One of the things I noticed immediately about CodeRush was the fact that there was
a single installer, and when I went to run it I was able to install it on all versions
of Visual Studio, including the Orcas Beta.&amp;nbsp; This was nice when compared to Resharper's
separate install for vs 2005 and vs 2003.&amp;nbsp; It also makes me feel good about improvements
in the product being available for all versions of the IDE.&amp;nbsp; One thing that I
noticed about R# was that there was some work being done in the VS 2005 version around
performance, but that did not seem to trickle down to the VS 2003 version.&amp;nbsp; I
think the big reason for this is the fact that CodeRush and Refactor! are implemented
on top of DxCore, which provides a very clean abstraction from the scariness that
is the Visual Studio integration layer.
&lt;/p&gt;
&lt;p&gt;
Here are the things I really like about CodeRush/Refactor:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The visualizations are stunning!&amp;nbsp; No, seriously this is some amazing stuff.&amp;nbsp;
Circles, arrows, animations, eye candy yes, but useful eye candy.&lt;/li&gt;
&lt;li&gt;
The Refactoring Live Preview is crazy brilliant.&amp;nbsp; &lt;a href="http://www.doitwith.net/"&gt;Mark
Miller&lt;/a&gt; mentioned this on a &lt;a href="http://www.dotnetrocks.com/default.aspx?showNum=185"&gt;DNR
episode&lt;/a&gt;, and I agree with his comment that the live preview allows you to discover
new useful refactorings that may not be completely obvious from the name.&lt;/li&gt;
&lt;li&gt;
Performance is great.&amp;nbsp; 'Nuf said.&lt;/li&gt;
&lt;li&gt;
It works with VB.Net.&amp;nbsp; Granted I don't use VB.Net, but some of my co-workers
do, and occasionally I have to work on VB.Net projects.&lt;/li&gt;
&lt;li&gt;
Dynamic Templates rock.&amp;nbsp; The fact that I can create a new mnemonic for my type,
and then use predefined prefixes and do &lt;font face="Consolas" color="#808080"&gt;vee&amp;lt;space&amp;gt;&lt;/font&gt; to
create a new Employee Entity for example is pure bliss.&lt;/li&gt;
&lt;li&gt;
Template contexts are way cool.&amp;nbsp; By default they have NUnit templates defined,
and with contexts, &lt;font color="#808080"&gt;t&amp;lt;space&amp;gt;&lt;/font&gt; creates both a TestFixture
class and a Test method&lt;/li&gt;
&lt;li&gt;
Markers and navigation are dreamy.&lt;/li&gt;
&lt;li&gt;
There are some crazy-cool template functions, like the ability to do a foreach within
a template, so things like creating a switch/case statement for all items in an enum
can be done easily.&amp;nbsp; This also powers a conditional to case refactoring that
is pretty sweet.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Here are the things that I miss from Resharper:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Automatically adding a using statement in VS 2003 was sweet.&amp;nbsp; VS 2005 can do
it with the buit-in intellisense features, but I got very used to it.&lt;/li&gt;
&lt;li&gt;
The VS 2003 test runner was very nice.&amp;nbsp; I use the &lt;a href="http://www.testdriven.net/"&gt;Testdriven.Net&lt;/a&gt; plugin,
which I cannot live without, but I like the graphical runner in the IDE.&amp;nbsp; The &lt;a href="http://www.jetbrains.com/unitrun/"&gt;free
test runner&lt;/a&gt; from JetBrains is for VS 2005 only, so it doesn't help those of us
in VS 2003.&amp;nbsp; I do like the fact that they released it as a free tool, though.&lt;/li&gt;
&lt;li&gt;
The "Extract Field" refactoring doesn't exist in Refactor!...This shocked me a lot.&lt;/li&gt;
&lt;li&gt;
The Find Usages task.&amp;nbsp; This I think is part of the reason why R# was slow, but
it did a brilliant job.&amp;nbsp; I think the rename in R# was more powerful as well.&amp;nbsp;
I think there is a rename in Beta for Refactor! that is supposed to be able to work
accross an entire project/solution, but I haven't had a chance to really test it yet.&lt;/li&gt;
&lt;li&gt;
The pre-build error checking is nice.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The good news is that the DxCore extensibility model means that most if not all of
these items could be recreated.&amp;nbsp; The bad news is that there isn't a lot of documentation
around the extensibility model, particularly when it comes to creating new refactorings.&amp;nbsp;
The test runner is one of the most painful points for me right now, so I've started
exploring the process of creating one using the DxCore APIs.&amp;nbsp; It opens up the
possibility of refining things too, which would be nice.&amp;nbsp; What I would really
like would be the ability to detect and integrate with TestDriven.Net.
&lt;/p&gt;
&lt;p&gt;
The folks over at &lt;a href="http://blog.eleutian.com/"&gt;Eleutian&lt;/a&gt; are evidently &lt;a href="http://blog.eleutian.com/2007/01/28/ProductivityToolsPart1.aspx"&gt;running
both&lt;/a&gt;, which they claim is possible with some tweaking,&amp;nbsp;but the performance
issues for VS 2003 are the biggest downer on the R# side, so I will probably not go
down that path.&amp;nbsp; I may load up the test runner for VS 2005, unless I get some
time to try and build one using DxCore, in which case I'll share it with the rest
of the world.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.drrandom.org/aggbug.ashx?id=85ea64f1-6bb7-4046-9045-506697093ddd" /&gt;</description>
      <comments>http://www.drrandom.org/CommentView,guid,85ea64f1-6bb7-4046-9045-506697093ddd.aspx</comments>
      <category>.Net</category>
      <category>Tools</category>
    </item>
  </channel>
</rss>