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.

Wednesday, November 14, 2007

Comparing DateTime structs ...

Consider the following code:

DateTime localTime = new DateTime(2007, 11, 14, 12, 0, 0, DateTimeKind.Local);
DateTime utcTime = new DateTime(2007, 11, 14, 12, 0, 0, DateTimeKind.Utc);

System.Diagnostics.Debug.Print("Is equal ? {0}", localTime == utcTime);

What do you expect the answer to be?


...and you probably guessed wrong as .NET actually considers them to be equal !?!


MSDN is "somewhat fuzzy" on the subject:


"Calculations and comparisons of DateTime objects are only meaningful if the objects represent times in the same time zone. For that reason, if no time zone is specified for the objects, it is assumed that the developer has some external mechanism, such as an explicit variable or policy, that can be used to determine the time zone in which a DateTime object was created."


Monday, November 05, 2007

Visual Studio 2008 release imminent

S. Somasegar (Corporate Vice President, Developer Division) just announced at Teched Barcelona that Visual Studio 2008 (and .NET 3.5 Framework) will be shipped before the end of November 2007.

Nice!

Sunday, November 04, 2007

Google translation

Niklas Jansson pointed out that Google managed to screw up the translation of the Calendar print dialog.

The orientation combo box in Swedish has the choices "Bil", "Stående" and "Liggande", the last two makes sense but the first one translating to Car obviously does not. (The original version says auto.)

Funnily enough, they managed to screw up the Finnish version too, where they for the same alternative provided "Autot" which means "the cars", (while auto might actually have been somewhat acceptable).

Well, you can't always win... :)

Integrating Help2 files into VS 2005 - part 2

The other workaround I hinted in the previous post involves a bit of manual labor the first time (or if you ask nicely, I might just provide the needed parts), if used more than once it is IMO less painful than the ORCA route.

This solution takes advantage of <CustomTable> feature of WiX. By "reverse engineering" the needed table schemas out of the relevant merge module MSHelp2_RegTables__RTL_---_---.msm we can author these tables as <CustomTable>:s and then just add <Row>:s as appropriate.

Next time just edit the row data and you're set.

For brevity, I just post one table here, but the rest can be made available upon request.

The tables I've used are HelpFile, HelpFileToNamespace, HelpNamespace and HelpPlugin.

      <CustomTable Id="HelpFileToNamespace">
<!--
HelpFileToNamespace table definition -->
<
Column
Type="string"
PrimaryKey="yes"
Id="HelpFile_"
Nullable="no"
KeyTable="HelpFile"
KeyColumn="1"
Category="Identifier"
Description="Foreign key into HelpFile table (required)." />
<
Column
Type="string"
Width="72"
PrimaryKey="yes"
Id="HelpNamespace_"
Nullable="no"
KeyTable="HelpNamespace"
KeyColumn="1"
Category="Identifier"
Description="Foreign key into HelpNamespace table (required)."/>

<!--
data -->
<
Row>
<
Data Column="HelpFile_">YourHelpFileKey</Data>
<
Data Column="HelpNamespace_">YourHelpNamespaceKey</Data>
</
Row>
</
CustomTable>

Saturday, November 03, 2007

Integrating Help2 files into VS 2005 - part 1

For various reasons (curiosity among others) I've been playing with integrating custom API documentation into Visual Studio, this turned out to be rather laborious.

For future reference I thought I'd document the process here.

- Create the code to be documented, use xml comments and turn on the generate xml comments switch in the project settings.

- Install Visual Studio SDK (yes, really ...)

- Install Sandcastle

- Install Sandcastle Help File Builder

- Open SHFB and create a Help2 project and customize appropriately.

- When the project builds successfully, open all the various .Hx? files (except .HxS) and remove the DTD reference, and from the .HxC file also the <CompilerOptions> element including contents. (For further info refer to the helpware site.)

- Now Microsoft wants you to use the Help Collection Integration Wizard, or manually edit merge files with Orca, neither of which is any fun.

- WiX has a WixVSExtension that among other thing has <HelpFile>, <HelpFileRef>, <HelpCollection> and <PlugCollectionInto> elements which sound promising.

- The problem: the WixVSExtension is currently broken, specifically bug 1588180 

- The bug comments include a suggested fix that involves recompiling WiX. Due to dependency issues this seems like a PITA.

- There is however also another workaround ... stay tuned!