Hi,
The following code gives me VBNC30471 while MS.NET compiles it fine.
Imports System.Data
Public Class Main
Public Shared Sub Main()
Dim reader As IDataReader
Dim a As Object
a = reader(0)
End Sub
End Class
I traced the problem down to Helper.vb line 1560:
System.Attribute.GetCustomAttribute(Type, GetType(DefaultMemberAttribute), True)
When Type is System.Data.IDataReader this call returns Nothing. The issue is
that the default
indexer is actually declared on IDataRecord, see
http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/System.Data/System.Data/IDataReader.cs
http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/System.Data/System.Data/IDataRecord.cs
The problem is that if you look at the code for GetCustomAttribute it does not
check base classes
for the DefaultMemberAttribute even though you pass True. (The inherit flag is
reset to false in
MonoCustomAttrs.cs::GetCustomAttributes() because the attribute does not have
the
AttributeUsage.Inherited flag). Therefore when searching for the
DefaultMemberAttribute on
IDataReader nothing is found.
I looked at what gmcs does and the closest thing I could find is in
expression.cs line 8411
http://anonsvn.mono-project.com/viewvc/trunk/mcs/mcs/expression.cs?revision=152858#l8411
http://anonsvn.mono-project.com/viewvc/trunk/mcs/mcs/typemanager.cs?revision=152808#l2354
Looking at the IndexerPropertyName() function in typemanager.cs, it seems like
gmcs just uses a name
of "Item" if it can't find anything. I am not sure if that is the correct
behavior for VB.
Perhaps we should just manually check base classes for DefaultMemberAttribute
since
GetCustomAttribute does not do it. Something like
Dim defAttr As Type = GetType(DefaultMemberAttribute)
attr = Attribute.GetCustomAttribute(Type, defAttr)
If attr Is Nothing Then
For Each t As Type in Type.GetInterfaces()
attr = Attribute.GetCustomAttribute(t, defAttr)
If attr IsNot Nothing Then Exit For
Next
End If
What do you think?
John
_______________________________________________
Mono-vb mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-vb