Closed Heroshrine closed 3 months ago
The "bypass lifetime check" inspections have changed in 2024.1. Instead of showing a warning when using ?.
or ??
, we now show a hint for ==
and !=
.
The main reason for this is that there were many scenarios when the inspections weren't working, e.g. GetSomething()?.whatever
would not be highlighted. We fixed all of these scenarios, but now it's too noisy - we're showing a lot of highlights telling you that something is working like normal C# code.
So we changed the inspection to show a highlight for when code was doing something other than normal C# code, i.e. for Unity objects' overridden ==
and !=
operators.
It's possible to re-enable the old inspections - go to Settings | Editor | Inspection Settings | Inspection Severity | C# and look for "Possible unintended bypass of lifetime check" in the Unity section (you can just search for this too).
Ok, I did see a warning for == and !=, but it suggested to use if(!object) and (object) for performance, but both ==/!= and if(object)/if(!object) call the same underlying method, so I'm not sure if it should be suggesting that. Not sure if it's related.
In the above image,
a?.
should provide a warning to not use null propagation, since it is a Unity Object.Unity Editor version 6000.0.4f1, JetBrains Rider Editor package version 3.0.28.