JetBrains / JetBrains/resharper-unity

Add inspection for script with name of built in component, e.g. "Grid"

Open
#597 2 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

If a script has the same name as a built in component, the following warning is displayed in the Unity console:

> Script 'Grid' has the same name as built-in Unity component.
> AddComponent and GetComponent will not work with this script.

Presumably, this means `GameObject.AddComponent(string)` and `GameObject.GetComponent(string)`, both of which are marked as obsolete, and should be replaced with typesafe versions, using `typeof` or type parameters.

However, the warning remains. Add an inspection to mimic this warning inside the code editor.

Also, add a code inspection wiki entry to provide more details. Will probably need more information on the list of known components and why it doesn't work with `AddComponent`/`GetComponent`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.