@@ -53,7 +53,10 @@ public static IEnumerable<Declaration> GetSupertypes(Declaration type)
53
53
{
54
54
return new List < Declaration > ( ) ;
55
55
}
56
- return ( ( ClassModuleDeclaration ) type ) . Supertypes ;
56
+ else
57
+ {
58
+ return ( ( ClassModuleDeclaration ) type ) . Supertypes ;
59
+ }
57
60
}
58
61
59
62
@@ -70,24 +73,38 @@ public bool IsExposed
70
73
{
71
74
return _isExposed . Value ;
72
75
}
73
- // TODO: Find out if there's info about "being exposed" in type libraries.
74
- // We take the conservative approach of treating all type library modules as exposed.
75
- if ( IsBuiltIn )
76
+ else if ( IsBuiltIn )
76
77
{
77
- _isExposed = true ;
78
+ _isExposed = IsExposedForBuiltInModules ( ) ;
78
79
return _isExposed . Value ;
79
80
}
80
- var attributeIsExposed = false ;
81
- IEnumerable < string > value ;
82
- if ( Attributes . TryGetValue ( "VB_Exposed" , out value ) )
81
+ else
83
82
{
84
- attributeIsExposed = value . Single ( ) == "True" ;
83
+ _isExposed = HasAttribute ( "VB_Exposed" ) ;
84
+ return _isExposed . Value ;
85
85
}
86
- _isExposed = attributeIsExposed ;
87
- return _isExposed . Value ;
88
86
}
89
87
}
90
88
89
+ // TODO: Find out if there's info about "being exposed" in type libraries.
90
+ // We take the conservative approach of treating all type library modules as exposed.
91
+ private static bool IsExposedForBuiltInModules ( )
92
+ {
93
+ return true ;
94
+ }
95
+
96
+ private bool HasAttribute ( string attributeName )
97
+ {
98
+ var hasAttribute = false ;
99
+ IEnumerable < string > value ;
100
+ if ( Attributes . TryGetValue ( attributeName , out value ) )
101
+ {
102
+ hasAttribute = value . Single ( ) == "True" ;
103
+ }
104
+ return hasAttribute ;
105
+ }
106
+
107
+
91
108
private bool ? _isGlobal ;
92
109
public bool IsGlobalClassModule
93
110
{
@@ -97,30 +114,25 @@ public bool IsGlobalClassModule
97
114
{
98
115
return _isGlobal . Value ;
99
116
}
117
+ _isGlobal = HasAttribute ( "VB_GlobalNamespace" ) || IsGlobalFromSubtypes ( ) ;
118
+ return _isGlobal . Value ;
119
+ }
120
+ }
100
121
101
- var attributeIsGlobalClassModule = false ;
102
- IEnumerable < string > value ;
103
- if ( Attributes . TryGetValue ( "VB_GlobalNamespace" , out value ) )
104
- {
105
- attributeIsGlobalClassModule = value . Single ( ) == "True" ;
106
- }
107
- _isGlobal = attributeIsGlobalClassModule ;
108
-
109
- if ( ! _isGlobal . Value )
122
+ private bool IsGlobalFromSubtypes ( )
123
+ {
124
+ var isGlobal = false ;
125
+ foreach ( var type in Subtypes )
110
126
{
111
- foreach ( var type in Subtypes )
127
+ if ( type is ClassModuleDeclaration && ( ( ClassModuleDeclaration ) type ) . IsGlobalClassModule )
112
128
{
113
- if ( type is ClassModuleDeclaration && ( ( ClassModuleDeclaration ) type ) . IsGlobalClassModule )
114
- {
115
- _isGlobal = true ;
116
- break ;
117
- }
129
+ isGlobal = true ;
130
+ break ;
118
131
}
119
132
}
120
-
121
- return _isGlobal . Value ;
133
+ return isGlobal ;
122
134
}
123
- }
135
+
124
136
125
137
private bool ? _hasPredeclaredId ;
126
138
/// <summary>
@@ -135,18 +147,12 @@ public bool HasPredeclaredId
135
147
{
136
148
return _hasPredeclaredId . Value ;
137
149
}
138
-
139
- var attributeHasDefaultInstanceVariable = false ;
140
- IEnumerable < string > value ;
141
- if ( Attributes . TryGetValue ( "VB_PredeclaredId" , out value ) )
142
- {
143
- attributeHasDefaultInstanceVariable = value . Single ( ) == "True" ;
144
- }
145
- _hasPredeclaredId = attributeHasDefaultInstanceVariable ;
150
+ _hasPredeclaredId = HasAttribute ( "VB_PredeclaredId" ) ;
146
151
return _hasPredeclaredId . Value ;
147
152
}
148
153
}
149
154
155
+
150
156
public bool HasDefaultInstanceVariable
151
157
{
152
158
get
0 commit comments