@@ -136,15 +136,16 @@ private static Property GetProperty(Method method, string name,
136
136
{
137
137
Type underlyingType = GetUnderlyingType ( type ) ;
138
138
Class @class = ( Class ) method . Namespace ;
139
+
139
140
Property property = @class . Properties . Find (
140
141
p => p . Field == null &&
141
- ( ( ! isSetter && p . HasSetter && p . Name == name ) ||
142
- ( isSetter && p . HasGetter &&
143
- GetReadWritePropertyName ( p . GetMethod , name ) == name ) ) &&
144
- ( ( p . HasGetter &&
145
- GetUnderlyingType ( p . GetMethod . OriginalReturnType ) . Equals ( underlyingType ) ) ||
146
- ( p . HasSetter &&
147
- GetUnderlyingType ( p . SetMethod . Parameters [ 0 ] . QualifiedType ) . Equals ( underlyingType ) ) ) ) ??
142
+ ( ( ! isSetter && p . SetMethod ? . IsStatic == method . IsStatic ) ||
143
+ ( isSetter && p . GetMethod ? . IsStatic == method . IsStatic ) ) &&
144
+ ( ( p . HasGetter && GetUnderlyingType (
145
+ p . GetMethod . OriginalReturnType ) . Equals ( underlyingType ) ) ||
146
+ ( p . HasSetter && GetUnderlyingType (
147
+ p . SetMethod . Parameters [ 0 ] . QualifiedType ) . Equals ( underlyingType ) ) ) &&
148
+ Match ( p , name ) ) ??
148
149
new Property { Name = name , QualifiedType = type } ;
149
150
150
151
if ( property . Namespace == null )
@@ -160,13 +161,43 @@ private static Property GetProperty(Method method, string name,
160
161
( int ) method . Access ) ;
161
162
}
162
163
163
- property . Name = property . OriginalName = name ;
164
164
method . GenerationKind = GenerationKind . Internal ;
165
165
if ( method . ExplicitInterfaceImpl != null )
166
166
property . ExplicitInterfaceImpl = method . ExplicitInterfaceImpl ;
167
167
return property ;
168
168
}
169
169
170
+ private static bool Match ( Property property , string name )
171
+ {
172
+ if ( string . IsNullOrEmpty ( name ) )
173
+ return false ;
174
+
175
+ if ( property . Name == name )
176
+ return true ;
177
+
178
+ if ( property . Name == RemovePrefix ( name ) )
179
+ return true ;
180
+
181
+ if ( RemovePrefix ( property . Name ) == name )
182
+ {
183
+ property . Name = property . OriginalName = name ;
184
+ return true ;
185
+ }
186
+
187
+ return property . SetMethod != null &&
188
+ GetPropertyNameFromSetter ( property . SetMethod . Name ) == name ;
189
+ }
190
+
191
+ private static string RemovePrefix ( string identifier )
192
+ {
193
+ if ( string . IsNullOrEmpty ( identifier ) )
194
+ return identifier ;
195
+
196
+ string name = GetPropertyName ( identifier ) ;
197
+ return name . StartsWith ( "is" , StringComparison . Ordinal ) && name != "is" ?
198
+ char . ToLowerInvariant ( name [ 2 ] ) + name . Substring ( 3 ) : name ;
199
+ }
200
+
170
201
private static void ProcessProperties ( Class @class , IEnumerable < Property > newProperties )
171
202
{
172
203
foreach ( Property property in newProperties )
@@ -275,17 +306,6 @@ private static void RenameConflictingMethods(Class @class, Property property)
275
306
}
276
307
}
277
308
278
- private static string GetReadWritePropertyName ( INamedDecl getter , string afterSet )
279
- {
280
- string name = GetPropertyName ( getter . Name ) ;
281
- if ( name != afterSet && name . StartsWith ( "is" , StringComparison . Ordinal ) &&
282
- name != "is" )
283
- {
284
- name = char . ToLowerInvariant ( name [ 2 ] ) + name . Substring ( 3 ) ;
285
- }
286
- return name ;
287
- }
288
-
289
309
private static Type GetUnderlyingType ( QualifiedType type )
290
310
{
291
311
TagType tagType = type . Type as TagType ;
0 commit comments