Skip to content

Commit

Permalink
Fixed #263 (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Apr 12, 2022
1 parent 46673bc commit 9d02993
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,14 @@ public void EmptyEnumerableIsResolvedIfElementTypeIsMissingBinding()

children.Should().BeEmpty();
}

[Fact]
public void EmptyEnumerableIsResolvedIfElementTypeIsMissingBindingEvenIsWasResoved()
{
var child = this.Kernel.Get<ChildA>();
var children = this.Kernel.Get<IEnumerable<ChildA>>();

children.Should().BeEmpty();
}
}
}
}
4 changes: 2 additions & 2 deletions src/Ninject/KernelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void UpdateRequest(Type service)
{
if (handleMissingBindings && this.HandleMissingBinding(request))
{
return this.Resolve(request, false);
return this.Resolve(request);
}

if (request.IsOptional)
Expand Down Expand Up @@ -568,7 +568,7 @@ from binding in satisfiedBindings
}
else
{
if (satisfiedBindings.Any(binding => !binding.IsImplicit))
if (satisfiedBindings.Any(binding => !binding.IsImplicit) || !handleMissingBindings)
{
satisfiedBindings = satisfiedBindings.Where(binding => !binding.IsImplicit);
}
Expand Down

0 comments on commit 9d02993

Please sign in to comment.