[Mono-dev] System.Reflection and C# compiler differences between Mono and .NET.
Rafael Teixeira
monoman at gmail.com
Sat Jun 9 08:49:34 EDT 2007
I think they are bugs, because some reflection-based code won't work
properly (I think dynamic proxies, or even xml configured IoC
containers, for example).
My two cents,
On 6/8/07, Jonathan Pryor <jonpryor at vt.edu> wrote:
> Mono's (g)mcs produces different metadata for explicitly-implemented
> interface members than CSC does. Thus, a question:
>
> Should these differences be considered to be Mono bugs?
>
> Details:
>
> Consider explicitly implemented methods and properties:
>
> using System.Collections;
> using System.Collections.Generic;
>
> class Demo : IEnumerator, IEnumerator<Demo>,
> IEnumerable<Demo>, IEnumerable
> {
> /* ... unimportant ... */
>
> // explicitly implemented interface members
> object IEnumerator.Current {
> get { return null; }
> }
> Demo IEnumerator<Demo>.Current {
> get { return null; }
> }
>
> IEnumerator IEnumerable.GetEnumerator ()
> {
> return null;
> }
> IEnumerator<Demo> IEnumerable<Demo>.GetEnumerator ()
> {
> return null;
> }
> }
>
> There are two significant differences between Mono's behavior and .NET's
> behavior.
>
> 1. Property names: (g)mcs generates TypeName.MemberName, while CSC
> produces Namespace.TypeName.MemberName, e.g. IEnumerator.Current vs.
> System.Collections.IEnumerator.Current.
>
> Oddly, (g)mcs generates Namespace.TypeName.MemberName for methods; it's
> only properties that get abbreviated in this fashion.
>
> 2. Generics: gmcs produces significantly different member names compared
> to CSC:
>
> gmcs: System.Collections.Generic.IEnumerable`1[[Foo, test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].GetEnumerator
> CSC: System.Collections.Generic.IEnumerator<Foo>.Current
>
> As you can see, generic parameter handling is quite different --
> <Foo> vs. `1[[Foo, test, Version=0.0.0.0, Culture=neutral,
> PublicKeyToken=null]]. The same generic parameter handling difference
> exists for properties as well as methods.
>
> This difference is somewhat important because it's user-visible: you can
> use System.Type.GetMember(string, BindingFlags) to load
> explicitly-implemented interface members on a given type, but to do so
> you need to use the *same* name as is present within the assemblies
> metadata. Consequently, this means that different strings must be used
> to obtain the same member depending on whether the assembly was compiled
> by CSC or gmcs (the Mono/.NET runtime is irrelevant).
>
> Again, the question: Should these differences be considered bugs within
> Mono?
>
> Thanks,
> - Jon
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
>
--
Rafael "Monoman" Teixeira
---------------------------------------
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man." George Bernard Shaw
More information about the Mono-devel-list
mailing list