Monday, January 29, 2007

FXCop Custom MSBuild Task

FXCop is great for checking code, and it's easy enough to run the command
line utility from MSBuild. This will run the analysis and produce a report
of all the issues, but this has no "teeth", that is, nothing makes anyone
look at the report and fix the issues. In order to have FXCop actually
break the build you need to write a custom task the following is an example
of a simple task that breaks the build if there are any issues. It does
need to be told where to find the report via the report location property

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Tasks;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.IO;
using System.Reflection;
using System.Diagnostics;
using System.Xml;

namespace Framework.Build.CustomTasks
public class CheckFXCop : Task

private string _reportLocation;

public string ReportLocation
get { return _reportLocation; }
set { _reportLocation = value; }

/// <summary>
/// Executes the Task
/// </summary>
/// <returns>true if the task successfully executed; otherwise,
public override bool Execute()

bool returnVal = true;
int numIssues = 0;


FileStream xmlFileStream = new
FileStream(this.ReportLocation, FileMode.Open);

XmlTextReader fxReport = new XmlTextReader(xmlFileStream);

while (fxReport.Read())

if (fxReport.LocalName == "Issue")
returnVal = false;


if (!returnVal)

Log.LogError("There are " + numIssues.ToString() + "
FXCop issue(s). Please review the report");


return returnVal;

return false;




Thursday, January 25, 2007

Handling alerts in WATIN

Update: I posted a response awhile ago as a new blog entry

One of the most common user interaction on a website is the javascript
"alert" funcions.
With a syntect of:


This function displays a message to the user and requires that they click a
button labeled OK before continuing.

Creating an automated test for a website that uses this poses a couple of
problems. First the is no DOM object
for the window, and second the window runs under a different thread then the
main browser window. Luckly any
web automation tool worth its salt will address both these issues and WATIN
is no exeption. The following code is an
example of how to use the alertdialog handler.

using( IE ie = new IE("http://hostname/pagename.htm"))

AlertDialogHandler alertDialogHandler = new AlertDialogHandler ();
using (new UseDialogOnce(ie.DialogWatcher, alertDialogHandler ))

* -- code to generate alert -- *
* *
* must use the "nowait" to allow *
* the code to goto the next line *
* *






Wednesday, January 24, 2007


I've been messing about with WATIR for awhile now and am very impressed. Very powerful, very flexible and I love any excuse to learn a new language (ruby). However, most of my coworkers do not share my thirst for knowledge. Nobody seamed interested in the amazing things that I was doing. Guess they were to busy getting the bug count down, forget that what I'm doing could keep it from getting high in the first place. Knowing this I've moved on to WATIN which so far seems to have most of the same features comes with an IDE and intellisense. Oh and lets not forget the US Navy and its list of approved software. The couple of DLLs that make up watin can be included in a project, but I don't think that an entire interpreter could be thought of in the same way.

New Blogger

So I'm on the new blogger now. To be honest, I'm not sure what that means exactly. But hey, if it's new it must be better right?

Monday, January 22, 2007

Super Hero Results

Your results:
You are Green Lantern

Green Lantern
Iron Man
The Flash
Wonder Woman
Hot-headed. You have strong
will power and a good imagination.

Click here to take the Superhero Personality Test