VContainer
VContainer copied to clipboard
Support dynamic registration from open generic type
#301
If the open generic type is registered, the closed generic type will be dynamically assembled at resolve time.
builder.Register(typeof(IFoo<,>), typeof(Foo<,>))
📝 Usage: https://github.com/Cysharp/MessagePipe/blob/master/src/MessagePipe/ServiceCollectionExtensions.cs#L43-L102
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/hadashia/vcontainer/BeCZQEMCyDrYStHXQN76EX5aXLAt
✅ Preview: https://vcontainer-git-ku-open-generics-hadashia.vercel.app
Since this approach is only making instances of the closed generic types using reflection it means it won't work with IL2CPP, right? It will only work if code generation is used since it will then generate the code that actually uses those types so they won't be missing in runtime.
I decided to adopt this one. #367
MakeGenericType seems to work in recent Unity. See also the comments.