Coverage with .Net 1.1 and VisualStudio.Net 2003
March 1st, 2006If you're stuck with .Net 1.1 for some reason but still want to know how much of your code is covered by your unit tests, consider having a look at the latest release of TestDriven.Net (by Jamie Cansdale).
As a reminder, TestDriven.Net is an add-in for VisualStudio.Net (all versions) which provides a well integrated support for unit testing, on all the major unit testing frameworks.
Why checking the coverage ? Well it helps you quickly realise that an area of code is weakly tested, and which part of it deserves work, so you can spend some times making it better, before carrying out something more critical.
Here's an (admittedly contrived) example:
Source code:
namespace Samples { public class Calculator { public static int Add(int a,int b) { return a+b; } public static int Mul(int a,int b) { return a*b; } } }
Incomplete unit test code:
using NUnit.Framework; using Samples; namespace Tests { [TestFixture] public class CalculatorTests { [Test] public void Addition() { Assert.AreEqual(12, Calculator.Add(10, 2)); } } }
From the IDE, right click on your test project, select "test with coverage", and the output is...
A few notes:
- if you want to use .Net 1.1 like I do, you'll have to install the former NCover 1.3.3.
- compile in debug configuration
- well... all this comes for free!
Happy testing.
Full sequence of builds with CruiseControl.Net
February 22nd, 2006I use CruiseControl.Net every day: everyone in the team is able to force the build and the publication of the artifacts (binaries+documentation) to the build repository (a network share with the latest versions).
For full releases, either internal or for production use, I need to build all the projects in sequence, and stop the full build if there is an error on a given project.
Until we add the full build workflow in CCNet, I found out that having a master project which triggers all the dependent projects in correct order is quite nice to use:
<target name="build.all"> <property name="serverurl" value="tcp://buildserver:21234/CruiseManager.rem" /> <launchccnetbuild serverurl="${serverurl}" projectname="myproject" /> <launchccnetbuild serverurl="${serverurl}" projectname="mysecondproject" /> <launchccnetbuild serverurl="${serverurl}" projectname="mythirdproject" /> </target>
You can download the launchccnetbuild task source and see the full example on this page.
Campfire / web-based group chat for business
February 20th, 2006Yet another nifty application from 37signals (apart from the free WriteBoard which I already use every week): a web-based group chat for business.
Campfire by 37signals has launched. It’s web-based group chat for business where file transfers work reliably and where you have shared access to the logs.
It’s also dripping with delicious Ajax, courtesy of Prototype maestro Sam Stephenson, who joined 37signals in December along with Marcel Molina. So go check it out. More details about the launch on Loud Thinking and 37signals.
Free tour available.
(through the rubyonrails blog)
Poll: are you using a wiki ? (and for which purposes?)
February 20th, 2006Hi!
I'd like to know how many of you are actually setting up and using wikis for their day jobs . These tools are very commonly used on open-source projects, but what about everyday life ?
My own answer: I'm proposing or setting up a wiki for almost every project I carry out. I use it mostly to write down the answers of frequently asked questions and also when I achieve a task which I know will have to be carried out again (I force myself to write down those little details). At the contrary, I tend to avoid writing down things that change very often.
So well now your turn : are you using a wiki ? How are you using it ?
SCC Provider switcher
February 16th, 2006I'm migrating a customer from VSS to Seapine Surround (quite nice btw).
Sometimes I need to work on the VSS code base for everyday coding, and some other days I need to evaluate the IDE integration of Surround in VisualStudio.Net 2003, use it to see how it interacts with our continuous integration setup, test the branching/merging stuff.
Well I need to change the default SCC provider quite often these days.
If you meet the same need, I quickly found this tool which let me do that without having to deal with the registry base.
FLogViewer - a free logfile viewer with filtering and coloring
February 14th, 2006I had been searching for a free logfile viewer supporting filtering and coloring for a while.
I finally found flogviewer: free, support regexp based filtering, and regexp line coloring. All I need to dive into those 80mb logfiles.

Although not perfect (I find it a bit slow for logfile of 80mb), it does the job really well.
Any other logviewer to suggest ?
Enterprise Integration with Ruby
February 13th, 2006One of my current readings is Enterprise Integration With Ruby. Although still a "beta" book (can be downloaded as a pdf), I really like both the covered topics and the good teaching skills of the author.
The topics covered so far (it's a work in progress) include how to connect to oracle and mysql to generate a mailing csv file (welcome to the heterogeneous world of enterprise computing), how to connect to LDAP, a journey into the world of ORM (starting by do-it-yourself, handwritten sql, then wrapping your own ORM, then using activerecord out of rails), has and belongs to many relationships, xml handling, etc...
For those who don't know Ruby yet, this book is a nice way to get a first grasp on this very nice language, and realise the potential use in your everyday work from a very pragmatic and realistic point of view.
The DRM handling of the pragprogs is also worth noticing: there's no restriction of any kind on the PDF version. Instead, your name appears on each and every page. The book is prepared in a couple of hours, then becomes ready to download.
Have a pleasant and instructive reading!
Learn more about Ruby: Programming Ruby: The Pragmatic Programmers' Guide, Second Edition
Spring.Net, CCNet, RubyOnRails and other news
August 16th, 2005* Spring.Net 1.0 RC1 is out, with most notably the first release of Spring.Net AOP / see the AOP quickstart here. I like the care which has been taken to allow the use of the AOP part without the IOC container.
* CruiseControl.Net 1.0 RC1 is out as well, with the new CCTray version I've blogged about recently (with its own installer), the introduction of native MSBuild support for .NET 2, and a new web reporting application (a unique application for all projects, whereas in the past one would have to create one web application per CCNet project under IIS).
* I've been reading and playing around with Ruby[OnRails] quite a lot, and I pretty much like it, here are two good books about Ruby and RubyOnRails:
- http://poignantguide.net/ruby/ Why's (poignant) guide to Ruby. A free guide to Ruby, with plenty of cartoons in it, probably one of the most funny while very instructive programming book I've read.
- http://www.pragmaticprogrammer.com/titles/rails/ Agile Web Development with Ruby on Rails. This book is definitely worth the price (~18€ in PDF form). No need to say the book deserve the "pragmatic" label, and is a precious piece for getting involved in RoR.
* Some tools I've become addicted to, they help me organize myself better:
- http://www.tadalist.com/ (free online todo lists)
- http://www.backpackit.com/ (nice free version, allows to track todos and notes)
- http://www.basecamphq.com/ (free version for managing 1 project)
These tools are built themselves on top of RubyOnRails and make a nice use of AJAX interfaces.
Voilà!
ReSharper 2.0 EAP has just started
July 21st, 2005Quick post to advertise that the beta version (EAP) of this great refactoring (+much more) tool is freely downloadable there.
[through Laurent Kempé, with full review]
CCTrayMulti
July 18th, 2005I had written a while ago about the need to monitor multiple CruiseControl.Net projects and how to achieve that at that time, through a NAnt script. I find this feature very useful to both an integration/build engineer and a project manager who would like to keep an eye on the overall status of the builds without too much effort.
This kind of tool give me the information I need to know where I stand: am I able to deliver the application ? (yes/no). Am I "on track" like they say in the Navy ?
Since then Graham Tackley from the CruiseControl.Net team has been working on a great tool called CCTrayMulti: a clever replacement of CCTray which allows to monitor multiple CCNet projects at once. Configuration can be achieved from the UI or by editing the XML configuration. You get a single notification icon in the system tray.
You also get a UI to see where are the issues, force the builds etc (a bit like the dashboard, but much more responsive):
As of build 1038, this tool is available in binary form.
Updating managed c++ AssemblyVersion
May 28th, 2005Very sunny in Paris this week end, this all looks very promising.
This week two persons asked me if I had some way to update automatically the AssemblyVersion attribute in a managed c++ project (as I had asked for that a while ago on NAnt lists). The asminfo task does not (yet?) handle MC++, and I needed to update the files instead of generating them. I ended up writing a custom NAnt task which works this way:
<updateversion major="-1" minor="-1" build="${build.number}" revision="-1" verbose="true"> <fileset basedir="."> <include name="**/AssemblyInfo.cs"/> <include name="**/CommonAssemblyInfo.cs"/> <include name="**/AssemblyInfo.cpp"/> </fileset> </updateversion>
The task relies on the following regular expression to match the AssemblyVersion attribute declaration in both C# and managed C++:
Regex regex = new Regex(@"AssemblyVersion[^(]*\(""(?<version>[^""]*)", options);
When the pattern is detected, the current AssemblyVersion is evaluated, then updated. In the example the -1 values mean the matching element will not be changed (I usually just update one item which is the build number). If a joker ".*" is ever met in the version, the end of the version get padded with .0 (eg: 1.0.* will get transformed to 1.0.0.0 before being updated).
What the task does for each file: it removes the readonly attribute if present, read the file content, update all the matches found, write the content back, and finally restore the original attributes on the file.
IMO the implementation would require some cleanup but does the job very well as it is.
How to mock a C# indexer in NMock ?
May 11th, 2005I've been using NMock for a while now. It enforces the already good practice of coding to interfaces rather than to concrete classes, and allows me to test things in isolation, with a pretty accurate understanding of what part of its dependencies a component interacts with.
I'll try to post about that later. For the moment here's a small trick on how to mock indexed properties in C# which I haven't seen documented already.
The following interface uses an indexed property with a getter and a setter.
interface IMyInterface { string this[int index] { get; set; } }
Indexed property accessors code is emitted as get_Item/set_Item methods behind the scene, so here's how to setup expectations for these calls:
DynamicMock mock = new DynamicMock(typeof(IMyInterface)); IMyInterface instance = (IMyInterface)mock.MockInstance; // expect the indexed property getter to be called with index 33 // and return "foo" mock.ExpectAndReturn("Item","foo",(int)(33)); // expect the index property setter to be called with index 40 // and expect the new value to be "fooAgain" mock.Expect("Item",(int)40,new IsEqual("fooAgain")); // test string foo = instance[33]; // will be "foo" instance[40]="fooAgain"; // verify calls after the test mock.Verify();
JetBrains ReSharper really kicks ass
May 11th, 2005I had read it quite a few times on various forums: ReSharper kicks ass, blah blah blah etc, the best add-in ever.
But now that I have *tried* it, I must admit it has seriously changed my life as a coder, to the point that I just feel soooo slow without it!
Here are the features I like most so far, which I use several times a day:
- extract interface
- move class to a new file / new namespace
- introduce variable for selected expression
- change method signature (including add/remove of parameters, reordering)
- find usage of a given method/type
- find inheritors/base
- encapsulate fields into properties
- extract a method (with parameters)
- introduce a parameter
- inline a variable
- customisable live templates
- rename an identifier (and update references)
- generate switch/case for an enum
- auto "using" with alt-enter
- auto cast / safe cast
Yes that's a bunch of features, but I really use them everyday now. Have a look here for all features.
The only bad point I've seen is that with very big solutions, it's slowing down the IDE, and the startup can be longer also.
Do yourself a favor, download the free 30 days trial!
Edit (15/05) : ReSharper 2.0 plans, including an open API...
WinDirStat, another clever usage of TreeMaps
April 16th, 2005_*you may want to read my more recent article for up to date information!*_
A tool I've been dreaming of (yes, almost!): WinDirStat. It's free, and open-source!

Aftern a scan it visualizes your disk space with treemaps, and displays space usage by file type. For instance I was instantly aware of the place taken by my audio recordings and my log files (argl).
This is at least worth 50 points on the geek scale :>>.
First seen on Tobler.Tech().
Edit: the history of treemaps explains that treemaps were actually invented "in response to the common problem of a filled hard disk" (Link from WinDirStat website).
A promising performance profiler for .Net
April 14th, 2005I've started using the new JetBrains .Net Profiler and it seems promising (the beta is available to public).
It helped me pinpoint a thread running managed c++ code which had issues with unmanaged select() calls, causing the application to use 100% CPU. I hadn't been able to properly pinpoint this problem with other tools (mainly, the mixed c++ code seems to often cause problem to profilers, most of the time the application would not even launch through the profiler).
What I especially like with this application (in its current state):
- it's tiny and simple
- the overhead seems to be good compared to other profilers I've tried
- its ability to delay the profiling capture, to start and stop it very simply when needed, and to save snapshots for later review.
I really like this convenient tool.
Then a question to you readers: which profilers (for both performance or memory) are you really using for your developments ?