Skip to content

RegisterInstance() throws incorrect exception #351

@ENikS

Description

@ENikS

RegisterInstance(...)

The method is defined by IUnityContainer as the following:

IUnityContainer RegisterInstance(Type type, string name, object instance, IInstanceLifetimeManager lifetimeManager);

Registered Type

Registration Type is determined either by explicit parameter type, or implicitly from type of the instance. When method RegisterInstance(...) is called with both type and instance as null` exception is thrown.

Exception

By convention, when argument is null, exception System.ArgumentNullException should be thrown. Instead, Unity throws System.InvalidOperationException

Solution

Unity must throw correct exception: System.ArgumentNullException

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions