Feature: Export inner exceptions to dnSpy #114
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rather than just grabbing the outer exception type and message grab it for inner exceptions as well.
This is a step towards #69
The overall strategy was:
It is mainly just for feedback/POC now as this mixes a whole bunch of approaches to see what is preferred.
DbgObject
base class. It didn't look like the data parameter got stuffed anywhere for DbgExceptions so I threw the InnerException data in there using another DbgException object. We could use another class for InnerException data but it seemed logical to tie to another DbgException so we have the additional methods and such available to us. The problem is DbgException inherits from DbgObject which makes sure data added is not classed from DbgObject. Could wrap the DbgException in an outer class (ie DbgInnerException which has a single property DbgException exception) that would bypass that check, but then the Close() function would be tricky. Even if DbgInnerException implemented iDisposable it would not be able to get the DbgDispatcher. Instead I hardcoded an exception into DbgObject for DbgException and took it a step further and made sure when DbgObject Close is called, it is also called on DbgException data. This could be more generalized to allow sub DbgObjects and similarly call Close on them, but I don't really have any core understanding of dnSpy. Why that assert is there, or what evil I may be unlocking. Given the limited InnerException data we could just switch to a new class with two strings and an int (hResult) and not worry about the DbgObject Close or check.Some potential negatives of the current code:
Assuming this is not the completely wrong way to go about this let me know some guidance on how you would like things handled and I will clean it up.
An exception thrown of:
throw new ArgumentNullException("Yes it was", new FileNotFoundException("Where is it Bobbbbbbbbb", "c:\\temp\\test.txt", new Exception("It fell off")));
returns in the main window showing:
I would take it a step further and likely add to the console log and messagebox as well.