ObjectSharp Blogs

You are currently viewing

Dave Lloyd's 2 Cents

A .NET Developer's Perspective


Happy New Year

It’s been over a month since I wrote an blog entry. I have reasons, Christmas, time off, New Years. I paved my main machine too, it was time. Put a fresh install of Windows 7 on a brand new Solid State Drive. It’s crazy fast. Of course that means fresh installs of everything. Everyday software gets installed first and then I move on to secondary stuff that I don’t use everyday, like Live writer. 

I am going to try and get out more Blog entries on what's new in 2010. At the moment I am pretty busy. Besides helping with day to day business. I have several presentations coming up.

  1. Today Adam Gallant and I are doing a Web Cast titled Quality Assurance in VSTS 2010.
  2. On January 21st Jeff Zado  and I will be in Waterloo to discuss Better Application Lifecycle Management with VS 2010
  3. On January 27th Deb Forsyth and I will be at the CTTDNUG in Kitchener presenting What’s new in TFS 2010

I also have Several ALM Assessments to do, plus Deb and I are writing some new courses. TFS 2010 for QA and TFS 2010 for Developers.

I’ll get back into the swing of a regular Blog entry sometime this week.

Build Process Templates

Making a build script do exactly what you want is easier with 2010?

When setting up a build there has always been a separation of concerns.

  • The Build Definition
  • The Build Process

Creating the build definition is much like you are use to in 2008. Right click on the builds node in the Team Explorer and select New Build Definition. It’s no longer a modal wizard, however it’s the same of information.

  • Name and Description

  • How you want the build to be triggered

  • Working folders

  • Build Server and Drop Location

  • Retention Policy

However there is a big difference, and it relates to the separation of concerns I mentioned above. In 2008 you could create a project file, that you would later have to edit to get the build to do anything extra ordinary. When you hit create on the project file tab you would be launched into another wizard that allowed you to select the solution to build, the type of configuration you wanted to build, weather or not you wanted tests executed against the build and or static code analysis performed.

In 2010 the Process tab contains a type of property grid which allows you to change the configuration of the build. This grid is organized into 3 sections Required, Basic and Advanced, allowing you to specify the solutions to build, define the build number, how to deal with tests and code analysis, weather or not to perform test impact analysis or label the source at this build to name just a few.

Where is all this defined? How would I add extra functionality to my build? What if I wanted to replace a dev.config with a test.config or deploy extra files to the drop location?

At the top of this tab is a show details expander.

image 

After expanding this area you will  be able to select from a list of Build Process Templates.

image

Each template can contain different build processes. Beta2 comes with three templates to get you going. Click New to create your own by selecting a XAML file you have already created a placed in source control, or copy one of the existing templates as a starting point. You will notice also that you can store your Build Template anywhere in source control. In previous versions they only ever existed in one place under source control.

With 2010 you can create a build using the default template, which will likely do most, and more likely all of what you need it to do. In my experience most teams do not customize their project build files so for them the default template will suffice.

If you do want to make changes to your Build process you no longer have to edit a confusing poorly documented XML file. Instead when you open the build template in VS you will be presented with a Windows Workflow editor that allows you to edit your build process template.

image

So why did I start this Blog post with a question? Although it does appear to be easier to add functionality to your build process, For those of us who are Windows Workflow challenged there is some learning to do. The good news is it will be better documented and ultimately easier to find solutions.

Conflict Resolution in TFS 2010

The conflict resolution in previous versions of VSTS/TFS worked ok, but did not have the best user experience for the developer. When a conflict was detected on check in a modal dialogue was dispatched and the developer could resolve the conflicts from there. However getting to all the information you required to resolve the conflict was not at hand.  

In TFS 2010 when you attempt to check in a conflict VS behaves the way it does when you have violated a Check in Policy. One mark for consistency. You will get a warning message as seen below.

image

Then you will be redirected to the Pending Changes - Conflicts Tab

From the conflicts tab you can get at the information you need to help you resolve the conflict.

image

Compare – Compare the local file with the latest version in source control.

History – See the complete history of all changes to this file.

Annotate – Shows you the source file with change set information in the margin. Including who made the change and when.

image

Once you know what you need to do, click on the expander for a file and select how you want to resolve this conflict. You can AutoMerge, use the Merge Tool to edit the source, or simply select the server version or the local version.

image

Happy Merging!

Test Driven Development with VS 2010

Test Driven Development proposes you should: write the test, watch it fail, write the code, run the test to see it pass, refactor your code.

This is difficult when your code won’t compile because you haven’t created the method or even the class you are writing a test for. When you are in the middle of writing unit tests you don’t want to have to switch over to create a class with an empty method, it breaks your train of thought.

In VS 2008 MS introduced the Generate Method Stub  on the CTRL+. smart tag.

image

In 2010 they have taken this a step further. There are two new features I want to talk about here IntelliSense Suggestion Mode and Generate From Usage.

IntelliSense has two modes now Completion Mode and Suggestion Mode. You can toggle between these modes with the key sequence CTRL+ALT+SPACEBAR.

