dadhi / DryIoc

DryIoc is fast, small, full-featured IoC Container for .NET
MIT License
1.02k stars 124 forks source link

KeyValuePair exposes internal DryIoc structures #653

Closed jods4 closed 1 month ago

jods4 commented 2 months ago

Using DryIoc version 6.0.0-preview-7. This is in an .NET 8 application, that also has DryIoc.Microsoft.DependencyInjection 8.0.0-preview-02, should it matter. All options are default ones (for MS DI package).

Setup

  1. We register multiple instances of IService with different (string) keys. container.Register(serviceType, implementationType, reuse, ifAlreadyRegistered, serviceKey /* :string */)

  2. Then we inject IEnumerable<KeyValuePair<object, IService>> into a ctor.

Result

The keys are not strings but DryIoc internal UniqueRegisteredServiceKey, which should have been unwrapped. Trying to inject IEnumerable<KeyValuePair<string, IService>> fails (no result), which makes sense given the previous result.

dadhi commented 2 months ago

Great catch. Thank you. Will fix.