Repository navigation
Report nested elements in C# XML text - #844
Merged
Merged
Conversation
The C# de-serialization threw an ``InvalidOperationException`` instead
of reporting an error when the content of a primitive started with
an element, *e.g.*, ``<someString><nested/></someString>``.
``XmlReader.ReadContentAs*`` throws it at an element node, and our
``catch`` filters did not cover it. We now check for an element before
the conversion in ``AsText``, which all the primitives go through:
if (reader.NodeType == Xml.XmlNodeType.Element)
{
error = new Reporting.Error(
$"Expected an XML content representing {typeof(T).Name}, " +
$"but got a nested element {reader.Name}");
return default!;
}
The XML-RPC readers of ``<boolean>``, ``<double>`` and ``<string>`` had
the same bug, and get the same check. Moreover, the key of a struct
member was coalesced with ``?? throw`` before the error was checked, so
any error in a ``<name>`` surfaced as an ``InvalidOperationException``.
We now check the error first.
We add the live test data ``some_string_as_nested_element.xml`` for
all the targets, and a C# XML-RPC test with a nested element in
``<boolean>``, ``<double>``, ``<string>`` and ``<name>``.
Coverage Report for CI Build 38185248312Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage remained the same at 90.141%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
The C# de-serialization threw an
InvalidOperationExceptioninstead of reporting an error when the content of a primitive started with an element, e.g.,<someString><nested/></someString>.XmlReader.ReadContentAs*throws it at an element node, and ourcatchfilters did not cover it. We now check for an element before the conversion inAsText, which all the primitives go through:The XML-RPC readers of
<boolean>,<double>and<string>had the same bug, and get the same check. Moreover, the key of a struct member was coalesced with?? throwbefore the error was checked, so any error in a<name>surfaced as anInvalidOperationException. We now check the error first.We add the live test data
some_string_as_nested_element.xmlfor all the targets, and a C# XML-RPC test with a nested element in<boolean>,<double>,<string>and<name>.