JetBrains / JetBrains/resharper-unity
conflicting file and class names should raise warnings / offer fixes
- Dominant language
- C#
- Stars
- 1.2k
- Forks
- 142
- PR merge metrics
- No merged PRs in 30d
Description
In unity, components that have an ancestor of `MonoBehaviour` must match their file name if they are to function as components. In my case, I my code looked like this:
```md
// Player/Manager.cs
public class PlayerManager : EffectableBase { ... }
// EffectableBase.cs
public class EffectableBase : MonoBehaviour { ... }
```
I was slowly collecting a lot of `Player*.cs` components and wanted to reorganize a little, some of those components didn't end up exclusively belonging to `Player` anymore.
I eventually remembered that I needed to rename the class "PlayerManager" to match the filename of "Manager.cs", but this managed to blindside me because I renamed from within Rider. Neither Unity nor Rider raised any errors, my Player object simply had an invalid script reference and I couldn't tell why until I couldn't find the class in the Add Component menu.
Contributor guide
Assessment
This issue has not been assessed yet.