Tuesday, December 11, 2007

"Thank you for the lasting contribution you made to Microsoft Visual Studio"

..that's what is engraved into the glass cube I got in the mailbox today.

vs2008-glasscube

Thursday, November 29, 2007

Dependency Visualizer 1.2.7

Turns out that Dependency Visualizer requires the Visual C++ Runtime version 7.1 (2003), and no-one had noticed (or at least not reported it to me).

The just released 1.2.7 fixes the installer to include the necessary files, otherwise nothing has changed since 1.2.6.

Wednesday, November 28, 2007

Interesting findings ...

What would you say if you found a class with the following interface during a code review?

internal static class Internal
{
// Methods
private static void CommonlyUsedGenericInstantiations_HACK();
private static T NullableHelper_HACK<T>() where T : struct;
private static void SZArrayHelper_HACK<T>(SZArrayHelper oSZArrayHelper);
}

Suspicious to say the least ...


The 'interesting' part here, is that the class actually exists, and not just anywhere but as System.Internal in mscorlib !

Monday, November 26, 2007

Dependency Visualizer now supports VS 2008

The just released 1.2.6 version of Dependency Visualizer now supports Visual Studio 2008 solutions/projects.

Monday, November 19, 2007

Visual Studio 2008 RTM released

Visual Studio 2008 just released (to MSDN subscribers) and the Express versions to the rest of you.

Get it now (or wait a few days to get better download speeds).

Friday, November 16, 2007

Stepping through properties in the debugger

Ever stepped through code in the debugger and ended up in N+1 trivial property getters before you got to the "real code" and felt frustrated?

Enter the DebuggerStepThroughAttribute. MSDN says the following: "For example, the Visual Studio 2005 debugger does not stop in a method marked with this attribute but does allow a breakpoint to be set in the method."

Basically, if you need a breakpoint in there, you'll get there, otherwise Visual Studio won't bother stepping there and just steps over it, which is exactly what we want.

So how do you apply the attribute to a property as its attribute usage states the following?

[AttributeUsageAttribute(AttributeTargets.Class|
AttributeTargets.Struct|
AttributeTargets.Constructor|
AttributeTargets.Method, Inherited=false)]

The point is to realize that while the property itself isn't a method, both the getter and the setter actually are.


So you can do the following:

        public int Foo
{
[DebuggerStepThrough]
get { return m_foo; }
set { m_foo = value; }
}

..and now the getter has the attribute, while the setter does not.

Thursday, November 15, 2007

Programmatically enumerate WCF endpoints defined in app.config

For various reasons you might want to enumerate all client endpoints defined in the application configuration file.

For future reference, this is one way to do it:

// Automagically find all client endpoints defined in app.config
ClientSection clientSection =
ConfigurationManager.GetSection("system.serviceModel/client") as ClientSection;

ChannelEndpointElementCollection endpointCollection =
clientSection.ElementInformation.Properties[string.Empty].Value as ChannelEndpointElementCollection;
List<string> endpointNames = new List<string>();
foreach (ChannelEndpointElement endpointElement in endpointCollection)
{
endpointNames.Add(endpointElement.Name);
}
// use endpointNames somehow ...

..obviously this is not production quality code.