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.9k stars 164 forks source link

Support for Value Types delegate registration #521

Closed slimshader closed 9 months ago

slimshader commented 1 year ago

Fix for https://github.com/hadashiA/VContainer/issues/489

vercel[bot] commented 1 year 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 May 22, 2023 3:27pm
AlonTalmi commented 1 year ago

I get compile error when removing the constraint without casting the delegate like so:

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static RegistrationBuilder Register<TInterface>(
    this IContainerBuilder builder,
    Func<IObjectResolver, TInterface> implementationConfiguration,
    Lifetime lifetime)
{
    return builder.Register(new FuncRegistrationBuilder(Create, typeof(TInterface), lifetime));
    object Create(IObjectResolver resolver) => implementationConfiguration(resolver);
}
hadashiA commented 9 months ago

👍