Update USP0022.md
This commit is contained in:
Родитель
fcaa655a81
Коммит
f2a944c6cc
|
@ -1,4 +1,4 @@
|
|||
# USP0022 Prefer reference equality
|
||||
# USP0022 Unity objects should not use if null coalescing
|
||||
|
||||
We have a dedicated diagnostic `UNT0029` to prevent is-null check with `UnityEngine.Object`. But `IDE0270` will suggest to use is-null check over reference equality method.
|
||||
|
||||
|
@ -29,4 +29,4 @@ Under normal circumstances, `if (item == null) throw new System.InvalidOperation
|
|||
|
||||
## Why do we suppress this diagnostic?
|
||||
|
||||
Unity has overridden the `==` operator for `UnityEngine.Object`. If you use the `==` operator to compare a `UnityEngine.Object` to null, it will return true if the `UnityEngine.Object` is destroyed, even if the object itself isn't actually null. The `??` operator cannot be overridden in this way, and therefore behaves inconsistently with the `==` operator, because it checks for null in a different way.
|
||||
Unity has overridden the `==` operator for `UnityEngine.Object`. If you use the `==` operator to compare a `UnityEngine.Object` to null, it will return true if the `UnityEngine.Object` is destroyed, even if the object itself isn't actually null. The `??` operator cannot be overridden in this way, and therefore behaves inconsistently with the `==` operator, because it checks for null in a different way.
|
||||
|
|
Загрузка…
Ссылка в новой задаче