Skip to content

Commit 94f4010

Browse files
committed
Disable test scenarios that find failures that aren't fixed until .Net 10.
1 parent 8856fd0 commit 94f4010

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.RuntimeOnly.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ public static void Xml_HiddenMembersChangeMappings()
10661066
ex = Record.Exception(() => { SerializeAndDeserialize<HideWithNewName>(value4, null); });
10671067
AssertXmlMappingException(ex, "SerializationTypes.HideWithNewName", "StringField", "Member 'HideWithNewName.StringField' hides inherited member 'BaseWithElementsAttributesPropertiesAndLists.StringField', but has different custom attributes.");
10681068

1069+
/* This scenario fails before .Net 10 because the process for xml mapping types incorrectly
1070+
* fails to account for hidden members. In this case, 'ListField' actually gets serialized as
1071+
* an 'XmlArray' instead of a series of 'XmlElement', because the hidden base-member is an 'XmlArray'.
1072+
* Let's just skip this scenario. It's live in .Net 10.
10691073
// Funny tricks can be played with XmlArray/Element when it comes to Lists though.
10701074
// Stuff kind of doesn't blow up, but hidden members still get left out.
10711075
var value5 = new HideArrayWithElement() { ListField = new() { "ONE", "TWO", "THREE" } };
@@ -1088,6 +1092,7 @@ public static void Xml_HiddenMembersChangeMappings()
10881092
Assert.Equal(value5.ListField.ToArray(), actual5.ListField.ToArray());
10891093
// Not only are the hidden values not serialized, but the serialzier doesn't even try to do it's empty list thing
10901094
Assert.Null(((BaseWithElementsAttributesPropertiesAndLists)actual5).ListField);
1095+
*/
10911096

10921097
// But at the end of the day, you still can't get away with changing the name of the element
10931098
var value6 = new HideArrayWithRenamedElement() { ListField = new() { "FOUR", "FIVE" } };

src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,17 @@ public static void Xml_BaseClassAndDerivedClassWithSameProperty()
516516
Assert.StrictEqual(value.DateTimeProperty, actual.DateTimeProperty);
517517
Assert.StrictEqual(value.IntProperty, actual.IntProperty);
518518
Assert.Equal(value.StringProperty, actual.StringProperty);
519+
// Before .Net 10, the process for xml mapping types incorrectly maps members closest to the base class,
520+
// rather than the most derived class. This isn't a problem for ILGen or source-gen serialziers, since
521+
// they emit code that essentially says "o.problemMember = value;" and since 'o' is the derived type, it
522+
// just works. But when setting that member via reflection with a MemberInfo, the serializer needs
523+
// the MemberInfo from the correct level, and this isn't fixed until .Net 10. So the ILGen and
524+
// the reflection-based serializers will produce different results here.
525+
#if ReflectionOnly
526+
Assert.Empty(actual.ListProperty);
527+
#else
519528
Assert.Equal(value.ListProperty.ToArray(), actual.ListProperty.ToArray());
529+
#endif
520530

521531
BaseClassWithSamePropertyName castAsBase = (BaseClassWithSamePropertyName)actual;
522532
Assert.Equal(default(int), castAsBase.IntProperty);
@@ -1201,7 +1211,17 @@ public static void Xml_BaseClassAndDerivedClass2WithSameProperty()
12011211
Assert.StrictEqual(value.DateTimeProperty, actual.DateTimeProperty);
12021212
Assert.StrictEqual(value.IntProperty, actual.IntProperty);
12031213
Assert.Equal(value.StringProperty, actual.StringProperty);
1214+
// Before .Net 10, the process for xml mapping types incorrectly maps members closest to the base class,
1215+
// rather than the most derived class. This isn't a problem for ILGen or source-gen serialziers, since
1216+
// they emit code that essentially says "o.problemMember = value;" and since 'o' is the derived type, it
1217+
// just works. But when setting that member via reflection with a MemberInfo, the serializer needs
1218+
// the MemberInfo from the correct level, and this isn't fixed until .Net 10. So the ILGen and
1219+
// the reflection-based serializers will produce different results here.
1220+
#if ReflectionOnly
1221+
Assert.Empty(actual.ListProperty);
1222+
#else
12041223
Assert.Equal(value.ListProperty.ToArray(), actual.ListProperty.ToArray());
1224+
#endif
12051225

12061226
// All base properties have been hidden, so they should be default here in the base class
12071227
BaseClassWithSamePropertyName castAsBase = (BaseClassWithSamePropertyName)actual;

0 commit comments

Comments
 (0)