Posts Tagged ‘Visual Studio 2010’

Dear all,

It’s my pleasure to announce that I have been invited as a speaker for this year’s .NET DevCon conference on 6th and 7th June in Nuremberg (Germany). I’m looking forward to this great opportunity to meet a lot of interesting people!

I am going to hold a session about productivty increasing Visual Studio 2010 Add-Ins. The talk will be based partially upon an article I wrote for the German dotnetpro magazine:  “Die Crème de la Crème”.

Here you can find an abstract of the session:

Produktivitätssteigernde Visual Studio Add-Ins

And here speaker profile page:


For a current list of publications, please check my Publications page.

Maybe I’ll see some of you there! 😉

Best regards,


Read Full Post »

Hi all,

I just put onto the Visual Studio Gallery the new version 1.2 of WADA. Mostly, I tried to fix some stability issues when querying the processes after W3WPs crash or an IISRESET occurs.


  • WADA 1.1: IISRESET –> “Get Procs” –> No results –> Restart VS 2010
  • WADA 1.2: IISRESET –> Refresh Webapp –> “Get Procs” –> Results

This means, if you execute an IISRESET, the worker processes end, and in order to make them run again you should refresh the web application you are testing (this will issue a new W3WP process). Then, just click on “Get Procs” in order to visualize the processes again. This should fix the problem of the annoying VS restart when wanting to see the processes again in WADA.



Fig.1 Multiple selection of processes


Attaching improvements

Now, there is also the possibility to attach to multiple processes, by simply clicking on each of the desired and then pressing “Attach”.

If you want to simply attach one process, just double click on that process, and the attach will be performed.


Planned future improvements

– Remote debugging

– <your improvement suggestion here>


Thank you all for your suggestions and valuable feedback, and keep sending more of it! This project isn’t finished, yet, and feedback/suggestions are always welcome.


Best regards,


Read Full Post »

Howdy people,

This time we’re going to have a look at another small (but effective) improvement in Visual Studio 2010: The breakpoints got some new achievements, namely:

  1. Labeling breakpoints
  2. Searching for breakpoints (Breakpoints Window)
  3. Specifying hit counters
  4. Import/Export breakpoints

Labeling is easy-to-use and newly available in Visual Studio 2010 (not in the Express Editions). Later on, we can also use these labels for searching.

After setting up a small console application (containing only the default-generated Program class), let’s declare an array of type Int32 and name it values. A simple foreach loop should iterate over the array. We’ll also place a breakpoint at the beginning of the loop. That’s enough for showing the new achievements. Figure 1 shows it:



Figure 1: After setting the breakpoint


After we’ve set the breakpoint, we can deliberately access the labels by right-clicking on the breakpoint and choosing EDIT LABELS from the context menu, as seen in Figure 2.



Figure 2: Accessing labels after a right click on the breakpoint

A window will open, allowing to define a new breakpoint label or to assign an existing one. In our case, I have already defined a label “NumberLoop”, which we’re gonna reuse. A check near the label in the list does the assignment, and confirming the dialog window sets the assignment. From now on, our breakpoint is called “NumberLoop”.


Figure 3: Label definition/assignment

We can verify the assignment immediately by bringing up the Breakpoints Window, which is located under Debug-Windows-Breakpoints Window (CTRL+D, B).


Figure 4: The breakpoints window, showing our breakpoint w/ label

The breakpoints window basically shows all breakpoints along with their name (i.e. filename and position in the code, as well w/ label, conditions and hit count). Additional columns can be defined by using the menu entry “Columns”, as seen in Figure 4. Defining another label in the code, 2 lines below, will result in Figure 5. Let’s try to enter “Number” as a search term in the menu of the breakpoints window.


Figure 5: 2 Breakpoints, before search


Figure 6:  After search – our breakpoint was found

The advantage is clear: When having lots and lots of breakpoints, it will be easy to give them meaningful names, so they can be found easier afterwards.

Moreover, by right-clicking on the desired breakpoint, a context menu will open, containing the entry “Go To Source Code” (“Go To Disassembly”, respectively), allowing you to navigate directly to the position in the code, where the breakpoint is located.

