How can I get gameObject's all script components?

Is there a way to get a gameObject’s all script components?
For example, a gameObject is “Player”, it has two script attached as components: “PlayerControl.cs” and “PlayerStatus.cs”.
How can I traverse all gameObject’s script components? (different gameobjct has various script components…)
I just want to traverse all gameObject’s script components and then do a null reference check to make sure the game won’t throw null reference exception…
thanks in advance.

To find all (public) Object-derived fields and check/report if they are null:

void Awake()
{
    #if UNITY_EDITOR
    foreach (FieldInfo fieldInfo in GetType().GetFields())
        if (fieldInfo.FieldType.IsSubclassOf(typeof(Object)))
            if ((Object)fieldInfo.GetValue(this) == null)
                Debug.LogError("Field " + fieldInfo.FieldType.Name + " " + fieldInfo.Name + " is null!");
    #endif
}

Note: This won’t work at runtime on iOS and probably some other platforms.


Get all components (technically, scripts):

gameObject.GetComponents<MonoBehaviour>();

Iterate with something like:

foreach (MonoBehaviour script in gameObject.GetComponents<MonoBehaviour>())
{
    // ...
}

But they won’t ever be null though, because they are attached properly. Perhaps this is not what your are asking? Any script that fails to reference another script would still throw NullRefExc-s.

If you are just looking for missing scripts:

if (gameObject.GetComponent<RequiredScript>() == null)
    Debug.LogError("Missing RequiredScript!");

There are fancier (more optimized) ways to do this, but if you only do it once, it probably won’t matter.

Edit: update per comment