873 B
873 B
USP0019 Don't flag private methods decorated with PreserveAttribute or UsedImplicitlyAttribute as unused
Methods decorated with PreserveAttribute
or UsedImplicitlyAttribute
attributes are not unused.
Suppressed Diagnostic ID
IDE0051 - Remove unused private members
Examples of code that produces a suppressed diagnostic
using UnityEngine;
using UnityEgine.Scripting;
class Loader
{
[PreserveAttribute]
private void InvokeMe()
{
}
public string Name; // "InvokeMe" serialized
private void Update() {
Invoke(Name, 0);
}
}
Why is the diagnostic reported?
The IDE cannot find any references to the method InvokeMe
and believes it to be unused.
Why do we suppress this diagnostic?
Even though the IDE cannot find any references to InvokeMe
, it will be called by Unity, and should not be removed.