JetBrains / JetBrains/resharper-unity
Incorrect repeated access warning
- 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
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