In completion mode if you entered the name of a type that does not exist, IntelliSense will make suggestions that match what you typed. I’m sure you have noticed that this can be annoying, with the wrong key stroke you end up with code you didn’t want.

image

By switching to Suggestion mode IntelliSense will display an edit control allowing you to continue typing even though there are no matches.

image

IntelliSense will even suggest this new class before it’s actually created.

image

Once you have completed your statement you can use the CTRL+. smart tag to generate this class.

image

Or generate a new type altogether, allowing you to select the project it should go in.

image

You can use this new feature to generate a method or property stub also a class, interface, struct or enum.

Reference Highlighting

I’m going to like the new Reference Highlighting in the 2010 code editor. This is like an in place version of the find all references feature.

To enable/disable this feature:

For C# Go to  Tools > Options >Text Editor > C# > Advanced
                        Check “Highlight references to symbol under cursor”

For VB Go to Tools > Options >Text Editor > Basic > VB Specific
                         Check “Enable highlighting of references and keywords”

Once enabled (which is the default in Beta 2) place your cursor on almost any symbol and all other references to that symbol will become highlighted.

image

You can navigate between the highlighted text using CRTL+SHIFT+UP ARROW or CRTL+SHIFT+DOWN ARROW

Symbols can include declarations, references, and pretty much anything else that Find All References would return. Including classes, objects, variables, methods, and properties.

In Visual Basic, this also includes: Select Case, Case, End Select, If, Then, ElseIf, and End If.

For C# code, reference highlighting is not provided for the switch and if constructions, but is provided for other symbols.

Gated Check-in Build Trigger

VS 2010 has a new feature that allows a developer to validate that their code change will merge and successfully build with the current code base on the server before ever checking it in. It’s called the gated Check-in.

How it works

Create a build type that uses Gated Check-in as it’s trigger for starting the build.

image

Take the code you want to check in and shelve it.

Then when you queue the build you can specify the Shelve set to be merged with the source from the server. You can also have the build complete your check in if the build is successful.

image

This should help to diminish the number of broken builds on the server.

Extending VS 2010

In VS 2010 MS has made adding extensions very very easy using the Extension Manager.

First you may want to change one option under Environment > Extension Manager.

You want to Load Per User Extensions when running as administrator.

image

Once you do that, from the Tools menu open the Extension Manager. The Extension manager shows you what extensions you already have installed, and gives you the ability to uninstall or disable them.

image

So where do I get extensions from? The extension manager helps here too. Select the Online Gallery and you will be able to pick from a list of published VS extensions. You can filter to just see Controls, Templates or Tools. Sorting is a handy way to see what is popular by rating or most downloaded.

image

Select the extension you want and click Download. You will be prompted to install the package. Now just restart Visual Studio and enjoy your new VS extension. :)

Code Coverage in VS2010

VThis took me a few minutes to find. Perhaps I can save someone else those few minutes.

To turn on Code Coverage locally you need to edit what used to be the <Local>.TestRunConfig , which is now called the <Local>.TestSettings.

The section is not called Code Coverage anymore it’s under Data and Diagnostics. There are a bunch of  tools you can turn on from here including:

image

Select Code Coverage, and the configure button at the top will become enabled.

image

To select the DLL’s for code coverage click the Configure button. You will get this window, I think you know what to do from here.

image

Access 2007 & SharePoint

If you are responsible for content in SharePoint in any way you should take a look at Access. Weather you are just updating information ongoing, or migrating information from an old site, or from other sources Access is the way to go.

I recently had several hundred items that needed to go into a list. The data was sent to me in an Excel spread sheet. So I thought I would look into the Excel Add-ins for SharePoint.  image

I knew Open with Access was an option in the list Actions menu but always dismissed it. I didn’t want to open up Access, I haven’t used that old tool in years. However with a need to insert hundreds of list items and a faint hope that using a client application to edit those lists would be a much nicer experience then  using SharePoint itself I clicked on the menu item.

You can completely manage your list with Access.

You don’t even have to log in to the SharePoint site via your browser. Open Access, then from the External Data tab on the ribbon select SharePoint Lists then Existing SharePoint List. Enter the URL of the SharePoint site, log in and select the option Link to the Data source by creating a linked table.

At this point select the lists you would like to work with and they will be added as tables in Access linked directly to SharePoint. Now that you have your list as an Access table the options for managing that data is endless.

You can update, insert and Delete using SQL Statements.

You can import data from multiple sources including Excel, Another SharePoint List, Text, XML, Word Mail merge, HTML, ODBC and more.

image

Trust me this is an option you will be happy you explored.

Google vs Bing Maps

I have been a fan of Google for a long time. I tried Live Search but ended up going back to Google.

The other day I was looking for an address in rural Hamilton, Flamborough actually. The address was 359 Concession 10 East Hamilton. I knew the general location I just wanted to know some street names around it to figure out the best route.

When I entered the address into Google Maps it took me to 359 Concession St in Hamilton which is on the mountain not in Flamborough. I tried various incarnations of the address but Google could not seem to find it. 

Therefore I switched over to Bing maps, entered the address the same as I had for Google and Bing found the exact location.

Bing, you have my attention!

More Posts Next page »