JetBrains / JetBrains/resharper-unity
Suggestion to use "is { }" pattern for null checking is wrong.
Open
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
Take this piece of code:
```
private void OnDrawGizmosSelected()
{
Gizmos.DrawSphere(rb.position, 1.0f);
}
```
*Check expression for null* changes it to this which doesn't work for Unity objects:
```
private void OnDrawGizmosSelected()
{
if (rb is { })
Gizmos.DrawSphere(rb.position, 1.0f);
}
```
Instead it should do this:
```
private void OnDrawGizmosSelected()
{
if (rb != null)
Gizmos.DrawSphere(rb.position, 1.0f);
}
```
Now that's even more problematic because nowhere in the options this can be changed.
JetBrains ReSharper 2020.3 Build 203.0.20201211.113035
Unity Support 2020.3.1.132
Contributor guide
Assessment
This issue has not been assessed yet.