Instantiating with null extra args ends with exception
Once creating game object for component via IInstantiator, like:
_instantiator.InstantiateComponent<MyComponent>(_executor, new object[] { task = task, onSuccess = onSuccess // <-- this is null });
ends with error indebug:
ZenjectException: Assert hit! Cannot include null values when creating a zenject argument list because zenject has no way of deducing the type from a null value. If you want to allow null, use the Explicit form.
what does the If you want to allow null, use the Explicit form actually means? Cannot find any official docs on it.
you need to pass a List<TypeValuePair> manually, since Zenject can't determine the contract type of null (using GetType()). So you need to use the _instantiator.InstantiateComponentExplicit<MyComponent>() method instead. And instead of using new object[] { ... } you need to use the more verbose strategy var args = new List<TypeValuePair>() { new TypeValuePair(typeof(TypeOfYourNullThing), null) } ;