@@ -1093,7 +1093,7 @@ namespace Sample
10931093 {
10941094 class SetupBase
10951095 {
1096- private static void SetupBaseComposition1 ()
1096+ private static void SetupBaseComposition ()
10971097 {
10981098 DI.Setup("RootNamespace.Sample.SetupBase", CompositionKind.Internal)
10991099 .Bind<int>().To(_ => 1);
@@ -1140,7 +1140,7 @@ namespace Sample
11401140 {
11411141 class SetupBase
11421142 {
1143- private static void SetupBaseComposition1 ()
1143+ private static void SetupBaseComposition ()
11441144 {
11451145 DI.Setup(kind: CompositionKind.Internal)
11461146 .Bind<int>().To(_ => 1);
@@ -1172,6 +1172,106 @@ public static void Main()
11721172 result . StdOut . ShouldBe ( [ "1" ] , result ) ;
11731173 }
11741174
1175+ [ Fact ]
1176+ public async Task ShouldSupportInheritanceOfCompositions ( )
1177+ {
1178+ // Given
1179+
1180+ // When
1181+ var result = await """
1182+ using System;
1183+ using Pure.DI;
1184+
1185+ namespace Sample
1186+ {
1187+ class SetupBase
1188+ {
1189+ private static void SetupBaseComposition()
1190+ {
1191+ DI.Setup(kind: CompositionKind.Internal)
1192+ .Bind<int>().To(_ => 1);
1193+ }
1194+ }
1195+
1196+ class SetupBase2: SetupBase
1197+ {
1198+ private static void SetupBaseComposition()
1199+ {
1200+ DI.Setup(kind: CompositionKind.Internal)
1201+ .Bind<string>().To(_ => "Abc");
1202+ }
1203+ }
1204+
1205+ partial class Setup: SetupBase2
1206+ {
1207+ private static void SetupComposition()
1208+ {
1209+ DI.Setup("Composition")
1210+ .Root<int>("Root")
1211+ .Root<string>("Root2");
1212+ }
1213+ }
1214+
1215+ public class Program
1216+ {
1217+ public static void Main()
1218+ {
1219+ var composition = new Composition();
1220+ Console.WriteLine(composition.Root);
1221+ Console.WriteLine(composition.Root2);
1222+ }
1223+ }
1224+ }
1225+ """ . RunAsync ( ) ;
1226+
1227+ // Then
1228+ result . Success . ShouldBeTrue ( result ) ;
1229+ result . StdOut . ShouldBe ( [ "1" , "Abc" ] , result ) ;
1230+ }
1231+
1232+ [ Fact ]
1233+ public async Task ShouldSupportDependsOnBaseClassWhenDefaultNameAndHasNoNamespace ( )
1234+ {
1235+ // Given
1236+
1237+ // When
1238+ var result = await """
1239+ using System;
1240+ using Pure.DI;
1241+
1242+ class SetupBase
1243+ {
1244+ private static void SetupBaseComposition()
1245+ {
1246+ DI.Setup(kind: CompositionKind.Internal)
1247+ .Bind<int>().To(_ => 1);
1248+ }
1249+ }
1250+
1251+ partial class Setup: SetupBase
1252+ {
1253+ private static void SetupComposition()
1254+ {
1255+ DI.Setup("Composition")
1256+ .Root<int>("Root");
1257+ }
1258+ }
1259+
1260+ public class Program
1261+ {
1262+ public static void Main()
1263+ {
1264+ var composition = new Composition();
1265+ Console.WriteLine(composition.Root);
1266+ }
1267+ }
1268+ """ . RunAsync ( ) ;
1269+
1270+ // Then
1271+ result . Success . ShouldBeTrue ( result ) ;
1272+ result . StdOut . ShouldBe ( [ "1" ] , result ) ;
1273+ }
1274+
11751275#if ROSLYN4_8_OR_GREATER
11761276 [ Fact ]
11771277 public async Task ShouldSupportMultipleBaseCompositions ( )
0 commit comments