unitycontainer / registration-by-convention

Unity.RegistrationByConvention package (Requires Core Implementation. Any contributors?)
Apache License 2.0
4 stars 12 forks source link

Bug ? in public static IUnityContainer RegisterTypes #6

Closed Mer0winger closed 5 years ago

Mer0winger commented 6 years ago

In the RegisterTypes Method there is this else condition bleow which will register any type even if i put FromMatchingInterface to the Method. If the FromMatchingInterface returning Null ( which happens in my App a lot ) anyhow the Method creates a registry entry.

But it should only create a register if for a Class an IClass Interface exists or not ? So if this is not a Bug how can i avoid this RegisterType of Types where no Interface by anming Convention exists ?

br

            else
            {
                var lifetimeManager = getLifetimeManager(type);
                if (null != lifetimeManager || (null != injectionMembers && 0 < injectionMembers.Length))
                    container.RegisterType(null, type, name, lifetimeManager, injectionMembers);
            }
ENikS commented 6 years ago

Not really sure if it is. It was there before I took over. You have a better solution?

yfital commented 5 years ago

You basically cannot avoid having to insert all types if your lifetime manager isn't null. Although I thought this is a definite bug, maybe it was by choice.

They say that although your types are not discoverable for a specific interface, the class itself should be registered in unity as it was requested by the lifetime manager.

Sounds to me like there is a need for an extra parameter here in the function itself (e.g. "register none discoverable types")?

ENikS commented 5 years ago

If you could provide a unit test that I can run and if you explain what is wrong with the implementation, I could try to fix it.

ENikS commented 5 years ago

Closing for lack of tests