The hit counters where already available in VS2008, and haven’t really changed, but for the sake of completeness they shall be named here as well. Right-clicking on a breakpoint allows you to define a hit counter for a specific breakpoint.



Figure 7: Defining hit counters for breakpoints

It means, the breakpoint will only be hit when a certain hit counter is reached. If you only want to see how many times a break point actually is passed, it is recommended to set the hit count to a very high value (that will never actually be reached). This way you can evaluate the hit counter afterwards and check for the actual value.


Figure 8: The hit count definition window

Breakpoints with conditions and/or hit counts are displayed as image. Disabled breakpoints will invert the colours.

The last new feature is the import / export of breakpoints. It is also available in the breakpoints window. The 2 buttons image are for exporting and importing, respectively, and will produce/accept an XML file containing not only the breakpoints, but also applying the search criteria you defined in the breakpoints window. This way it’s easy to reuse even your breakpoints. In a possible scenario you want to pass your breakpoints to another developer, who is working on the same project, this seems quite a handy feature.

Enjoy finding and exterminating bugs!

Best regards,


Read Full Post »

Howdy folks,

The Visual Studio Team recently released a set of installable extensions that help to improve the productivity while working with the new Visual Studio 2010. This set of extensions is called Visual Studio Productivity Power Tools, and it really keeps its promises.

1. Editor Improvements

There is a set of features that directly integrate into the Code Editor. At the first glance after installing the VSPPT you can see the current editing line is entirely highlighted (see figure 1) This is good for immediately recognizing which line we are working in. Personally, I think it can be of great use, since it often happens to me not to immediately see where I was editing after e.g. an ALT+TAB switch between windows.



Figure 1: Highlighting of the current line (current caret position)

  • Automatic Brace Closing (ABC)
    This works with all types of braces, as well as with quotes.
  • Triple-Click to select entire line
  • Go-to-Definition:
    Simply by holding the CTRL-Button and clicking on the variable/function/class etc. Just like in Word when you are following links!
  • Automatic Statement Completion: SHIFT+ENTER will insert a semicolon and end the current editing line
  • Move line up/down: Press ALT+UP/DOWN to swap the current editing line with the line above or below, respectively.

2. The Quick Access Tool Window

A very handy tool when it comes to remembering menu item’s locations. Do you waste time searching through the menu for command or tool window you would like to access? This problem’s solved now. Simply type CTRL+3 in order to bring up the QA Tool Window. As you type, the window will show you:

  • Menu commands
  • VS options
  • Project templates

(a personal remark: it would have been nice if the team would have also included the option to search for item templates over the QA).

You can cycle through the search results by pressing CTRL+3 more often. Figure 2 shows the Quick Access Tool Window.


Figure 2: The Quick Access Tool Window listing results by category.

3. Searchable “Add Reference” Dialog

A great improvement – it’ll gonna save us a lot of time looking for assemblies we need.


Figure 3: The new “Add Reference” dialog

4. Assignment Alignment (oh, what a rhyme!)

Very nice feature for keeping the overview when having a lot of assignments – in such a case it might be hard to read the assignment value of a variable that has been assigned to somewhere in the middle of the block.


Figure 4: Unaligned assignments

Hitting CTRL+ALT+] (English keyboard layout, with the German one it didn’t work but only produced a square bracket). It’ll transform the code from Figure 4 into something that looks like the code in Figure 5:


Figure 5: Aligned assignments.

There are many more extensions that come with the Visual Studio Productivity Power Tools, and I pointed out only the ones who caught my eye at the first glance. However, for a full feature list, you should go to Productivity Power Tools Page.

Below you can find a download link for getting the Microsoft Productivity Power Tools:



5. Only Get What You Need

By the way, in case you shouldn’t want to use each feature of the Power Tools, you can simply enable/disable them one by one using the Tools-Options-Productivity Power Tools dialog window, as shown in Figure 6:


Figure 6: The PPT options dialog.

Note: A restart of VS 2010 is needed for the changes to take effect.


