Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested named resolution could cause stack overflow #74

Closed
z4kn4fein opened this issue Feb 13, 2020 · 1 comment
Closed

Nested named resolution could cause stack overflow #74

z4kn4fein opened this issue Feb 13, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@z4kn4fein
Copy link
Owner

In this scenario:

var container = new StashboxContainer(c => c
          .WithMemberInjectionWithoutAnnotation()
          .WithCircularDependencyTracking())
    .Register<ITest, Test>(c => c.DefinesScope("root").WithName("root"))
    .Register<ITest, Test1>(c => c.InNamedScope("root").DefinesScope("A"))
    .Register<ITest, Test2>(c => c.InNamedScope("root").DefinesScope("B"))
    .Register<ITest, Test3>(c => c.InNamedScope("A"))
    .Register<ITest, Test4>(c => c.InNamedScope("A"))
    .Register<ITest, Test5>(c => c.InNamedScope("B"))
    .Register<ITest, Test6>(c => c.InNamedScope("B"));

var r = container.Resolve<ITest>("root");

 interface ITest
 { }

 class Test : ITest
 {
     public ITest[] Subs { get; set; }
 }

 class Test1 : ITest
 {
     public ITest[] Subs { get; set; }
 }

 class Test2 : ITest
 {
     public ITest[] Subs { get; set; }
 }

 class Test3 : ITest
 { }

 class Test4 : ITest
 { }

 class Test5 : ITest
 { }

 class Test6 : ITest
 { }

Test1 and Test2 are selected even for scope A and B, but they should only when the bottom level scope is root. This causes circular resolution.

@z4kn4fein z4kn4fein added the bug label Feb 13, 2020
@z4kn4fein z4kn4fein added this to the v2.9.0 milestone Feb 13, 2020
@z4kn4fein z4kn4fein self-assigned this Feb 13, 2020
z4kn4fein added a commit that referenced this issue Feb 13, 2020
@z4kn4fein
Copy link
Owner Author

fixed in v3.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant