The Nifty Dozen
The 12 Free .NET Development Tools Every Programmer Should Use
© Philippe Lacoude
Washington,
D.C.
April 2005 (Version 1.1)
|
|
Summary
The following pages list significant open source or freeware
contributions to the .NET software development community.
If you have not downloaded and tried these tools, you are probably
stranded on a desert island, away from civilization.
If you have not yet adopted at least two or three of these twelve
tools for your every day activities, you are voluntarily reducing
your productivity.
If you are not using these tools because your IT department came
up with the bright idea that you should not install software
downloaded off the Internet on your corporate PC, well, there are
web sites where you can post your résumé.
Content
Microsoft FxCop 1.312
Spotting Code Defects
Respecting Coding Standards
Learning Coding Standards
NUnit
NDoc
.NET Reflector
.NET Resourcer
CLR Spy
Sharp Develop
Visual XPath
NAnt
Fiddler
Vil
OlyMars
http://www.gotdotnet.com/team/fxcop/
Spotting Code Defects
Can you spot the 10 problems in the 10 lines of code below?
namespace FxCopTest
{
class test
{
static void Main(string[] args)
{
System.Console.WriteLine(MultiCopy.Dup("Test", 10));
}
}
public class MultiCopy
{
// Duplicating function
public static string Dup(string Input, int MaxVal)
{
if (Input == "") return "";
int i; string s = "";
for(i=1; i<=MaxVal; i++) { s += Input; }
return s;
}
}
}
If you cannot, try Microsoft FxCop 1.312: Running
against the above code, FxCop found 10 defects: 2 warnings, 5 errors and
3 critical errors.
Respecting Coding Standards
Microsoft FxCop is an application that analyzes managed code
assemblies and checks their conformance to recommended .NET programming
standards.
Because this application does not analyze the source code but rather targets
the resulting compiled code, it can analyze programs written in any .NET
language.
FxCop exists in two flavors: as a graphical user interface
(FxCop.exe) for interactive work and as a command-line tool (FxCopCmd.exe)
that can be used to perform batch analysis of large projects.
The later version is particularly interesting for a security team that wants
to scan all .NET code of an organization for security defects.
The first time you use FxCop, you may be surprised by the number
of glitches contained in your programs, unless you are a first rate .NET
programmer with an intimate understanding of the Framework: FxCop checks
hundreds of rules and generally finds errors on design, localization, performance
and security.
The rules are an analytical translation of Microsoft's .NET Framework Design
Guidelines.
If you are not convinced of the power of FxCop, download it
and run it against one of Microsoft's own .NET Framework library.
FxCop came to existence after the release of the 1.1 version of the
Framework.
As a consequence, even Microsoft programmers let some defects slip through the
product.
If Microsoft programmers did not get it right with some of the .NET Framework
1.1 libraries, and unless you run FxCop, how can you be sure you do not
have issues with your own code?
Learning Coding Standards
A final argument in favor of using this product on a daily
basis is that it improves a programmer's coding abilities.
After about six months, you start fixing the bugs by yourself before even
running the tool.
The quality improves by a quantum leap.
The tool has definitive educational benefits.
For managers, forcing FxCop on developers is also the assurance of
eliminating some subtle security glitches that could compromise security.

