DaZombieKiller / TypeTreeDumper

Experimental tool to export type tree information from the Unity editor.
MIT License
46 stars 11 forks source link

Added struct export support for unity versions 2017.1 to 2020.2 #3

Closed spacehamster closed 4 years ago

spacehamster commented 4 years ago

Adds struct export support for unity versions 2017.1 to 2020.2. Some notes:

DaZombieKiller commented 4 years ago

A simple implementation of UnresolvedSymbolException that I mentioned in my review comments could be:

public sealed class UnresolvedSymbolException : Exception
{
    const string DefaultMessage = "Symbol has not been resolved.";

    public string SymbolName { get; }

    public UnresolvedSymbolException()
        : base(DefaultMessage)
    {
    }

    public UnresolvedSymbolException(string message, Exception inner)
        : base(message, inner)
    {
    }

    public UnresolvedSymbolException(string symbol)
        : base(DefaultMessage)
    {
        SymbolName = symbol;
    }

    public UnresolvedSymbolException(string symbol, string message)
        : base(message)
    {
        SymbolName = symbol;
    }

    public UnresolvedSymbolException(string symbol, string message, Exception inner)
        : base(message, inner)
    {
        SymbolName = symbol;
    }

    public override string Message
    {
        get
        {
            var message = base.Message;

            if (!string.IsNullOrEmpty(message) && !string.IsNullOrEmpty(SymbolName))
                message += $" ({SymbolName})";

            return message;
        }
    }
}
DaZombieKiller commented 4 years ago

This doesn't seem to actually catch exceptions.

 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

I did a bit of reading to try and figure out why this happens, and it turns out that this doesn't work for exceptions thrown in unmanaged threads, so we need to wrap AfterEverythingLoaded's call to Dump in a try/catch and handle any exceptions manually.

DaZombieKiller commented 4 years ago

Looks good, merging now. Thanks for the changes!