-
Notifications
You must be signed in to change notification settings - Fork 529
Changes in Ninject 4
As of Ninject 4 we only support the following target frameworks:
- .NET Framework 4.6 (and higher)
- .NET Standard 2.0
A major focus point for Ninject 4 is moving the needle for both performance and memory usage.
TODO Link to a benchark, and images showing the advancements.
TODO Scott
Even though injection into private members is generally considered to be a bad practice, Ninject provides knobs to enable private constructor, method and property injection.
To encourage you to move away from private member injection, both the InjectNonPublic and InjectParentPrivateProperties properties on (I)NinjectSettings are marked obsolete as of this release.
Unless we receive strong user feedback to keep this feature, support for private member injection will be removed in the next major release.
By default, Ninject now uses expression trees for injection instead of LCG which ensures compatibility with .NET Native (and other AOT runtimes).
The UseReflectionBasedInjection setting can be used to switch to reflection based injection.
A new PropertyInjection property on (I)NinjectSettings has been introduced to allow one to disable property injection.
For those using only constructor or method injection, disabling property injection yields a minor performance bump.
By default, property injection remains enabled.
A new MethodInjection property on (I)NinjectSettings has been introduced to allow one to disable method injection.
For those using only constructor or property injection, disabling method injection yields a minor performance bump.
By default, method injection remains enabled.
This section provides a list of (breaking) API changes that we introduced. These changes only affect extensibility authors.
Changed return value of IBindingResolver (and implementing classes) from IEnumerable<IBinding>
to ICollection<IBinding>
.
Changed return value of ISelector.SelectConstructorsForInjection(Type type)
(and implementing classes) from IEnumerable<ConstructorInfo>
to ConstructorInfo[]
.
The T Get<T>(string key, T defaultValue)
and void Set(string key, object value)
methods have been removed from INinjectSettings.
The GetBindings(Type service)
method now returns IBinding[]
instead of IEnumerable<IBinding>
.
The GetBindings(Type service)
method now returns IBinding[]
instead of IEnumerable<IBinding>
.
The GetBindings(Type service)
method now returns IBinding[]
instead of IEnumerable<IBinding>
.
- A StackOverflowException is thrown when type is a self-bindable, but the registered binding does not match (#341)
- Attempt to resolve an unbound generic type definition results in an IndexOutOfRangeException (#340
- Bind/Rebind to a constant List always returns an empty list (#333)
- Request for List<T> takes implicit binding into account (#263)
- Service is cached for scope when member injection fails (#262)
- Building with NO_LCG results in test failure (#219)
- Deadlock between
ICache.Clear()
andICache.TryGet(IContext context)
(#182) - Not compatible with UWP using .NET Native tool chain (#271)
Licensed under Apache 2 License
Contents
- Home
- Why Use Ninject
- Getting Started
- Dependency Injection By Hand
- Dependency Injection With Ninject
- Injection Patterns
- Multi Injection
- Object Scopes
- Modules and the Kernel
- Providers, Factory Methods and the Activation Context
- The Activation Process
- How Injection Works
- Contextual Binding
- Conventions-Based Binding