Figure 1 - Analysis of the System.Messaging Assembly Using FxCop 1.312
http://www.nunit.org/
NUnit is a unit-testing tool for the Microsoft .NET
Framework.
It is analogous but not identical to JUnit on the Java platform.
Like many .NET open source products, NUnit current's version (i.e. version
2.2.0 at the time of this writing) is written in C#.
This tool has fostered a lot of activity in the open
source community which quickly came up with three very nice derivatives
of this tool:
- A
follow up from NUnitAddIn, Test Driven .NET is a Visual Studio add-in for
NUnit.
The tool can be found at
http://www.testdriven.net/
- NUnitASP
can be used to test web sites by interacting programmatically with the
controls on the web page.
The tool, which can be found at
http://nunitasp.sourceforge.net/,
is meant to test the ASP.NET code-behind only:
- It
does not replace load testing with Microsoft Application Center Test
(ACT)
- It
will not help with JavaScript defects
- It
is not very useful for a QA team to create acceptance tests either.
- NUnitForms
is the Windows Forms equivalent of NUnitASP.
One very cool feature is that it includes a recorder application.
It allows writing tests without resorting to WinRunner or to programming
using the Shell object.
The tool can be found at
http://sourceforge.net/projects/nunitforms/
http://ndoc.sourceforge.net/
NDoc is an open source development tool available under
the GNU General Public License.
NDoc automates the generation of documentation.
NDoc uses the .NET assemblies and the XML documentation files generated
by the C# compiler.
For VB.NET programmers, NDoc can still be useful as it is able to process
the XML documentation files created by VB.NET add-ons (such as VBCommenter.)
NDoc adds a handful of XML tags to the documentation tags
defined in the C# Programmer's Reference.
In particular, NDoc has XML tags to document the
<event>,
<threadsafety>
and <overloads> behavior of a method or of
a class.
The strong selling point of NDoc, aside its unbeatable price ,
is that unlike Visual Studio .NET 2003, it can create multiple documentation
formats:
- MSDN-style
HTML Help format (.chm)
- Visual
Studio .NET Help format (HTML Help 2)
- MSDN-online
style web pages
If your code changes frequently and if you are under pressure
to keep the documentation up-to-date, NDoc is the definitive tool to use.
Of course, on the other hand, good code speaks for itself, commenting is for
beginners, commenting is a hurdle, we do not have time to comment our code,
and we probably understand the code we wrote...
http://www.aisto.com/roeder/dotnet/
Lutz Reoder's .NET Reflector must be one of the nicest freeware
tools: this tool has an appealing interface that shows the great
attention to detail that went into this product.
Even the “About” dialog box is worth looking at!
Like the Microsoft .NET Framework IL Disassembler (ILDASM.EXE),
.NET Reflector lets you view inside of a compiled assembly, class, method,
property or type and translates back the binary values into more readable
intermediate language (IL) code.
Unlike ILDASM, the .NET Reflector can actually translate back
assemblies into more than just IL code: it can generate VB.NET, C# and
Delphi code from the IL.
This means that you can look inside the new VB.NET program you just wrote
and regenerate its code as C#.
This makes this product almost unique and highly valuable.
The product has some minor limitations: after downloading
it, one of my first tests was to have it translate back a compiled VB.NET
filtered structured exception handling (SEH) block into C#.
Because the latter does not support this CLR feature, the .NET Reflector
had to replace the VB.NET filtered SEH by a series of question marks.
Similar nasty tests yielded the same results: if a CLR feature is not
implemented by VB.NET, C# or Delphi, the .NET Reflector does not create a
workaround.
This task is left to the developer.
This issue notwithstanding, .NET Reflector translates 99%
of the IL code back into one of three languages.
A nice exercise is to look into the original .NET Framework classes to
learn how they were first implemented.
For example, the following screenshot shows the implementation of the
System.Collection.BitArray.CopyTo
(Array, Int32)
method:

Figure 2 - .NET Reflector's Translation of a System.Collection Method
http://www.aisto.com/roeder/dotnet/
Lutz Roeder's .NET Resourcer is an editor for the resource
files used by the .NET framework.
The software comes with the same slick interface used by the .NET Reflector,
also developed by the same individual.
The Resourcer is particularly useful for people who do not
use the Visual Studio .NET 2003 environment. The Resourcer allows the
manipulation of the binary and XML file formats.
It is invaluable if you want to integrate icons and bitmaps to .NET
applications.
http://blogs.msdn.com/adam_nathan/
The CLR Spy tool is a C# program that uses a new feature of
the CLR 1.1 called the “Customer Debug Probes”.
Once you specify applications, the tool allows you to monitor calls and
marshalling between the .NET IL code and the native code.
Naturally, since all these probes relate to the interoperations between the
.NET runtime and the native operating system, the CLR Spy does not record
any activity from .NET programs that do not use COM Interop or P/Invoke.
The probes cover four categories: error probes, warning
probes, info probes and a miscellaneous category that tracks buffer issues
and premature garbage collection of instances of classes that point on
unmanaged objects.

