Skip to content

Commit 7d705ee

Browse files
Fix lightweight root graph handling and max-arity test
1 parent 87c4467 commit 7d705ee

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/Pure.DI.Core/Core/DependencyGraphBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public IEnumerable<DependencyNode> Build(GraphBuildContext ctx)
5757
}
5858
else
5959
{
60-
if (node.Root.Kind.HasFlag(RootKinds.Light))
60+
if (node.Root.Source.Kind.HasFlag(RootKinds.Light)
61+
&& node.Root.Source.RootType is not INamedTypeSymbol { IsGenericType: true })
6162
{
6263
processed.Add(processingNode);
6364
}
@@ -562,4 +563,4 @@ private IProcessingNode CreateNewProcessingNode(ICache<ProcessingNodeKey, IProce
562563

563564
private static object? GetContextTag(Injection injection, DependencyNode node) =>
564565
node.Factory is { Source.HasContextTag: true } ? injection.Tag : null;
565-
}
566+
}

tests/Pure.DI.IntegrationTests/LightweightRootsTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,11 @@ class Service(
12121212
int a1, int a2, int a3, int a4,
12131213
int a5, int a6, int a7, int a8,
12141214
int a9, int a10, int a11, int a12,
1215-
int a13, int a14, int a15, int a16) : IService
1215+
int a13, int a14, int a15) : IService
12161216
{
12171217
public int Sum { get; } =
12181218
a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 +
1219-
a9 + a10 + a11 + a12 + a13 + a14 + a15 + a16;
1219+
a9 + a10 + a11 + a12 + a13 + a14 + a15;
12201220
}
12211221
12221222
partial class Composition
@@ -1226,7 +1226,7 @@ void Setup() => DI.Setup(nameof(Composition))
12261226
.RootArg<int>("a1").RootArg<int>("a2").RootArg<int>("a3").RootArg<int>("a4")
12271227
.RootArg<int>("a5").RootArg<int>("a6").RootArg<int>("a7").RootArg<int>("a8")
12281228
.RootArg<int>("a9").RootArg<int>("a10").RootArg<int>("a11").RootArg<int>("a12")
1229-
.RootArg<int>("a13").RootArg<int>("a14").RootArg<int>("a15").RootArg<int>("a16")
1229+
.RootArg<int>("a13").RootArg<int>("a14").RootArg<int>("a15")
12301230
.Bind<IService>().To<Service>()
12311231
.Root<IService>("Create", kind: RootKinds.Light);
12321232
}
@@ -1236,14 +1236,14 @@ class Program
12361236
static void Main()
12371237
{
12381238
var composition = new Composition();
1239-
Console.WriteLine(composition.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16).Sum);
1239+
Console.WriteLine(composition.Create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15).Sum);
12401240
}
12411241
}
12421242
""".RunAsync(new Options(LanguageVersion.Preview));
12431243

12441244
// Then
12451245
result.Success.ShouldBeTrue(result);
1246-
result.StdOut.ShouldBe(["136"], result);
1246+
result.StdOut.ShouldBe(["120"], result);
12471247
}
12481248

12491249
[Fact]

0 commit comments

Comments
 (0)