DebuggerDisplay Attribute

The DebuggerDisplay attribute (System.Diagnostics.DebuggerDisplayAttribute) controls how a class or field is displayed in the debugger variable windows. When a custom object is displayed, the name of the class or the result of ToString() is shown. This can be changed with a DebuggerDisplay attribute.

Look at the following demonstration. I added the DebuggerDisplay attribute:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace DebuggerView
{
    [DebuggerDisplay("User name={UserName} " +
        "& email={EmailAddress}")]
    class User
    {
        public string UserName { get; set; }
        public string EmailAddress { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            User u = new User()
            {
                UserName = "maor",
                EmailAddress = "maor@example.com"
            };
        }
    }
}

The DebuggerDisplay attribute has a single argument, which is a string to be displayed in the value column for instances of the type. This string can contain braces ({ and }). Text within a pair of braces will be evaluated as a field, property or method.

And the result is:

DebuggerDisplay

March Meeting – Web and Load Test

This month we had a testing specialist at the podium, Shai Raiten attracted over 50 listeners with a well built lecture and fascinating demos about Visual Studio Team System web testing. The original plan was to dedicate one lecture to web testing and the other one to load testing, but since the there was a lot of interaction with the audience and a lot of discussions we’ve decided to go with the flow and dedicate the entire meeting to web testing. Shai will join us again on April (exact date will be pubished here and on MS-Event feed) and will present some web testing left-overs and a Load session

For the presentation, code examples and much more pls see Shai’s blog

Stop Connecting To TFS Automatically On Visual Studio Startup

I often visit customers and work outside the office, means I work disconnected for a while.

It’s laborious when I open VS (2005 or 2008) and waiting for VS to connect automatically to TFS.

Colin Beales has an excellent tip that explains how to stop Visual Studio from automatically connecting to a TFS server when it starts up.

  • Backup your registry
  • Navigate to Team Foundation key:
    • For VS 2005 navigate to: HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio8.0TeamFoundation
    • For VS 2008 navigate to: HKEY_CURRENT_USERSoftwareMicrosoftVisualStudio9.0TeamFoundation
  • Add a registry key “AutoLoadServer” (type DWORD)
  • Setting the value to be 0 (Do not connect automatically or 1 to connect automatically).

ASP.NET 2.0 – Web Site vs Web Application project

A common question by asp.net developers is what project model should I use for asp.net application? Web Site project (which introduced with VS 2005) or Web Application project (which delivered as add-in for VS 2005 and built-in within VS 2005 SP1)?

There is no thumb rule. Every project model has it’s own advantages (and diss-advantages off course…). I hope this post will help you to understand better the differences between 2 of them.

Web Application project model

  • Provides the same Web project semantics as Visual Studio .NET 2003 Web projects.
  • Has a project file (structure based on project files).
  • Build model – all code in the project is compiled into a single assembly.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET 2.0 (master pages, membership and login, site navigation, themes, etc).
  • Using FrontPage Server Extensions (FPSE) are no longer a requirement.

Web Site project model

  • No project file (Based on file system).
  • New compilation model.  (Read here or here for more details) and …
  • Dynamic compilation and working on pages without building entire site on each page view.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Each page has it’s own assembly.
  • Different code model.  (Read here for more details)

Ok, all is great, but you want to create your web site now. Which model should you use?

  • You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
  • You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
  • You need to add pre-build and post-build steps during compilation? use Web Application project.
  • You need to build a Web application using multiple Web projects? use Web Application project.
  • You want to generate one assembly for each page? use Web Site project
  • You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project
  • You prefer single-page code model to code-behind model? use Web Site project.
%d bloggers like this: