[Mono-devel-list] different behavior in MS.NET and MONO in System.Type.GetElementType()

Eran Domb erand at mainsoft.com
Sun Nov 16 10:25:40 EST 2003


Hello,
I found a difference in the behavior of MS.NET and mono.
System.Type.GetElementType() :
 
In MS.NET the method behave the following way:
 - If the instance is the type of an array, it returns the type of the
objects in the array (String for an array of String etc.)
 - In any other case it returns null.
In Mono it behaves the same with arrays, but in Enums it returns the
underlying type of the enum and in all other types it returns itself
instead of null.
 
The question is what should be the behavior in Mono ? As it is now or as
it is in MS .net ? 
 
If we modify the behavior to be the same as MS .NET's one there may be a
lot of impacts.
 
For example:
 
System.Xml.Serialization.XmlSerializationWriterInterpreter.MemberHasValu
e(XmlTypeMapMember member, object ob, bool isValueList)
if (val != null && val.GetType().IsEnum)
{
                              
            if (val.Equals (member.DefaultValue)) return false;
                              
            val = Convert.ChangeType (val, val.GetType().GetElementType
());
}
 
This piece of code expects the GetElementType() to return the underlying
type of the enum, while in MS.NET it will return null. If we modify
GetElementType(), the code needs to be modified to use
Enum.GetUnderlyingType(Type type).
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20031116/1ffd556c/attachment.html 


More information about the Mono-devel-list mailing list