JetBrains / JetBrains/resharper-unity

Incorrect repeated access warning

Open
#1,627 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

The following code is throwing the warning `Repeated property access of built in component is inefficient` which is not correct.

``` csharp
private IEnumerator ToggleLaser()
{
lineRenderer.enabled = true;
yield return null;
lineRenderer.enabled = false;
}
```

The suggested fix:
``` csharp
private IEnumerator ToggleLaser()
{
var enabled1 = lineRenderer.enabled;
enabled1 = true;
yield return null;
enabled1 = false;
lineRenderer.enabled = enabled1;
}
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning with the C# ToggleLaser snippet from the issue and trace the inspection that reports repeated access to lineRenderer.enabled. No source file or test is named; done means the valid property assignments no longer produce the inefficient-access warning or its suggested rewrite.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.