We have a dedicated diagnostic UNT0029
to prevent is-null check with UnityEngine.Object
. But IDE0041
will suggest to use is-null check over reference equality method.
IDE0041 - Use 'is null' check
using UnityEngine;
class Camera : MonoBehaviour
{
public void Update()
{
if (ReferenceEquals(transform, null))
return;
}
}
Under normal circumstances, ReferenceEquals(arg, null)
can be simplified to arg is null
. But doing that with UnityEngine.Object
will trigger UNT0029
.
We suppress IDE0041
for that very specific case, because instead you'll have no options for achieving the desired behaviour without suppressing a warning.