Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 653 Bytes

USP0010.md

File metadata and controls

26 lines (17 loc) · 653 Bytes

USP0010 Don't flag fields with the ContextMenuItem attribute as unused

Fields decorated with the ContextMenuItem attribute are not unused.

Suppressed Diagnostic ID

IDE0051 - Remove unused private members

Examples of code that produces a suppressed diagnostic

using UnityEngine;

class Camera : MonoBehaviour
{
    [ContextMenuItem("Foo", "Bar")]
    private string contextMenuString = "";
}

Why is the diagnostic reported?

The IDE cannot detect any references to contextMenuString in the class.

Why do we suppress this diagnostic?

contextMenuString is used indirectly by Unity, which is undetectable by the IDE.