JetBrains / JetBrains/resharper-unity

"Comparison to null is expensive" and "unity lifetime check" icon on implicit lifetime check, but not on explicit

Open
#2,477 0 comments 6 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

If you compare a unity object against null, you get the "Comparison to null is expensive" warning and the "implicit check for unity object lifetime" icon.

![Image](https://github.com/user-attachments/assets/26a35585-1f8a-4d82-930c-105dade63e85)

![Image](https://github.com/user-attachments/assets/8d6ae37d-426d-44dc-abed-6ce79b32b240)

If you then convert it to the explicit check per resharper suggestion, both hints disappear, even though the check is still performed.

![Image](https://github.com/user-attachments/assets/350e64e0-bfb7-4ad8-9931-924aa2dd7d11)

![Image](https://github.com/user-attachments/assets/336d4053-cdde-45ae-8120-24d5ce0ec7c0)

Expected:
Both icon and hint for expensive operation should still be there.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Unity object comparison and explicit lifetime-check cases described in the issue, then locate the inspection responsible for the warning and lifetime icon. Done means the explicit check still reports both the expensive-operation hint and the implicit Unity lifetime-check icon, with coverage for both forms if the existing test structure supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.