JetBrains / JetBrains/resharper-unity
NotNull field warning and MonoBehaviour
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
Suppose you have the following:
```
[ExecuteAlways]
[RequireComponent(typeof(MeshCollider))]
public sealed class FacePickerTarget : MonoBehaviour
{
[NotNull]
public MeshCollider Collider;
[NotNull]
public List Triangles = new List();
private void Awake()
{
Collider = GetComponent();
}
private void OnEnable()
{
Collider = GetComponent();
}
}
```
You get an is not initalized on all execution paths.
Couldn't R# be smart enough to know that since it's a MonoBehaviour then it's done either in Awake or OnEnable ?
Contributor guide
Research direction
Start by reproducing the warning with the FacePickerTarget MonoBehaviour example and inspect how [NotNull] fields assigned in Awake and OnEnable are analyzed. Done means the requested lifecycle pattern is handled consistently without the uninitialized warning for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- game-dev, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100