Figure 3 - CLR Spy Monitoring .NET Reflector and Visual Studio .NET 2003
http://www.icsharpcode.net/OpenSource/SD/
SharpDevelop is by far the most impressive of all the .NET
open source software products reviewed in this document.
It is a complete, professional looking IDE.
It compares very favorably to Microsoft's Express Edition of Visual Studio.
It probably has more features than this latter product.
A big difference between Visual Studio and SharpDevelop is that the open
source IDE was written entirely in Visual C#.
It does not mix managed .NET portions with C/C++ binary code.
SharpDevelop highlights the code, supports CVS for source
control, integrates code completion functionality (for C# programmers) and
uses “combines” where Visual Studio uses “solutions”.
Like many large sophisticated applications, SharpDevelop is extensible through
add-ins.
This allows extensibility of SharpDevelop, multiple language support, integrated
unit testing from within the IDE, and a small but neat regular expression
validating editor.
Even if you are an obstinate Visual Studio .NET 2003 Enterprise
Edition user, which is still a richer product, SharpDevelop is a must see.
The tool is a great tutorial for .NET programmers because it was written from
scratch using nothing but C# and because the source code is available to
users.
In the same rubric, let us add that the SharpDevelop source code comes with a
very interesting “SharpDevelop
C# Coding Style Guide 0.3”, which could apply to more than this
single product.

Figure 4 - SharpDevelop in Action
http://weblogs.asp.net/nleghari/
Visual XPath is a graphical interface that generates XPath
queries.
After loading an XML document, you can expand the nodes of this document and
Visual XPath displays the XPath query string corresponding to the selected
node.

Figure 5 - XPath Query for a Sub Node of an Arbitrary Document
Once you have selected the node you are interested in, the
tool can generate the corresponding C# code for you:
using System;
using System.Xml;
using System.Xml.XPath;
public static void RunXPath()
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"C:\Program Files\VisualXPath\customers.xml");
XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsMgr.AddNamespace("ixq","http://www.ipedo.com/XQueryExample");
XmlNodeList nodes =
xmlDoc.SelectNodes("/ixq:customers/customer[1]/custno/text()",nsMgr);
foreach(XmlNode node in nodes)
{
// Do anything with node
Console.WriteLine(node.OuterXml);
}
}
The upside of using Visual XPath is that you will not need to
learn the XPath syntax.
The obvious downside is that you will miss a lot of the intellectual amusement
that comes with learning the geeky syntax of XPath.
http://nant.sourceforge.net/
Although NAnt stands for Not Ant, NAnt is similar to its Java
cousin Ant (http://ant.apache.org/)
in more than one way.
First and foremost, it serves the same purpose: writing stable and reproducible
build scripts.
Like Ant, NAnt was designed to be free of the O/S platform dependencies inherent
to the use of tools such as make,
nmake, and gnumake.
Ant and NAnt do not implement their functions using shell-based commands but by
adding Java and .NET classes (respectively) that implement the various tasks of
the build process.
The differences between Ant and NAnt start to appear as soon as
one scratches under the surface.
Like Visual Studio solutions, NAnt uses XML-based configuration files to describe
the build process[1].
The default build for the basic “Hello, World!” program looks like
this:
<?xml version="1.0"?>
<project name="Hello World" default="build" basedir=".">
<description>The Hello World of build files.</description>
<property name="debug" value="true" overwrite="false" />
<target name="clean" description="remove all generated files">
<delete file="HelloWorld.exe" failonerror="false" />
<delete file="HelloWorld.pdb" failonerror="false" />
</target>
<target name="build" description="compiles the source code">
<csc target="exe" output="HelloWorld.exe" debug="${debug}">
<sources>
<includes name="HelloWorld.cs" />
</sources>
</csc>
</target>
</project>
Although the current version of NAnt at the time of this writing
is 0.85, do not get fooled by the version number: NAnt is a first grade product
that has been around since .NET Beta 1 and was first released to the public
(via SourceForge) in August 2001.
If you care about Software Configuration Management, you probably
want to use NAnt. One more reason to use it is that it is free.
http://www.fiddlertool.com/fiddler/
The Fiddler PowerToy is a sophisticated proxy server that can
capture web traffic between a browser and a web server.
Although it is mostly used to debug HTTP web traffic resulting from the
interaction of the browser with the web server, it can also capture web
services' traffic.
Fiddler allows programmers to set breakpoints in applications,
stop the traffic based on flexible target criteria and modify the content of
the requests or the responses.
The tool is easier to use than Network Monitor because the traffic is presented
in clear text and only represents the data exchanged at the top ISO layers.
It is also easier to use than re-running captured scripts recorded with
Microsoft Application Center Test.
The tool can test performance: programmers can visualize the
time that requests take to process.
Fiddler can be extended in two manners:
- Fiddler
can be scripted using JScript .NET
- Fiddler
can use special add-ins assemblies written in any .NET language
and commonly known as Inspectors.
Inspectors define two interfaces for response or for request
related tasks.
By default, Fiddler ships with a dozen of inspectors.

Figure 6 - Fiddler capturing Fiddler Web Site Traffic
http://www.1bot.com/
There is not anything vile about Vil.
Quite the contrary.
Like FxCop, Vil is a piece of software which was designed to spot defects in
your coding style.
However, its spirit is radically different than that of FxCop.
While FxCop concentrates on the micro-side of programming, Vil takes a
macroscopic approach to code analysis, providing global statistics on
assemblies.
Vil computes interesting metrics.
To name a few:
|
LOC
|
The lines of code (LOC)
are the lines of intermediate language instructions.
|
|
DIT
|
The depth in tree (DIT)
is the inheritance depth which starts at 0 for the
System.Object
and increases by 1 with each level of inheritance.
|
|
eCouplings
|
The efferent couplings (or
eCouplings) are the number of types
inside the “subject” module (or assembly) that depend
on types in other modules (or assemblies.)
|
|
aCouplings
|
The afferent couplings (or aCouplings)
are the number of types in other modules (or assemblies) that depend
on types within the “subject” module (or assembly.)
|
|
Instability
|
The instability of the module (or assembly) is defined by
the ratio of
eCouplings /
(eCouplings + aCouplings)
If a “subject” module depends on other modules,
which in turn reference the “subject” module, then the module
is deemed unstable: if the above ratio indicates stability when it equals
to '0' while '1' indicates instability.
|
|
ImpTypes
|
The ImpTypes is the number of
types (classes and structs)
that can have implementations.
|
|
Abstractness
|
The percentage of all types which are abstract
(including interfaces.)
|
|
LCOM
|
The lack of cohesion of methods (LCOM)
is the extent to which instance methods use the instance fields of a
class/struct
(excluding the static methods and fields.)
|
|
Tryblocks
|
Number of “try”
blocks within a method.
|
|
maxStack
|
Maximum size of the evaluation stack of a method or
constructor at runtime.
|
Vil is a command-line utility:
vil /Assembly=MyLib.dll /m=LOC,DIT,instability,tryblocks /sc=all /s=loc /h/ /nix
http://www.microsoft.com/france/msdn/olymars
Also known as the “SQL Server Centric .NET Code
Generator”, OlyMars is a very powerful code generator based on
database modeling.
Simply by selecting a target database, OlyMars allows instant
generation of both SQL and .NET code.
The end result is a solid library that segregates the data layer (SQL code),
the data access layer, and the business objects.
The tool includes numerous templates to generate business component layers,
.NET Compact Framework code, and web service classes.
The latest builds support the web services extensions (WSE 2.0).
The tool eliminates the repetitive task of coding methods to
access stored procedures.
The tool is complex to use and requires some investment of
one's time.
Part of the complexity is due to the fact that the program generates code
that follows the business faade pattern: OlyMars is easier to master for
programmers used to create large scalable enterprise solutions.
That said, the payback is immediate, because the time it takes to learn
this tool will be much less than writing C# database code from scratch
for your next application.

Figure 7 - A C# Library for the Northwind Database Generated by OlyMars
|