Skip to content

Commit

Permalink
Fix benchmarking and only use Base if we didn't actually get a result
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-andersson-at-westermo committed Aug 30, 2024
1 parent f6ea6c2 commit 42bfbe4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Benchmarking/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Benchmarks;
[JsonExporterAttribute.FullCompressed]
public class ResolveBenchmarks
{
private readonly IContainer m_container = new DependencyInjectionContainer(default, default, default!);
private readonly IContainer m_container = new DependencyInjectionContainer(default, default, new NonInjectedClass());

[Benchmark]
public ChainA ResolveChain() => m_container.Resolve<ChainA>();
Expand Down
4 changes: 2 additions & 2 deletions FactoryGenerator/FactoryGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public bool TryResolve(Type type, out object? resolved)
resolved = factory();
return true;
}}
if(Base is not null)
else if(Base is not null)
{{
return Base.TryResolve(type, out resolved);
}}
Expand All @@ -516,7 +516,7 @@ public bool TryResolve<T>(out T? resolved)
return true;
}}
}}
if(Base is not null)
else if(Base is not null)
{{
return Base.TryResolve<T>(out resolved);
}}
Expand Down
1 change: 1 addition & 0 deletions Tests/FactoryGenerator.Tests/InjectionDetectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void ContainerMayCreateItself()
var newContainer = new DependencyInjectionContainer(m_container);
var resolved = m_container.Resolve<IEnumerable<IArray>>();
resolved.Count().ShouldBe(6);
var nonInjected = m_container.Resolve<Inherited.NonInjectedClass>();
}
[Fact]
public void HierarchicalContainersResolveArraysProperly()
Expand Down

0 comments on commit 42bfbe4

Please sign in to comment.