Provide a static constructor when applying the InitializeOnLoad attribute to a class. This will call it when the editor launches.
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
class Camera : MonoBehaviour
{
}Add static constructor:
using UnityEngine;
using UnityEditor;
[InitializeOnLoad]
class Camera : MonoBehaviour
{
static Camera()
{
}
}A code fix is offered for this diagnostic to automatically apply this change.