views:

1210

answers:

1

I was debugging some code in Visual Studio 2005, when I noticed that the IDE was not hitting breakpoints in a particular generic class. I could manually step into the class, but the tool-tips shown when hovering over references contained nothing but memory addresses instead of the normal friendly tool-tips.

It turns out that the problem is caused by the name of the file (!). Specifically, when the file name contains a ` (backtick, backquote), the debugger will not load the symbols for that file. The workaround is to rename the file.

I was using a backtick in the first place to represent the cardinality of a generic type:

  • Foo.cs contains a non-generic type (e.g. Foo)
  • Foo`1.cs contains a generic type with a single type parameter (e.g. Foo<T>)
  • Foo`2.cs contains a generic with two type parameters (e.g. Foo<T,U>)

This bug (is it?) occurs in Visual Studio 2008 as well.

Can anyone explain this behavior?

+4  A: 

I was under the impression that behind the scenes generic types are compiled into types that have backticks in their names. Say you had List<int> and List<string>, behind the scenes you'd have two classes. One would be System.Collections.Generic.List'1 and the other System.Collections.Generic.List'2. These classes may be generated and stored in files of the same name (with .cs extension).

I'm guessing that if you stick backticks in your file name you're going to be messing with this mechanism.

I am speculating a bit here as I haven't researched it, but it could be something for you to research? :)

Good luck

EDIT - Had to use apostrophes instead of backticks as they're reserved symbols in this editor :)

OJ
That sounds plausible -- the generics are stored in the PDB as belonging to intermediate files like List`1.cs and the symbol lookup code skips files that appear to be auto-generated. Thanks for the answer.
Dave
This seems to have been fixed in VS2010.
John Leidegren