Re: [Mono-dev] Generic type naming

2007-03-10 Thread Jonathan Pryor
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 EnumerableFromArray(T[]
> array)
>   {
>   foreach (T t in array)
>   yield return t;
>   }

This results in the creation of a *compiler-generated* type which
implements IEnumerable.

> 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 {}' 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


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Generic type naming

2007-03-09 Thread David Mitchell
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:

--
using System;
using System.Collections.Generic;
using System.Collections;

namespace MonoBug
{
public class ListBug
{
public static IEnumerable EnumerableFromArray(T[]
array)
{
foreach (T t in array)
yield return t;
}

public static IEnumerable IntEnumerableFromArray(int[]
array)
{
foreach (int i in array)
yield return i;
}

public static void Main()
{
Console.WriteLine(EnumerableFromArray(new int[] { 1,
2, 3 }).GetType());
Console.WriteLine(IntEnumerableFromArray(new int[] {
1, 2, 3 }).GetType());
}
}
}
--
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. 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.

--Dave

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Robert Jordan
Sent: Monday, March 05, 2007 11:26 PM
To: mono-devel-list@lists.ximian.com
Subject: Re: [Mono-dev] Generic type naming

David Mitchell wrote:
> My apologies if I am dredging up an issue that has already been resolved
and
> put to rest, but my curiosity compels me to do so.
> 
>  
> 
> I have noticed that Mono's algorithms for providing names to specific
> generic types is significantly different to that of Microsoft's
> implementation of .Net. Where Microsoft's implementation usually has lots
of
> fancy angle brackets and full type listings of the arguments, Mono often
has
> weird accent marks and numbers.

Like Mono, MS uses the accent marks as well. For example,
Dictionary`2[K, T] denotes the non-instantiated generic type
Dictionary (C# notation), whereas Dictionary`2[[String, Int32]]
is an instantiated Dictionary (C# notation).

When full names are requested, the type names become ever weirder:

System.Collections.Generic.Dictionary`2
[
[
System.String, mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
],
[
System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089
]
]

> Is this difference between the two implementations the result of an
> architectural decision, developer laziness (hey, the best developers are
all
> a bit lazy, right?), or of something in between the two extremes?

There should be no differences. Please file bugs if you find some.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] Generic type naming

2007-03-05 Thread Robert Jordan
David Mitchell wrote:
> My apologies if I am dredging up an issue that has already been resolved and
> put to rest, but my curiosity compels me to do so.
> 
>  
> 
> I have noticed that Mono's algorithms for providing names to specific
> generic types is significantly different to that of Microsoft's
> implementation of .Net. Where Microsoft's implementation usually has lots of
> fancy angle brackets and full type listings of the arguments, Mono often has
> weird accent marks and numbers.

Like Mono, MS uses the accent marks as well. For example,
Dictionary`2[K, T] denotes the non-instantiated generic type
Dictionary (C# notation), whereas Dictionary`2[[String, Int32]]
is an instantiated Dictionary (C# notation).

When full names are requested, the type names become ever weirder:

System.Collections.Generic.Dictionary`2
[
[
System.String, mscorlib,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
],
[
System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089
]
]

> Is this difference between the two implementations the result of an
> architectural decision, developer laziness (hey, the best developers are all
> a bit lazy, right?), or of something in between the two extremes?

There should be no differences. Please file bugs if you find some.

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list