WithConcreteTypeDynamicRegistrations results in unintended instantiation
- Dominant language
- C#
- Stars
- 1.1k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
Using the `WithConcreteTypeDynamicRegistrations()`, when injecting a range of class, where no registrations has been added, results in instantation of an item.
**Other scenarios:**
1. When using `WithAutoConcreteTypeResolution` the issue does not occur.
2. If item has been registered, then issue does not occur.
3. Other range interfaces (`IList`, `ICollection` etc.) results in same issue.
4. Injecting a range of interfaces (eg. `IThing`), the issue does not occur.
**Setup:**
```
class Program
{
void Main()
{
var rules = Rules
.Default
//.WithAutoConcreteTypeResolution()
.WithConcreteTypeDynamicRegistrations();
var container = new Container(rules);
container.Register();
var registry = container.Resolve();
}
}
class MyRegistry
{
public MyRegistry(IEnumerable things)
{
/* 'things' contains a single thing */
Debugger.Break();
}
}
class Thing
{
Guid Id { get; set; }
}
```
**Expected Behavior:**
'things' should be empty.
**Current behavior:**
'things' contain a single item.
Contributor guide
Assessment
This issue has not been assessed yet.