[Mono-dev] Generic type naming
Jonathan Pryor
jonpryor at vt.edu
Sat Mar 10 11:42:36 EST 2007
On Fri, 2007-03-09 at 17:41 -0800, David Mitchell wrote:
> You're right...there's no difference in the implementation for the names of
> Generic types. The weirdness in the type name that I was seeing comes from
> using the fancy new 'yield return' syntax that was introduced in C# 2.0.
>
> To illustrate, try this block of code in Mono and on .NET:
...
> public static IEnumerable<T> EnumerableFromArray<T>(T[]
> array)
> {
> foreach (T t in array)
> yield return t;
> }
This results in the creation of a *compiler-generated* type which
implements IEnumerable<T>.
> You'll get different results on each platform, although I'm not entirely
> certain if the naming convention is part of the C# spec or not.
The naming of compiler-generated types is NOT part of the C# spec.
The C# spec does control some type naming, such as stipulating that
generic types have "`" followed by the number of generic parameters
appended to the type name, e.g. `class Foo<T,U> {}' is Foo`2.
> I'm looking
> into this because I'm trying to get all of the Wintellect.PowerCollections
> tests to succeed in Mono (http://www.wintellect.com/PowerCollections.aspx).
>
> If you download it right now, four of the tests will fail, and the first one
> does so because the test makes assumptions about the type name.
It sounds like the test is invalid and should be fixed.
- Jon
More information about the Mono-devel-list
mailing list