@@ -69,6 +69,7 @@ public ModelBuilder(GeneratorConfiguration configuration, XmlSchemaSet set)
69
69
70
70
if ( configuration . GenerateInterfaces )
71
71
{
72
+ PromoteInterfacePropertiesToCollection ( ) ;
72
73
RenameInterfacePropertiesIfRenamedInDerivedClasses ( ) ;
73
74
RemoveDuplicateInterfaceProperties ( ) ;
74
75
}
@@ -184,7 +185,8 @@ private void RenameInterfacePropertiesIfRenamedInDerivedClasses()
184
185
{
185
186
if ( implementationClassProperty . Name != implementationClassProperty . OriginalPropertyName
186
187
&& implementationClassProperty . OriginalPropertyName == interfaceProperty . Name
187
- && implementationClassProperty . XmlSchemaName == interfaceProperty . XmlSchemaName )
188
+ && implementationClassProperty . XmlSchemaName == interfaceProperty . XmlSchemaName
189
+ && implementationClassProperty . IsAttribute == interfaceProperty . IsAttribute )
188
190
{
189
191
RenameInterfacePropertyInBaseClasses ( interfaceModel , implementationClass , interfaceProperty , implementationClassProperty . Name ) ;
190
192
interfaceProperty . Name = implementationClassProperty . Name ;
@@ -195,6 +197,28 @@ private void RenameInterfacePropertiesIfRenamedInDerivedClasses()
195
197
}
196
198
}
197
199
200
+ private void PromoteInterfacePropertiesToCollection ( )
201
+ {
202
+ foreach ( var interfaceModel in Types . Values . OfType < InterfaceModel > ( ) )
203
+ {
204
+ foreach ( var interfaceProperty in interfaceModel . Properties )
205
+ {
206
+ var derivedProperties = interfaceModel . AllDerivedReferenceTypes ( ) . SelectMany ( t => t . Properties )
207
+ . Where ( p => p . Name == interfaceProperty . Name || p . OriginalPropertyName == interfaceProperty . Name ) . ToList ( ) ;
208
+
209
+ if ( derivedProperties . Any ( p => p . IsCollection ) )
210
+ {
211
+ foreach ( var derivedProperty in derivedProperties . Where ( p => ! p . IsCollection ) )
212
+ {
213
+ derivedProperty . IsCollection = true ;
214
+ }
215
+
216
+ interfaceProperty . IsCollection = true ;
217
+ }
218
+ }
219
+ }
220
+ }
221
+
198
222
private static void RenameInterfacePropertyInBaseClasses ( InterfaceModel interfaceModel , ReferenceTypeModel implementationClass ,
199
223
PropertyModel interfaceProperty , string newName )
200
224
{
@@ -752,6 +776,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForAttributes(Uri source, Typ
752
776
{
753
777
var attributeQualifiedName = attribute . AttributeSchemaType . QualifiedName ;
754
778
var attributeName = _configuration . NamingProvider . AttributeNameFromQualifiedName ( attribute . QualifiedName , attribute ) ;
779
+ var originalAttributeName = attributeName ;
755
780
756
781
if ( attribute . Parent is XmlSchemaAttributeGroup attributeGroup
757
782
&& attributeGroup . QualifiedName != typeModel . XmlSchemaName
@@ -795,6 +820,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForAttributes(Uri source, Typ
795
820
{
796
821
OwningType = typeModel ,
797
822
Name = attributeName ,
823
+ OriginalPropertyName = originalAttributeName ,
798
824
XmlSchemaName = attribute . QualifiedName ,
799
825
Type = CreateTypeModel ( attribute . AttributeSchemaType , attributeQualifiedName ) ,
800
826
IsAttribute = true ,
0 commit comments