@@ -2578,5 +2578,91 @@ public void TestArrayItemAttribute()
2578
2578
var optionList = applicationType . GetProperty ( "OptionList" ) ;
2579
2579
Assert . Equal ( "Test_Generation_Namespace.T_OptionList" , optionList . PropertyType . FullName ) ;
2580
2580
}
2581
+
2582
+ [ Fact ]
2583
+ public void CollectionSetterInAttributeGroupInterfaceIsPrivateIfCollectionSetterModeIsPrivate ( )
2584
+ {
2585
+ const string xsd = @"<?xml version=""1.0"" encoding=""UTF-8""?>
2586
+ <xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
2587
+ <xs:element name=""Element"">
2588
+ <xs:complexType>
2589
+ <xs:attributeGroup ref=""AttrGroup""/>
2590
+ </xs:complexType>
2591
+ </xs:element>
2592
+
2593
+ <xs:attributeGroup name=""AttrGroup"">
2594
+ <xs:attribute name=""Attr"">
2595
+ <xs:simpleType>
2596
+ <xs:list itemType=""xs:int""/>
2597
+ </xs:simpleType>
2598
+ </xs:attribute>
2599
+ </xs:attributeGroup>
2600
+ </xs:schema>" ;
2601
+
2602
+ var generator = new Generator
2603
+ {
2604
+ NamespaceProvider = new NamespaceProvider
2605
+ {
2606
+ GenerateNamespace = key => "Test" ,
2607
+ } ,
2608
+ GenerateInterfaces = true ,
2609
+ CollectionSettersMode = CollectionSettersMode . Private
2610
+ } ;
2611
+ var contents = ConvertXml ( nameof ( CollectionSetterInAttributeGroupInterfaceIsPrivateIfCollectionSetterModeIsPrivate ) , xsd , generator ) . ToArray ( ) ;
2612
+ var assembly = Compiler . Compile ( nameof ( CollectionSetterInAttributeGroupInterfaceIsPrivateIfCollectionSetterModeIsPrivate ) , contents ) ;
2613
+
2614
+ var interfaceProperty = assembly . GetType ( "Test.IAttrGroup" ) ? . GetProperty ( "Attr" ) ;
2615
+ var implementerProperty = assembly . GetType ( "Test.Element" ) ? . GetProperty ( "Attr" ) ;
2616
+ Assert . NotNull ( interfaceProperty ) ;
2617
+ Assert . NotNull ( implementerProperty ) ;
2618
+
2619
+ var interfaceHasPublicSetter = interfaceProperty . GetSetMethod ( ) != null ;
2620
+ var implementerHasPublicSetter = implementerProperty . GetSetMethod ( ) != null ;
2621
+ Assert . False ( interfaceHasPublicSetter ) ;
2622
+ Assert . False ( implementerHasPublicSetter ) ;
2623
+ }
2624
+
2625
+ [ Fact ]
2626
+ public void CollectionSetterInAttributeGroupInterfaceIsPublicIfCollectionSetterModeIsPublic ( )
2627
+ {
2628
+ const string xsd = @"<?xml version=""1.0"" encoding=""UTF-8""?>
2629
+ <xs:schema xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
2630
+ <xs:element name=""Element"">
2631
+ <xs:complexType>
2632
+ <xs:attributeGroup ref=""AttrGroup""/>
2633
+ </xs:complexType>
2634
+ </xs:element>
2635
+
2636
+ <xs:attributeGroup name=""AttrGroup"">
2637
+ <xs:attribute name=""Attr"">
2638
+ <xs:simpleType>
2639
+ <xs:list itemType=""xs:int""/>
2640
+ </xs:simpleType>
2641
+ </xs:attribute>
2642
+ </xs:attributeGroup>
2643
+ </xs:schema>" ;
2644
+
2645
+ var generator = new Generator
2646
+ {
2647
+ NamespaceProvider = new NamespaceProvider
2648
+ {
2649
+ GenerateNamespace = key => "Test" ,
2650
+ } ,
2651
+ GenerateInterfaces = true ,
2652
+ CollectionSettersMode = CollectionSettersMode . Public
2653
+ } ;
2654
+ var contents = ConvertXml ( nameof ( CollectionSetterInAttributeGroupInterfaceIsPublicIfCollectionSetterModeIsPublic ) , xsd , generator ) . ToArray ( ) ;
2655
+ var assembly = Compiler . Compile ( nameof ( CollectionSetterInAttributeGroupInterfaceIsPublicIfCollectionSetterModeIsPublic ) , contents ) ;
2656
+
2657
+ var interfaceProperty = assembly . GetType ( "Test.IAttrGroup" ) ? . GetProperty ( "Attr" ) ;
2658
+ var implementerProperty = assembly . GetType ( "Test.Element" ) ? . GetProperty ( "Attr" ) ;
2659
+ Assert . NotNull ( interfaceProperty ) ;
2660
+ Assert . NotNull ( implementerProperty ) ;
2661
+
2662
+ var interfaceHasPublicSetter = interfaceProperty . GetSetMethod ( ) != null ;
2663
+ var implementerHasPublicSetter = implementerProperty . GetSetMethod ( ) != null ;
2664
+ Assert . True ( interfaceHasPublicSetter ) ;
2665
+ Assert . True ( implementerHasPublicSetter ) ;
2666
+ }
2581
2667
}
2582
2668
}
0 commit comments