dadhi / dadhi/DryIoc

WithConcreteTypeDynamicRegistrations results in unintended instantiation

Open
#643 3 comments 1 reaction 2 assignees Claimed by @dadhi View on GitHub
bug
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.