In tests/attributes:
[mono.git] / mcs / mbas / Test / tests / attributes / AttributesClassUseC.vb
1 'Author: Ritvik Mayank <mritvik@novell.com>
2 'Copyright (C) 2005 Novell Inc. (http://www.novell.com)
3 ' multiple-use for derived takes both the attributes
4  
5 Imports System
6
7 <AttributeUsage(AttributeTargets.Class, AllowMultiple := True, _
8                 Inherited := True )> _
9 Class MultiUseAttribute 
10         Inherits System.Attribute
11         Public Sub New(ByVal Value As Boolean)
12         End Sub
13 End Class
14
15 <AttributeUsage(AttributeTargets.Class, Inherited := True)> _
16 Class SingleUseAttribute
17         Inherits Attribute
18         Public Sub New(ByVal Value As Boolean)
19         End Sub
20 End Class
21
22 <SingleUse(True), MultiUse(True)> Class Base
23 End Class
24
25 <SingleUse(False), MultiUse(False)> _
26 Class Derived
27         Inherits Base
28 End Class
29
30 Module Test 
31         Sub Main()
32                 Dim type As Type = GetType(Derived)
33                 Dim arr() As Object = _
34                 type.GetCustomAttributes(GetType(Attribute), True)
35                 If arr.Length <> 3 Then 
36                         Throw New Exception ("multiple-use attribute is inherited on a derived type can take both attributes. expected total attributes = 3 but got " & arr.Length)
37                 End If  
38         End Sub
39 End Module