hadashiA / VContainer

The extra fast, minimum code size, GC-free DI (Dependency Injection) library running on Unity Game Engine.
https://vcontainer.hadashikick.jp
MIT License
1.88k stars 163 forks source link

With parameter resolver #640

Closed hadashiA closed 6 months ago

hadashiA commented 6 months ago

port from #570

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
vcontainer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 2, 2024 2:13am
christopher-qde commented 5 months ago

Just a FYI, this ended up being a breaking change in my current project. Me defining a type parameter as string but sending in null gives me:

error CS0121: The call is ambiguous between the following methods or properties: 'RegistrationBuilder.WithParameter<TParam>(TParam)' and 'RegistrationBuilder.WithParameter<TParam>(Func<IObjectResolver, TParam>)'

Also... I've relied on sending in null for a Func, as a optional constructor parameter. I've used WithParameter to optionally set this. This now gets interpreted as the lazy resolve overload, and throws a NRE as it tries to invoke the null. My solution was to create a Func that returns null rather than just sending in null to WithParameter.