ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 366 forks source link

[InjectOptional] int causes NullReference #639

Open NoxMortem opened 5 years ago

NoxMortem commented 5 years ago

Found during reporting https://github.com/modesttree/Zenject/issues/638

Documentation

If the dependency is a primitive type (eg. int, float, struct) then it will be injected with its default value (eg. 0 for ints).

This causes a NullReference

public void Inject([InjectOptional] LayerController layerController, [InjectOptional] int controlsLayer)

This does not:

public void Inject([InjectOptional] LayerController layerController, int controlsLayer = 0)