@@ -1270,6 +1270,75 @@ static void Main()
12701270 result . StdOut . ShouldBe ( [ "136" ] , result ) ;
12711271 }
12721272
1273+ [ Theory ]
1274+ [ InlineData ( 20 ) ]
1275+ [ InlineData ( 21 ) ]
1276+ [ InlineData ( 22 ) ]
1277+ [ InlineData ( 23 ) ]
1278+ [ InlineData ( 24 ) ]
1279+ [ InlineData ( 25 ) ]
1280+ [ InlineData ( 26 ) ]
1281+ [ InlineData ( 27 ) ]
1282+ [ InlineData ( 28 ) ]
1283+ [ InlineData ( 29 ) ]
1284+ [ InlineData ( 30 ) ]
1285+ public async Task ShouldFailWhenLightweightRootHasTooManyTaggedArguments ( int argsCount )
1286+ {
1287+ // Given
1288+ var ctorArgs = new global ::System . Collections . Generic . List < string > ( ) ;
1289+ var sumArgs = new global ::System . Collections . Generic . List < string > ( ) ;
1290+ var rootArgs = new global ::System . Collections . Generic . List < string > ( ) ;
1291+ var callArgs = new global ::System . Collections . Generic . List < string > ( ) ;
1292+ for ( var i = 1 ; i <= argsCount ; i ++ )
1293+ {
1294+ ctorArgs . Add ( $ "[Tag(\" a{ i } \" )] int a{ i } ") ;
1295+ sumArgs . Add ( $ "a{ i } ") ;
1296+ rootArgs . Add ( $ ".RootArg<int>(\" a{ i } \" , \" a{ i } \" )") ;
1297+ callArgs . Add ( i . ToString ( ) ) ;
1298+ }
1299+
1300+ var ctorSeparator = ",\n " ;
1301+ var rootSeparator = "\n " ;
1302+
1303+ var setupCode = $ """
1304+ using Pure.DI;
1305+
1306+ namespace Sample;
1307+
1308+ interface IService {{ int Sum {{ get; }} }}
1309+ class Service(
1310+ { string . Join ( ctorSeparator , ctorArgs ) } )
1311+ : IService
1312+ {{
1313+ public int Sum {{ get; }} = { string . Join ( " + " , sumArgs ) } ;
1314+ }}
1315+
1316+ partial class Composition
1317+ {{
1318+ void Setup() => DI.Setup(nameof(Composition))
1319+ .Hint(Hint.Resolve, "Off")
1320+ { string . Join ( rootSeparator , rootArgs ) }
1321+ .Bind<IService>().To<Service>()
1322+ .Root<IService>("Create", kind: RootKinds.Light);
1323+ }}
1324+
1325+ class Program
1326+ {{
1327+ static void Main()
1328+ {{
1329+ var composition = new Composition();
1330+ var service = composition.Create({ string . Join ( ", " , callArgs ) } );
1331+ }}
1332+ }}
1333+ """ ;
1334+
1335+ // When
1336+ var result = await setupCode . RunAsync ( new Options ( LanguageVersion . Preview , CheckCompilationErrors : false ) ) ;
1337+
1338+ // Then
1339+ result . Success . ShouldBeFalse ( result ) ;
1340+ }
1341+
12731342 [ Fact ]
12741343 public async Task ShouldFailWhenCallingLightweightRootWithWrongArgumentType ( )
12751344 {
0 commit comments