These extensions are very handy when it comes to speeding up development and saving time for trivial tasks like closing braces, ending statements, searching for templates and references etc. I think I’m going to try them for the daily productive use in order to be able to confront the coding with/without the VSPPT. But if my first impression persists, then it’s gonna be a great time-saver and productivity-improver.

Best regards and stay tuned!


Read Full Post »

Howdy all,

Did you already check out the latest Keybinding Cards of the new VS 2010? If not, you can find them here:




They are available for C#, C++, VB, and for the newly added F#.

Here are my two of my favourite new keybindings:


1. CTRL + COMMA (,) (NavigateTo window)

Cross-solution searching of matching elements of all types (be it file names, source code content, etc.). It’s a really fast searching mechanism. Further information about the NavigateTo feature can also be found in my previous post “Visual Studio 2010: New Features Part 1: UI”.


Zoom in/out the source code editor, respectively. Very handy when it comes to presentations. Remember the old days where you had to increase/decrease the font size by going to the Tools menu (while your audience had to wait for it)? Those days are gone!


Best regards,


Read Full Post »

Howdy there,

Now it’s around a month, that Microsoft released the .NET framework 4 to the public – so I wanted to take the occasion to give you a quick view on two nice new features:

1. Optional parameters:

You can specify any parameters to be optional by assigning it a default value directly in the list of parameters (using the assignment operator). It is quite straight-forward:


   1: public static void DoSomething(Int32 count = 10)

   2: {

   3:     for (int i = 0; i < count; i++)

   4:     {

   5:         Console.WriteLine(i);

   6:     }

   7:     Console.ReadLine();

   8: }

Snippet 1: The DoSomething method, specifying the count parameter as optional

This changes also the way such a method can be called, i.e. by omitting the parameter it still works fine – it just assigns the default value (in our case 10), and the code can perfectly run like that. Hence, a call to the method may look like in the following example:

   1: static void Main(string[] args)

   2: {

   3:     DoSomething();

   4: }

Snippet 2: Call to DoSomething , omitting the parameter

Even IntelliSense takes notice of the optional parameters, displaying them in square brackets, along with its default value:


Figure 1: IntelliSense displaying an optional parameter

Straightforward so far, isn’t it?

2. Named parameters

