.NET Developments - A SearchWinDevelopment.com Blog

.NET Developments:

 

A SearchWinDevelopment.com Blog


A blog on all things .NET, with news and tips about Visual Studio, ASP.NET, Visual Basic programming, C# and .NET architecture.

TFS to the rescue — almost

(Editor’s note: This is the first blog post by Christopher Yager, who will be writing on the .NET Developments blog from time to time. Yager is chief software architect at GLD Solutions Inc. and is currently using .NET 2.0 for his new development projects. Here he will blog about topics such as Windows Communication Foundation, Team Foundation Server and SQL Server. Welcome aboard, Chris!)

Before I get into this — welcome to my blog.  I’ll be posting mainly about my adventures in .NET programming — feedback is welcome.  I’m no guru but I did stay at a Holiday Inn Express last night.  (Actually as I write I’m still at said Holiday Inn… )

So TFS (Team Foundation Server), Microsoft’s answer to the software lifecycle management problem, really is a great product.  My team uses most features on a daily basis.  My headline is somewhat misleading but allow me some latitude while I state my case.  I run a software development company.  We produce software products and we have customers that use them.  (Go figure.)  We have a QA staff.  We test our products.  TFS has no way to capture the guts of a user defined test against a product that tests a particular requirement.  Specifically we needed to save metrics of test runs with success and failure rates, reasons for failure, environments tested, and lot of other neat stuff.  I didn’t expect TFS to have all this rich user testing goo so I expected we’d roll our own.  This article is about how we connected our hand-rolled testing metrics program with our Team Foundation Server.

The problem:  A scenario test fails; a bug is created against a product/task/whatever and needs to be linked to the test that caused the problem.

The Solution:  The TFS API!

Team Foundation Server has a plethora of components that you can leverage allowing seamless integration with the back end of your TFS implementation.  These components are found in the following path normally: 

[Program Files Root]\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies

**Client requirement: On any system you install your custom TFS linked software, Team Explorer must be installed.  An obvious server requirement is that you have a Team Foundation Server installed somewhere in your network or available via the Web.  If you’re interested in getting TFS running (and why wouldn’t you be?!) you can download a trial from Microsoft.

Our general requirement for this task was to view a list of active bugs for a team project and allow selection of one. 

OK — some meat for you code monkeys. 

Create a windows forms project in your favorite language.  Mine is C# but any .NET language will do.

Add references to the following assemblies.  You’ll need to browse for them since they are not in the GAC or otherwise registered for easy VS reference adding.  The image shows them all together but this is a doctored image to save space.

tfs references

Put a tab control on the form and set it to dock-fill (leave the 2 tab pages alone), size the form to 800X600 (this just saves us some time and coding).

We’re basically going to create two functions that perform the guts of the scenario.  The GetWorkItems function which utilizes the DomainProjectPicker dialog class to allow the user to select the team project they wish to examine and the PickWorkItemsControl user control which allows searching of the TFS work item store. 

                   

private void GetWorkItems()
{
    DomainProjectPicker dpp = new DomainProjectPicker();
    DialogResult dr = dpp.ShowDialog(this);
    if (dr == DialogResult.OK)
    {
        tfs = dpp.SelectedServer;
        tfsProject = dpp.SelectedProjects[0];
        this.Text = "My Team Foundation Link - " + tfsProject.Name;
        Store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
        TeamProject = Store.Projects[tfsProject.Name];
        pw = new PickWorkItemsControl(Store);
        pw.Dock = DockStyle.Fill;
        pw.PortfolioDisplayName = TeamProject.Name;
        this.tabPage1.Controls.Add(pw);
        pw.PickWorkItemsListViewDoubleClicked +=
            new PickWorkItemsListViewDoubleClickedEventHandler(
            pw_PickWorkItemsListViewDoubleClicked);
    }
}

The InitWorkItemControl function allows the user to view the details of a selected work item and utilizes the WorkItemFormControl control.


private void InitWorkItemControl()
{
    this.WorkItemControl = new WorkItemFormControl();
    this.WorkItemControl.Dock = System.Windows.Forms.DockStyle.Fill;
    this.WorkItemControl.FormDefinition = null;
    this.WorkItemControl.Item = null;
    this.WorkItemControl.LayoutTargetName = "WinForms";
    this.WorkItemControl.Name = "WorkItemControl";
    this.WorkItemControl.Size = new System.Drawing.Size(683, 428);
    this.WorkItemControl.TabIndex = 0;
    this.tabPage2.Controls.Add(this.WorkItemControl);
} 

We’ll tie this all together in the constructor for the form:


public Form1()
{
    InitializeComponent();
    InitWorkItemControl();
    GetWorkItems();
}

Here is what the finished product looks like: (This is an out-of-the-box dialog,  I didn’t write any of it.)
tfsConnect

The search control on this form does not have any of my code in it.  I only provided the tab control for it to live in.
tfssearch
The dialogs and controls exposed by the TFS API take care of the majority of the user interface, we just need to hook the stuff together with a little glue.  You can download the sample solution which has both C# and VB .NET versions of the program. 

Special thanks to Brian Randell who taught me this stuff through an article on MSDN Magazine.

 Download the source code here

They could have told me

(Editor’s note: This is the first blog post by Chris Madsen, who will be writing on the .NET Developments blog from time to time. Madsen is a consultant who programs in Visual Basic and Visual Studio 2005. Her first few posts will cover the ups and downs of migrating from VS 2003 to VS 2005; she’ll also write about some of the Visual Studio 2005 features that surprised her. Welcome aboard, Chris!)

The other day I got the latest edition of Visual Studio magazine in the mail. Along with it came a glossy, full-color pirate’s map. Evidently, that’s how Microsoft thinks of Visual Studio 2008 — “made for the likes of developers, and other scoundrels.”

I know the calendar says 2008, but in the real world of developers, it’s barely 2005. And I’m more a captain of a leaky little fishing boat than I am a pirate. It takes everything I have to get my work out the door on time. I upgrade my tools (such as Visual Studio) when I can’t live without a new feature, not when I get glossy maps in the mail.

I’m not alone: I still see plaintive questions begging for help with VB 6 apps, and with upgrading to VB .NET. I’ll leave it to others to reveal all the cool new stuff in VS 2008. I’m going to concentrate on Visual Studio 2005, including the woes of upgrading from VS 2003.

Whenever I run across a juicy bit, I’ll let you know. These are the things they never tell you, the information that’s written between the lines in the documentation, the stuff they leave out. It’s the stuff you find after opening a hundred Google links, buried in the answer to the answer to the answer to a question on some obscure site.

Who is this “they” who never tells me stuff? I’ll leave it up to you to decide.

I program mostly in Visual Basic .NET, so that’s what I’ll be talking about. I work almost exclusively with WinForms, and I’ve done a lot of work using Access, Word, and Excel in .NET apps. I love to write macros to make my life easier. I am a consultant with clients in Florida, Massachusetts and Maine. Just to keep things interesting, I live across country from all of them, in Washington State. So I might throw in some tidbits about telecommuting and consulting. Let me know if you are interested.

I’m sure I’ll write about some things you already know. Maybe they’ll make you smack your head and exclaim, “What sort of idiot is she?” But I figure if it wasn’t obvious to me, it wasn’t obvious to someone else, and that’s who the tidbit is for. I’m glad you have a better grasp of some things than I do.

But they could have told me.

What’s obsolete in .NET Framework 2.0

The jump from .NET 1.1 to .NET 2.0 was a pretty significant one, as it involved changes such as new APIs and a new version of the CLR.

Why bring this up now? One, we know there are a lot of .NET 1.1 applications out there, so any programmers looking to migrate those applications will want to know which APIs made it into .NET 2.0 and which did not. Two, .NET 3.0 and 3.5 use the same APIs and the same CLR — remember, those upgrades focus primarily on new libraries and new programming language features like LINQ.

To that end Indian blogger cabhilash recently pointed folks to two rather helpful MSDN documents covering that which is obsolete in the .NET Framework 2.0.

The documents are .NET Framework V2.0 Obsolete Type/Member List (By Assembly) and .NET Framework V2.0 Obsolete Type/Member List (By Namespace). For each member or type, Microsoft provides a sentence or two explaining why it should not be used. There tend to be two general reasons for obsolescence — depreciation in Visual Studio 2005 or, simply, a better way of doing things in VS 2005. Either way, the lists are worth a look-see.

.NET Framework 3.5 re-released to include .NET 2.0 SP1 and .NET 3.0 SP1

Forgive our gratuitous use of .NET in the headline there, but Microsoft has re-released its download of.NET 3.5 so that it now includes the Service Pack releases of .NET 2.0 and 3.0.

Here’s the latest .NET Framework 3.5 download, date-stamped yesterday,  and here’s the readme document for .NET 3.5.

These next two Knowledge Base documents outline what is in the older .NET Service Pack releases that have been bundled into the new .NET 3.5 release.

Finally, if you have separate implementations of .NET 2.0 or 3.0 running somewhere out there, the links to those Service Pack releases are below. All contain “prerequisite feature support” for .NET 3.5; in the case of the .NET 2.0 SP1, said support also covers .NET 3.0.

Happy downloading.

Visual Studio 2005 Express Edition SP1 now available

Microsoft has released a service pack for Visual Studio 2005 Express, the free version of its flagship IDE. There are service packs for each of the five VS 2005 Express editions — Visual Basic, C#, C++, J# and Web Development.

For details about what is included in the download, Microsoft is pointing programmers to the Visual Studio 2005 Service Pack 1 Release Notes Knowledge Base article.