modesttree / Zenject

Dependency Injection Framework for Unity3D
MIT License
2.43k stars 269 forks source link

Baking Issues #14

Open extrawurst opened 5 years ago

extrawurst commented 5 years ago

Hey @svermeulen sorry to bother you with this. But I am still struggling with those baking issues since 8.0.1: https://github.com/modesttree/Zenject/issues/603

I am now using namespace pattern ^ and I tried checking All generated Assemblies and still see some types not being found in the baking data like:

LayoutGroup
GraphicRaycaster
TMP_InputField
...

Actually all these types I don't need Zenject to Inject. Is there maybe a way to annotate a field to be ignored in the Injection phase to? Something like [NoInject]?

I am on Unity 2018.3.4.1f1

svermeulen commented 5 years ago

There is the [NoReflectionBaking] attribute.

One important thing to be aware of is that zenject is only able to add reflection baking to libraries that reference Zenject-usage.dll (since baking needs to add code that makes use of that to the library). So if you have a library that has MonoBehaviours in it, which doesn't reference zenject, and you include that a zenject scene, that it will have to use runtime injection.

If you're sure that everywhere that you need injection is baked, then you can use the ReflectionBakingCoverageModes.NoCheckAssumeFullCoverage mode. This will not fallback on runtime reflection so you can avoid the performance penalty for monobehaviours you don't care about, but you have to be careful that everything is fully baked for that to work. FallbackToDirectReflectionWithWarning is useful to list all the classes would be skipped