How do I get the string value of an XML comment?

Hi,
*
Question:
I’d like to know whether it’s possible to get the string value of the XML comment summary of a class.
*
What I need it for:
I’m working on a custom editor for MonoBehaviour classes.
All it’s supposed to do is create a HelpBox in the Inspector containing the MonoBehaviour’s XML comment summary text. This will hopefully make it easier for me to use and maintain my scripts.
*
Example of what I want to achieve:
I have a MonoBehaviour class named SomeClass with an XML comment:

/// <summary>
/// This class does something.
/// </summary>
public class SomeClass : MonoBehaviour
{
   
}

In the Inspector, I want a HelpBox to appear with the text “This class does something.”, just like in the summary:


*
What I’ve achieved so far:

[CustomEditor(typeof(MonoBehaviour), true)]
public class MonoBehaviourEditor : Editor
{
    public override void OnInspectorGUI()
    {
        string xmlSummary = ???;

        EditorGUILayout.HelpBox(xmlSummary, MessageType.None);

        base.OnInspectorGUI();
    }
}

As you can see by the “???” on line 6, I just need some method to get the XML summary - if there even is a method that does that.
*
Many thanks in advance!

Extracting XML comment from the code should be as simple as reading any XML file. The big issue here is where does the XML file are being stored and how we can access them. I have never done it so I had to explore a bit to see how to do it. Fortunately for us, there is a tutorial on how to do it. [1] There is two major issue I had whenever I tried to do it.

  1. The project settings was not opening. To fix this, I had to set Tool → Option → Tools For Unity → General → Miscellaneous → Access To Project Properties to true [2]
  2. The project was not being build completely (Visual studio was not generating the project) which implies the documentation was not generated. To fix this, I had to set Tool → Option → Tools For Unity → General → Miscellaneous → Disable the full build of projects to false [3]

[1] C# - Accessing XML Documentation via Reflection | Microsoft Learn

[2] Can't open project property in visual studio 2015 with Unity 5.3.2 - Questions & Answers - Unity Discussions

[3] Developer Community