warning: Creating default object from empty value in /home1/seocactu/public_html/csharptocsharp/modules/taxonomy/taxonomy.module on line 1388.

Here are my favorite Firefox add-ons

Web Developer tool bar (gotta love Ctrl+Shift+f)

Firebug (the best javascript debugger and more)

Html Validator (great for seeing all your awesome htmlz c0dez)

Sqlite Manager (the version for Firefox 3.5 is much improved)

Greasemonkey (custom scripts)

Modify Headers (I use to test other user agents)

Live Page Rank (get google page rank for the site you're on)

Search Status (lots of SEO goodies)

Add n Edit Cookies (easily add and/or modify cookies)

Remove Cookies for Site (removes cookies only for the site you're on)

ColorZilla (eyedropper tool to get any color on a web page, in an image, or html)

refspoof (change the referring url)

YSlow (figure out why your site is slow :( )

Hackbar (test your site with various sql injection strings)

I work for a fabulous company, I've been with them for about 3 years. They are incredible about making sure developers have what they need to get the job done, whether it's software or hardware (or classes, or books). In fact, I'm on my third development machine! Most software requests are usually also granted.

So what does your gear look like? What development software has your company gotten for you to help better your work?

This is what it looks like for me:(as of posting)


  • Windows XP 64, core 2 quad @ 2.5 GHz, 8 gigs of ram
  • 3 19 inch widescreen monitors
  • microsoft natural ergo keyboard
  • trackball mouse
  • physical server 03 box [for testing]
  • various XP/03 virtual machines [more testing]


  • Resharper 4
  • dotTrace
  • NDepend
  • NCover complete
  • RegexBuddy
  • BareTail Pro
  • All the microsoft dev. stuff (VS 03,05,08, SQL server 05,08)
  • Snag it
  • ultramon

What about you?

kick it on

This post will allow you to unit test objects that have a dependency on a SqlDataReader by mocking/stubbing a data reader.

Here I've made a 'wrapper' of sorts for the good ol' Microsoft SqlHelper class, which is ancient now, ya? Since the SqlHelper.ExecuteReader's method class implements the IDataReader interface we're in luck.

public interface IFetch {
//add members as necessary
IDataReader ExecuteDataReader(string connectionString, 
string storedProcedureName,SqlParameter[] parameters);
public class Fetch : IFetch {
public IDataReader ExecuteDataReader(string connectionString, 
string storedProcedureName, SqlParameter[] parameters){
return SqlHelper.ExecuteReader(connectionString, 

Next we create our object from the results of our IDataReader. The SqlHelper class removes the worry about mocking SqlCommand and SqlConnection classes. All you need to worry about are the results (SqlDataReader).

(You can make your own RockStar object, fo sho.)

Whether you call it constructor initialization or constructor chaining, we have it here, and will allow us to inject the correct dependency, in this case, an interface that defines an ExecuteReader method. (I've never gotten into DI/IoC frameworks, should I, and which??)

private readonly RockStar rs;
private readonly IFetch fetch;
//here's the magic sauce for the unittests
public FetchCms(IFetch fetch, RockStar rs){
this.fetch = fetch; = rs;
//production code calls this which calls 
//the other constructor. mmm.
public FetchRockStar() : this(new Fetch(), new RockStar()) { }
public RockStar GetRockStar(string urlToLookup){
var parms = new[] { new SqlParameter("@urlName", urlToLookup) };
using (IDataReader reader = 
fetch.ExecuteDataReader("localhell", "rockstar_page_get",parms)){
if (reader != null && reader.Read()){
rs.Name = reader["name"].ToString();
rs.Guitar = reader["guitar"].ToString();
//add some logic... and so on...                       
catch //swine flu
return fs;

ok, so now your production code is hawt, but how do you 'fake' a reader, or 'fake' its results? Good question, but never fear, Phil Haack has you covered with his totally rock-tacular StubDataReader class. Get it.

so now, in your UnitTest project...

I'm creating some fake results that I can use to test my expectations, using the StubDataReader class you've downloaded above and added to your UnitTest project.

private static StubDataReader getData_Kerry_King(){
var resultSet = new StubResultSet("name", "guitar");
resultSet.AddRow("Kerry King", "B.C. Rich");
return new StubDataReader(resultSet);

I'm using the Moq framework to mock my interfaces. (it's from an older release, hence the Expect calls rather than the Setup calls [anyone: what does the new version get me?])

public void Execute_DataReader_Test() {
var m = new Mock<IFetch>();
//here i'm expecting that my ExecuteReader implementation
//return my 'fake' data
x => x.ExecuteReader(
var rockStar = new RockStar();
// pass IN the interface using the special constructor.
var fetch = new FetchRockStar(m.Object, rockStar);
rockStar = fetch.GetRockStar("kerry-king");
Assert.AreEqual("Kerry King",rockStar.Name);
Assert.AreEqual("B.C. Rich",rockStar.Guitar);

Even Kerry thinks you should be testing!

kick it on

So in my first Log4Net Config post a weee time back, I talked about a hot way to configure your log4net settings using a composite, rolling logging model.

Here, I have that same log4net config, but done in code! It doesn't have the same flexibility of the web.config or an xml file if you're frequently changing values--since you'd have to push code for any changes--but it does make any logic easier.

It begs the usage of preprocessor directives for setting File [location], PatternLayout, or Threshold.

log4net.Appender.RollingFileAppender a = 
new log4net.Appender.RollingFileAppender();
a.Name = "RollingFileAppender";
a.File = @"c:\\log.txt";
a.AppendToFile = true;
a.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Composite;
a.MaxSizeRollBackups = 14;
a.CountDirection = 1;
a.MaximumFileSize = "15000KB";
a.StaticLogFileName = true;
a.Layout = new log4net.Layout.PatternLayout(@"{%level}%date{MM/dd HH:mm:ss} - %message%newline");
a.Threshold = log4net.Core.Level.Debug;

(Thanks to my buddy J.A. for showing me this).


kick it on


When rockin' out the NAnt build process, I thought it was necessary to have a folder that accurately states the build version/number of the enclosed assembly. I'm sure I could have done this w/code, but eff that... I wanted to have a bit of fun, trying the <code> tags from within the build file itself.

Given a path to an assembly, ${build.dir} will echo something like:


I've found it handy for:

  • Doing something at build time wo/another console app.
  • Keeping track of builds (duh)
  • Impressing the ladies.

(Sorry about the whacked formatting!)

<property name="build.dir" value="build" />
<property name="pathToAssembly" value="C:\your\moms\house\nice.dll" />
<target name="getbuildnum">
<script language="C#" prefix="method" >
<import namespace="System.Reflection" />
public string GetVersionFromAssembly(string assPath) {
Assembly ass = Assembly.LoadFrom(assPath);
return "build-"+ass.GetName().Version.ToString()
<property name='build.dir' value='${method::get-version-from-assembly(pathToAssembly)}' />
<echo message='${build.dir}' />

kick it on


So just a quickie post. NAnt doesn't play very nicely with the MSBuild task especially with .NET 3.5, so I thought I'd post a snippet from a build file that I think I finally like (and works!).

* project has been renamed [to csharptocsharp] to protect the innocent lame!

<property name="msbuild" value="C:/WINDOWS/Microsoft.NET/Framework/v3.5/MSBuild.exe" />
<target name="compile" description="Compiles using the AutomatedDebug Configuration">
<!-- NAnt doesn't like this part! :( -->
<!--<msbuild project="src\">
<property name="Configuration" value="AutomatedDebug" />
<!-- So we just use an exec task instead!-->
<exec program="${msbuild}">
<arg value="src\" />
<arg value="/v:n" />
<arg value="/p:Configuration=AutomatedDebug" />
<arg value="/p:WarningLevel=0" />

kick it on


This isn't really new, I know, I know I've heard it all before about ReSharper. "ReSharper is ok but...," or "It's expensive..." or "Blah blah ReSharper...," or some other comment from some jerky developer deeming it useless. Even if you think the rewards aren't that great in terms of orgiastic programming results;
think about your hands (and fingers), and all the wasted keystrokes. Damnit.

Scott Hanselman discusses the programmer's hands and how important they are to your career (BC: and of course, your life). Although ReSharper may not indeed save you from some terrible hand condition... Everything helps.

I spent hours a day for years in my past life as a classical musician honing finger movements for ultimate efficiency. Why? Because you want to be able to pick your nose when your 80.

Yes I have a crazy ergo keyboard and trackball rat.

In any case. My comment to the unbelievers is:

Have fun wasting your time. [loser]

I am in no way affiliated with ReSharper, JetBrains, or any other Visual Studio plugin like CodeRush. I'm just a coder d00d. But, like me, if you're in a situation where the company you work for supports time-saving tools for their developers, then you need some sort of Visual Studio add-on (or whatever IDE) like this.

I've tried "convincing" other developers and showing them how awesome it is--turning a huge list of private items to public getter/setters should have been enough--but no one seems to care! For me: incorporating, LINQ and extension methods in 3.0 is the best part. For months I dealt with all the broken [looking] LINQ queries with ReSharper 3.1--but no more!

So to anyone that hasn't tried it for Visual Studio 2008... here are the ReSharper 4.0 nightly builds for your pleasure...

And for anyone else I say: remember your digits... and I give thee this.

broken developer finger

kick it on

So, you've got a remote desktop connection that has gone haywire. Looks like explorer has hung up, and crashed.

For some reason you're on your Vista boot camped-MacBook so the Control+Alt+End key combination is nonexistent. You were smart enough to install Launchy 'cuz it rokks and 'cuz Mike Duncan said so. What do you do?! Never fear... Launchy to the rescue!

(Sexy new Launchy 2.0 interface.)

There are all sorts of hot features with Launchy besides opening applications. Searching google, calculations, weather, indexing... If you're like me, then you like to use your keyboard more than your rat mouse. (I wish I could get a MacBook type trackpad built into my MS ergonomic keyboard). Then I'd give that rodent to the ratatatCATs.

Now at version 2.0 all you need to do is a little Alt+Space action to bring up that beast. Type "explorer" to bring your desktop back from the dead and you're back in business. Baby.


kick it on


About Brian

profile for bluevoodoo1 on Stack Exchange, a network of free, community-driven Q&A sites

Brian Canzanella brings you nifty tips and tricks for most things .NET. read more...

Readers / Stuff