Skip to content

Support dynamic registration from open generic type#200

Closed
hadashiA wants to merge 1 commit intomasterfrom
ku/open-generics
Closed

Support dynamic registration from open generic type#200
hadashiA wants to merge 1 commit intomasterfrom
ku/open-generics

Conversation

@hadashiA
Copy link
Copy Markdown
Owner

@hadashiA hadashiA commented Apr 24, 2021

#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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 24, 2021

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

@igor84
Copy link
Copy Markdown

igor84 commented Aug 21, 2022

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.

@hadashiA
Copy link
Copy Markdown
Owner Author

I decided to adopt this one. #367

MakeGenericType seems to work in recent Unity. See also the comments.

@hadashiA hadashiA closed this Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants