Distinguish between overloaded methods in XML-Comments

XML-Comments are quite handy when documenting public methods / classes. But what about method overloads in “see”-Tags?

Today when documenting some methods of a class using XML-Comments, I got a ReSharper message saying

Ambiguous reference Bar

However, ReSharper did not provide any automatic solution. So I had to find one myself 🙂

Read the rest of this entry »

Pitfalls and Best Practices to prevent them #4 – Object Finalizers

Let’s help the .NET Garbage Collector! Why this often backfires…

You know that the .NET Framework comes with a Garbage Collector to tidy up unreferenced objects. And you also know that there are so called “Finalizers” (sometimes also called “Destructors”) which are executed before an object’s memory is definitely deallocated.


Some people may think: “Hey – let’s help the Garbage Collector a little bit” and write code like that (Note: The console output is for a later example only):

Read the rest of this entry »

[WPF] Hide the “Window Buttons” (minimize, restore and close) and the icon of a window

No “Red-X”? Then I can’t close the window! How to achieve this reaction in WPF applications.

Even if it is not always the user friendliest way, there are situation in which you do no want the user to close a window using the “red X” in the upper right corner of a window’s non client area (sometimes only called “Close Button” 😉 ).

In most cases this behavior is expected from Dialogs which usually do not have “Minimize” and “Maximize” buttons. So it’s a common practice to hide the whole so called “System Menu”, “Control Box” or “System Bar”.

Windows Forms

It’s quite easy to do so in Windows Forms: Simply set the ControlBox property to false:

Read the rest of this entry »

No Interface Without Contract? – Part 5: Using Microsoft Code Contracts

Microsoft Code Contracts? Get started using them!

In the previous part we had a first look on Microsoft Code Contracts. This part will help us getting started using them.

Download and Installation

To use MS Code Contracts you need at least the Standard Edition of Visual Studio 2008 (VS 2010 is also supported).

Read the rest of this entry »

No Interface Without Contract? – Part 4: Writing down Pre- and Postconditions

Contracts are important – we already saw this. What can we do that we always see them when coding?

In the previous part, we formulated pre- and postconditions for a sample class. However, we only have written them down in plain text.

So we are now finding out how to specify them in a more comfortable (and elegant of course 😉 ) way.

I will introduce five possibilities: Documentation, Exception / Assert based, Custom Checker Class, Attributes and Code Contracts.

Read the rest of this entry »

Threatfire and Visual Studio –> Debugging slowdown

Something prevented me from debugging!!! Why this excuse can be true in some situations.

Some days ago, I noticed that the Visual Studio 2008 debugger suddenly was very, very slow.

A simple “Step Over” took up to 10 seconds. Even worse was the performance of the “Immediate Window”. When evaluating an expression, the output was terribly slow, too.

As debugging in such a low speed is no fun any more, I had to find the reason. First I thought that changed settings, windows or plugins are responsible.

Read the rest of this entry »