fix: degrade malformed legacy XML Session Files instead of throwing - #684
Merged
Conversation
A legacy XML .lxp whose <file> element has no <options> child threw NullReferenceException out of PersisterXML.ReadOptions. Persister.Load calls the XML reader from inside its JSON catch block, so the NRE replaced the original exception and propagated up the synchronous file-open path, where nothing handles it. ReadOptions now skips the options section when it is absent, leaving those settings at their PersistenceData defaults. The tab, columnizer and highlightGroup elements are siblings of <options>, not children, so they moved out of the guarded region and are still read — an early return would have cost the user their columnizer for a file that merely lacks options. The body that does need the node moved to ReadOptionsNode. ReadPersistenceDataFromNode now honours its own documented contract and returns defaults for a node that is not an element, which is what a comment among the filterTab children produces. PersisterXML.Load is documented to return null on unparseable input, but only caught malformed markup. This is a read-only fallback for a format LogExpert no longer writes, and its readers assume a well-formed document, so the catch now also covers the exceptions malformed *content* raises: FormatException, OverflowException, ArgumentException and NullReferenceException. Each is pinned by a test case. Closes #680
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A legacy XML .lxp whose element has no child threw NullReferenceException out of PersisterXML.ReadOptions. Persister.Load calls the XML reader from inside its JSON catch block, so the NRE replaced the original exception and propagated up the synchronous file-open path, where nothing handles it.
ReadOptions now skips the options section when it is absent, leaving those settings at their PersistenceData defaults. The tab, columnizer and highlightGroup elements are siblings of , not children, so they moved out of the guarded region and are still read — an early return would have cost the user their columnizer for a file that merely lacks options. The body that does need the node moved to ReadOptionsNode.
ReadPersistenceDataFromNode now honours its own documented contract and returns defaults for a node that is not an element, which is what a comment among the filterTab children produces.
PersisterXML.Load is documented to return null on unparseable input, but only caught malformed markup. This is a read-only fallback for a format LogExpert no longer writes, and its readers assume a well-formed document, so the catch now also covers the exceptions malformed content raises: FormatException, OverflowException, ArgumentException and NullReferenceException. Each is pinned by a test case.
Closes #680