JetBrains / JetBrains/resharper-unity

unwarranted "Co-variant array conversion from Transform[] to Object[]" warning

Open
#2,437 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

We get a "Co-variant array conversion from Transform[] to Object[] can cause run-time exception on write operation" [warning](https://www.jetbrains.com/help/rider/CoVariantArrayConversion.html) when using eg [`Undo.RecordObjects(transforms, "Edit Transforms");`](https://docs.unity3d.com/ScriptReference/Undo.RecordObjects.html) (passing a `Transform[]` when the method signature only takes `Object[]`).

I understand why this happens, but in this case it's unwarranted because the array we pass will only be read, not written to. I'm sure there are more such examples in the Unity API.

- Is there a mechanism in Resharper to white-list methods for warnings? external annotations?
- If so, is there such a Unity-specific whitelist we can edit somewhere / send a PR?

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.