Xml serializer test updates prep for reflection work#104173
Merged
StephenMolloy merged 8 commits intodotnet:mainfrom Aug 22, 2024
Merged
Conversation
This was referenced Jun 29, 2024
Open
mconnew
reviewed
Jul 1, 2024
| // Check whether the XName is the same, this can be done by comparing the two XNames. | ||
|
|
||
| if (!baselineXElement.Name.Equals(actualXElement.Name)) | ||
| if ((baselineXElement == null && actualXElement != null) || !baselineXElement.Name.Equals(actualXElement.Name)) |
Member
There was a problem hiding this comment.
Are you trying to protect against nulls being passed in? If so, this can still throw NRE. If you pass in null for both, the first expression of the OR will be false, and then actualXElement.Name will throw NRE.
mconnew
reviewed
Jul 1, 2024
| XNamespace coreclrns = actualXElement.GetNamespaceOfPrefix(coreCLRPrefix); | ||
| if ((deskns == null) || (coreclrns == null)) | ||
| { | ||
| Debug.WriteLine("Either expected {0} or actual {1} attribute value doesn't have namespace :", deskAtrs[i].Value, coreCLRAtrs[i].Value); |
Member
There was a problem hiding this comment.
It's possible that they might both not have a namespace. Is this a scenario we care about differentiating in the debug output?
mconnew
reviewed
Jul 1, 2024
src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.Internal.cs
Outdated
Show resolved
Hide resolved
mconnew
reviewed
Jul 1, 2024
...System.Runtime.Serialization.Schema/tests/System/Runtime/Serialization/Schema/SchemaUtils.cs
Outdated
Show resolved
Hide resolved
mconnew
reviewed
Jul 1, 2024
This was referenced Jul 26, 2024
mconnew
approved these changes
Aug 22, 2024
am11
reviewed
Aug 23, 2024
| var dClass = new XmlSerializableDerivedClass() { AttributeString = "derivedIXmlSerTest", DateTimeValue = DateTime.Parse("Dec 31, 1999"), BoolValue = true }; | ||
|
|
||
| var expectedXml = WithXmlHeader(@$"<BaseIXmlSerializable xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:type=""DerivedIXmlSerializable"" AttributeString=""derivedIXmlSerTest"" DateTimeValue=""12/31/1999 12:00:00 AM"" BoolValue=""True"" xmlns=""{XmlSerializableBaseClass.XmlNamespace}"" />"); | ||
| var fromBase = SerializeAndDeserialize(dClass, expectedXml, () => new XmlSerializer(typeof(XmlSerializableBaseClass), new Type[] { typeof(XmlSerializableDerivedClass) })); |
Member
There was a problem hiding this comment.
This is failing on Alpine Linux:
/root/helix/work/workitem/e /root/helix/work/workitem/e
Discovering: System.Private.Xml.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.Private.Xml.Tests (found 4735 of 4792 test cases)
Starting: System.Private.Xml.Tests (parallel test collections = on [2 threads], stop on fail = off)
XmlSerializerTests.Xml_DerivedIXmlSerializable [FAIL]
XML comparison is also failing
Test failed for input: XmlSerializableDerivedClass
Expected: <?xml version="1.0" encoding="utf-8"?>
<BaseIXmlSerializable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DerivedIXmlSerializable" AttributeString="derivedIXmlSerTest" DateTimeValue="12/31/1999 12:00:00 AM" BoolValue="True" xmlns="http://example.com/serializer-test-namespace" />
Actual: <?xml version="1.0" encoding="utf-8"?>
<BaseIXmlSerializable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="DerivedIXmlSerializable" AttributeString="derivedIXmlSerTest" DateTimeValue="12/31/1999 12:00:00 AM" BoolValue="True" xmlns="http://example.com/serializer-test-namespace" />
Stack Trace:
/_/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs(2336,0): at XmlSerializerTests.SerializeAndDeserialize[T](T value, String baseline, Func`1 serializerFactory, Boolean skipStringCompare, XmlSerializerNamespaces xns)
/_/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.Internal.cs(42,0): at XmlSerializerTests.Xml_DerivedIXmlSerializable()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
/_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(57,0): at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Finished: System.Private.Xml.Tests
In the actual value 12:00:00 AM, it is getting E2 80 AF character before AM, instead of regular space 20.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Shoring up XmlSerializer/Schema tests in preparation for future serializer work.