At iP3 we are using OJB.Net for object relational persistence. It is really easy to use, but it was using an ArrayList by default and we wanted to use the new Whidbey Generics List<> type.
When OJB.Net creates objects out of the relational data, it uses reflection to generate the IList collection object which is ArrayList by default.
When we tried to change this to the Generics List<> type OJB.Net didn’t seem to be able to handle it and reported that it couldn’t find the type in the assembly. My collegue Lance and I sat and worked through the problem for about half an hour until he did a GetType().ToString() on a List<> object. To our surprise we found that the type name we needed to Reflect for was System.Collections.Generic.List’1 linstead of System.Collections.Generic.List.
The full line for getting the type for List<String> using reflection then becomes:
Type classType = Type.GetType(“System.Collections.Generic.List’1[[System.String,Mscorlib]],Mscorlib“,true);
Don Box has a good post about Generics reflection under the heading Generics as Type Constructors from August 2003, but it doesn’t mention anything about adding a suffix to the type name.
If someone has seen this suffix notation explained previously then please shoot me a link.
Read more about the craziness on Lance’s blog.