Now, imagine a case where we have a method that defines two required parameters, followed by an optional parameter and then again followed by another requited parameter. Let’s change the DoSomething method so it looks like in snippet 3:

   1: public static void DoSomething(String name, String surname, String city = "Munich", Int32 age)

   2: {            

   3:     Console.WriteLine(name + " " + surname + " lives in: " + city + " / age:" + age;

   4: }

Snippet 3: The changed DoSomething  method

Now it is basically possible to change the order of the parameter calling by specfying the correct names followed by a colon and again followed by the value. That’s it!


   1: DoSomething(surname: "Miller", name: "John", age: 32);

   2: DoSomething(age:32, surname: "Miller", name: "John", city:"Berlin");

Snippet 4: Two ways of calling DoSomething, using named parameters

This feature is especially useful if you use optional parameters, since it may not become clear which parameter is called next if you omit an optional parameter. Again, IntelliSense gives useful hints when calling a named parameter.


Best regards,


Read Full Post »

Howdy people,

Me again with some more information of how both Code Contracts and Pex can be used together to write expressive tests (while still specifying a (partial) specification of the code). In the course of this article wel’ll also cover Assertions and Assumptions. In order to point out only the necessary topics, let’s introduce a new (very basic) sample project, and let’s perform the following steps:

  • Create a console application called MusicStore
  • Create the class Artist (as of Figure 1)
  • Create the class Album (as of Figure 2)
  • Enable Code Contracts checking (both static and runtime, as of figure 3)


Figure 1: The Artist class of the MusicStore project.


Figure 2: The Album class of the MusicStore project.


Figure 3: Enabling both Runtime Checking (Full), and Static Checking

Important: Do not forget to also check the Implicit Non-Null Obligations, as of Figure 3

The only critical point for CC should be the SellAlbum method of the Artist class. Why? Simply, because there we might have a parameter of type Album that could be NULL. And the Static Checker gives us the correct hints to it, as expected:


Figure 4: Expected CC’s Static Checker suggestion and warning.

So we have one suggestion to put a precondition, and an effective warning that we might be passing a parameter that could be NULL. This was predictable.

Running Pex over the method SellAlbum reveals the following results (If you need a starting point for Pex, please look at my article First steps with PEX: Automated White box Testing for .NET)


Figure 5: Pex results for 3 test cases, one providing the album parameter = NULL. Please note also the typical Pex exploration results’ table showing one column per parameter (in this case only album ).

What happens if we put an assertion to this critical parameter? Let’s simply add one, as shown in Figure 6:


Figure 6: Adding an assertion using a call to the static method Contract.Assert(bool condition) of the CC framework.

It makes sense to assert a number of AlbumsSold higher or equal to 1 (after 1 album has been sold), right? Does putting an assertion have an impact on Pex? Of course! Let’s run it again to see how:


Figure 7: Effects on Pex of using Code Contracts’ Assertions. Pex clearly identifies this as an assertion failure, hence letting the generated test case fail. Line 2 (highlighted the additionally created Pex test for the Code Contracts assertion).

So far, so good. Let’s look at Figure 6 again. We can also put such an assertion for the album object. This clearly makes sense – since selling an album should increase the album’s TimesSold count. Let’s do this in Figure 8:


Figure 8: Added another assertion for the album.TimesSold property.

And immediately, let’s look at the Static Checker warnings and the generated Pex test cases (Figures 9 and 10):


Figure 9: One more unproven assert warning for our newly added Assertion in the SellAlbum method. This was expected. Let’s run Pex again!


Figure 10: Line 3 shows the newly generated (and failed) test case of Pex. Again, this was expected.

Great coverage – but What About the Meaning?

This is a good question. Is this still an expressive test? Let’s recap the meaning. We could have an Album -type parameter passed, which could be theoretically NULL. Would it make any sense to then test its property TimesSold? I am sure, we can agree on that this would not be the case.

So, what we need, is the possibility to prevent Pex from generating test cases in such a case, hence producing only meaningful tests. And who is going to provide us with such a capability?

Code Contracts’ Assumptions

Important: Assumptions only work when the Full contract option is checked in the Code Contracts pane (under our project’s properties)

Figure 11 gives a brief example of how to put such an assumption into our code of the SellAlbum method.


Figure 11: Creating assumptions.

Figure 11 needs some explanations:

The first three assumptions simply protect us from getting the current object, the passed album, or the passed album’s artist as NULL. Makes sense, so far. The following two assumptions ensure that this.AlbumsSold and album.TimesSold both are non-negative values.

(Note also that now we put our assertions INSIDE the artist comparison’s block – makes sense, since we do not need to assert when there happened no increase of AlbumsSold and TimesSold properties).

What do We Expect?

Well, we pretty much thought at everything, didn’t we? So we expect Pex to not issue any errors or failures again. A simple re-run of Pex will show us the result, as can be seen in Figure 12.


Figure 12: Unexpected error on line 3, a failed assertion.

An unexpected failure? How could that happen? Let’s look at what the parameters looked like in the case of failure:


Did you see it? AlbumsSold is equal to int.MaxValue ! I guess, I do not need to explain what happens, if you try to increase an integer (in SellAlbum ) which is already equal to its maximum value! But why did that happen?

Simply put, this is one of the boundary test cases we explained in First steps with PEX: Automated White box Testing for .NET article. Pex guesses from the type of variables which are the boundary values (and also intermediate values).

To summarize shortly & sweetly today’s lecture:

Code Contracts & Pex: meaningful, expressive tests

(by preventing test case generation for assumed parameter values)

Let’s stop here today. There are more interesting topics regarding Code Contracts and Pex, and I am quite sure this will keep us busy for another while!

Enjoy playing around with Pex and Code Contracts, and see you next time!

Best regards,


Read Full Post »

Older Posts »