Open stefnotch opened 6 years ago
That is not the purpose of NotNull. It is a design-time only attribute used to let ReSharper do a static analysis to detect wrong usages of nullability.
See: https://www.jetbrains.com/help/resharper/Reference__Code_Annotation_Attributes.html
@Kryptos-FR Oh, I assumed that it didn't have anything to do with that [NotNull]
attribute, since it's defined inside SiliconStudio.Core.Annotations
.
Well, what would be an alternative to achieve what I want to achieve? It's not that uncommon that a component needs a reference to another component to work properly.
Checking it in code would require me to write a lot of extra code that I would prefer to avoid writing. Also, it would be a runtime check rather than a game-studio-time check.
Dependency injection would be one alternative that I can think of right now.
The use case would be making sure that every entity has all required components. For example, a player controller component (move the player with the keyboard) needs a camera.
Though, only public properties which can be edited in the game studio should be checked.