Add DebuggerTypeProxy and DebuggerDisplay attributes on assembly level to take control over what is displayed in the debugger, even for types that you don’t own.

using System.Diagnostics;
using System.Xml.Linq;

[assembly: DebuggerDisplay("XML: {this.ToString(SaveOptions.None),nq}", Target=typeof(XDocument))]
[assembly: DebuggerTypeProxy(typeof(ConsoleApp.XElementDebuggerTypeProxy), Target=typeof(XElement))]

namespace ConsoleApp;

class Program
{
    static void Main(string[] args)
    {
        var xml = """
            <person>
                <firstName>Donald</firstName>
                <lastName>Duck</lastName>
            </person>
            """;
            
        var xDoc = XDocument.Parse(xml);
        var element = new XElement("city", new XText("Duckburg"));
        xDoc.Root!.Add(element);

        Console.WriteLine(xDoc);
    }
}

public class XElementDebuggerTypeProxy
{
    private readonly XElement _xElement;
    public string Xml => $"{nameof(XElement)}: {_xElement.ToString(SaveOptions.None)}";
    public XElementDebuggerTypeProxy(XElement xElement) =>
        _xElement = xElement;
}