Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 3d6e00c

Browse files
authored
Fix MatchingRefApiCompat issues in Serialization libraries (#28552)
* Fixes: System.Xml.XmlSerializer/src/MatchingRefApiCompatBaseline.uap.txt * fixes System.Xml.XmlSerializer/src/MatchingRefApiCompatBaseline.uapaot.txt * Fixes: System.Xml.XmlSerializer/src/MatchingRefApiCompatBaseline.netcoreapp.txt * Fixes: System.Runtime.Serialization.Xml/src/MatchingRefApiCompatBaseline.txt * Bring back ReadString() as it is used somewhere else * fix build errors
1 parent 1ad8ed9 commit 3d6e00c

File tree

10 files changed

+17
-85
lines changed

10 files changed

+17
-85
lines changed

src/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DataContractSerializer.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ internal DataContractSerializer(Type type, IEnumerable<Type> knownTypes, int max
9292
Initialize(type, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, null, false);
9393
}
9494

95-
public DataContractSerializer(Type type, XmlDictionaryString rootName, XmlDictionaryString rootNamespace,
96-
IEnumerable<Type> knownTypes,
97-
int maxItemsInObjectGraph,
98-
bool ignoreExtensionDataObject,
99-
bool preserveObjectReferences,
100-
DataContractResolver dataContractResolver)
101-
{
102-
Initialize(type, rootName, rootNamespace, knownTypes, maxItemsInObjectGraph, ignoreExtensionDataObject, preserveObjectReferences, /*dataContractSurrogate,*/ dataContractResolver, false);
103-
}
104-
10595
public DataContractSerializer(Type type, DataContractSerializerSettings settings)
10696
{
10797
if (settings == null)

src/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ private bool WriteMemberText(Member anyText)
693693
{
694694
if (special.TypeDesc.Kind == TypeKind.Node)
695695
{
696-
value = Document.CreateTextNode(ReadString());
696+
value = Document.CreateTextNode(Reader.ReadString());
697697
}
698698
else
699699
{
@@ -706,11 +706,11 @@ private bool WriteMemberText(Member anyText)
706706
{
707707
if (text.Mapping.TypeDesc.CollapseWhitespace)
708708
{
709-
value = CollapseWhitespace(ReadString());
709+
value = CollapseWhitespace(Reader.ReadString());
710710
}
711711
else
712712
{
713-
value = ReadString();
713+
value = Reader.ReadString();
714714
}
715715
}
716716
else
@@ -721,7 +721,7 @@ private bool WriteMemberText(Member anyText)
721721
}
722722
else
723723
{
724-
value = WritePrimitive(text.Mapping, (state) => ((ReflectionXmlSerializationReader)state).ReadString(), this);
724+
value = WritePrimitive(text.Mapping, (state) => ((ReflectionXmlSerializationReader)state).Reader.ReadString(), this);
725725
}
726726
}
727727
}
@@ -1832,7 +1832,7 @@ private bool WriteEnumAndArrayTypes(out object o, StructMapping mapping, XmlQual
18321832
Func<object, string> functor = (state) =>
18331833
{
18341834
var reader = (ReflectionXmlSerializationReader)state;
1835-
return reader.CollapseWhitespace(reader.ReadString());
1835+
return reader.CollapseWhitespace(reader.Reader.ReadString());
18361836
};
18371837
o = WriteEnumMethod(enumMapping, functor, this);
18381838
ReadEndElement();

src/System.Private.Xml/src/System/Xml/Serialization/XmlSchemaImporter.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,6 @@ public class XmlSchemaImporter : SchemaImporter
3737
/// </devdoc>
3838
public XmlSchemaImporter(XmlSchemas schemas, CodeIdentifiers typeIdentifiers) : base(schemas, CodeGenerationOptions.GenerateProperties, new ImportContext(typeIdentifiers, false)) { }
3939

40-
/// <include file='doc\XmlSchemaImporter.uex' path='docs/doc[@for="XmlSchemaImporter.XmlSchemaImporter2"]/*' />
41-
/// <devdoc>
42-
/// <para>[To be supplied.]</para>
43-
/// </devdoc>
44-
public XmlSchemaImporter(XmlSchemas schemas, CodeIdentifiers typeIdentifiers, CodeGenerationOptions options) : base(schemas, options, new ImportContext(typeIdentifiers, false)) { }
45-
46-
/// <include file='doc\XmlSchemaImporter.uex' path='docs/doc[@for="XmlSchemaImporter.XmlSchemaImporter3"]/*' />
47-
/// <devdoc>
48-
/// <para>[To be supplied.]</para>
49-
/// </devdoc>
50-
public XmlSchemaImporter(XmlSchemas schemas, CodeGenerationOptions options, ImportContext context) : base(schemas, options, context) { }
51-
52-
5340
/// <include file='doc\XmlSchemaImporter.uex' path='docs/doc[@for="XmlSchemaImporter.ImportDerivedTypeMapping"]/*' />
5441
/// <devdoc>
5542
/// <para>[To be supplied.]</para>

src/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationReader.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,40 +1428,6 @@ protected Array ShrinkArray(Array a, int length, Type elementType, bool isNullab
14281428
Array.Copy(a, b, length);
14291429
return b;
14301430
}
1431-
// This is copied from Core's XmlReader.ReadString, as it is not exposed in the Contract.
1432-
protected virtual string ReadString()
1433-
{
1434-
if (Reader.ReadState != ReadState.Interactive)
1435-
{
1436-
return string.Empty;
1437-
}
1438-
Reader.MoveToElement();
1439-
if (Reader.NodeType == XmlNodeType.Element)
1440-
{
1441-
if (Reader.IsEmptyElement)
1442-
{
1443-
return string.Empty;
1444-
}
1445-
else if (!Reader.Read())
1446-
{
1447-
throw new InvalidOperationException(SR.Xml_InvalidOperation);
1448-
}
1449-
if (Reader.NodeType == XmlNodeType.EndElement)
1450-
{
1451-
return string.Empty;
1452-
}
1453-
}
1454-
string result = string.Empty;
1455-
while (IsTextualNode(Reader.NodeType))
1456-
{
1457-
result += Reader.Value;
1458-
if (!Reader.Read())
1459-
{
1460-
break;
1461-
}
1462-
}
1463-
return result;
1464-
}
14651431

14661432
// 0x6018
14671433
private static uint s_isTextualNodeBitmap = (1 << (int)XmlNodeType.Text) | (1 << (int)XmlNodeType.CDATA) | (1 << (int)XmlNodeType.Whitespace) | (1 << (int)XmlNodeType.SignificantWhitespace);

src/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ private static XmlSerializer[] GetReflectionBasedSerializers(XmlMapping[] mappin
807807
#if !FEATURE_SERIALIZATION_UAPAOT
808808
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
809809
[ResourceExposure(ResourceScope.None)]
810-
public static bool GenerateSerializer(Type[] types, XmlMapping[] mappings, Stream stream)
810+
internal static bool GenerateSerializer(Type[] types, XmlMapping[] mappings, Stream stream)
811811
{
812812
if (types == null || types.Length == 0)
813813
return false;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
Compat issues with assembly System.Runtime.Serialization.Xml:
2-
MembersMustExist : Member 'System.Runtime.Serialization.DataContractSerializer..ctor(System.Type, System.Xml.XmlDictionaryString, System.Xml.XmlDictionaryString, System.Collections.Generic.IEnumerable<System.Type>, System.Int32, System.Boolean, System.Boolean, System.Runtime.Serialization.DataContractResolver)' does not exist in the implementation but it does exist in the contract.
3-
Total Issues: 1
2+

src/System.Xml.XmlSerializer/ref/System.Xml.XmlSerializer.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,8 @@ public void ExportMembersMapping(System.Xml.Serialization.XmlMembersMapping xmlM
382382
public System.Xml.XmlQualifiedName ExportTypeMapping(System.Xml.Serialization.XmlMembersMapping xmlMembersMapping) { throw null; }
383383
public void ExportTypeMapping(System.Xml.Serialization.XmlTypeMapping xmlTypeMapping) { }
384384
}
385-
public partial class XmlSchemaImporter
386-
//CodeDOM : System.Xml.Serialization.SchemaImporter
385+
public partial class XmlSchemaImporter : SchemaImporter
386+
//CodeDOM : System.Xml.Serialization.SchemaImporter
387387
{
388388
public XmlSchemaImporter(System.Xml.Serialization.XmlSchemas schemas) { }
389389
//CODEDOM public XmlSchemaImporter(System.Xml.Serialization.XmlSchemas schemas, System.Xml.Serialization.CodeGenerationOptions options, System.CodeDom.Compiler.CodeDomProvider codeProvider, System.Xml.Serialization.ImportContext context) { }
@@ -402,6 +402,10 @@ public XmlSchemaImporter(System.Xml.Serialization.XmlSchemas schemas, System.Xml
402402
public System.Xml.Serialization.XmlTypeMapping ImportSchemaType(System.Xml.XmlQualifiedName typeName, System.Type baseType, bool baseTypeCanBeIndirect) { throw null; }
403403
public System.Xml.Serialization.XmlTypeMapping ImportTypeMapping(System.Xml.XmlQualifiedName name) { throw null; }
404404
}
405+
public abstract class SchemaImporter
406+
{
407+
internal SchemaImporter() { }
408+
}
405409
public partial class XmlSchemas : System.Collections.CollectionBase, System.Collections.Generic.IEnumerable<System.Xml.Schema.XmlSchema>, System.Collections.IEnumerable
406410
{
407411
public XmlSchemas() { }
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
11
Compat issues with assembly System.Xml.XmlSerializer:
2-
CannotRemoveBaseTypeOrInterface : Type 'System.Xml.Serialization.XmlSchemaImporter' does not inherit from base type 'System.Xml.Serialization.SchemaImporter' in the implementation but it does in the contract.
3-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeGenerationOptions, System.Xml.Serialization.ImportContext)' does not exist in the implementation but it does exist in the contract.
4-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeIdentifiers, System.Xml.Serialization.CodeGenerationOptions)' does not exist in the implementation but it does exist in the contract.
5-
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializationReader.ReadString()' does not exist in the implementation but it does exist in the contract.
6-
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializer.GenerateSerializer(System.Type[], System.Xml.Serialization.XmlMapping[], System.IO.Stream)' does not exist in the implementation but it does exist in the contract.
7-
Total Issues: 5
2+
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
Compat issues with assembly System.Xml.XmlSerializer:
2-
CannotRemoveBaseTypeOrInterface : Type 'System.Xml.Serialization.XmlSchemaImporter' does not inherit from base type 'System.Xml.Serialization.SchemaImporter' in the implementation but it does in the contract.
3-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeGenerationOptions, System.Xml.Serialization.ImportContext)' does not exist in the implementation but it does exist in the contract.
4-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeIdentifiers, System.Xml.Serialization.CodeGenerationOptions)' does not exist in the implementation but it does exist in the contract.
5-
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializationReader.ReadString()' does not exist in the implementation but it does exist in the contract.
6-
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializer.GenerateSerializer(System.Type[], System.Xml.Serialization.XmlMapping[], System.IO.Stream)' does not exist in the implementation but it does exist in the contract.
7-
Total Issues: 5
1+
Compat issues with assembly System.Xml.XmlSerializer:
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
Compat issues with assembly System.Xml.XmlSerializer:
2-
CannotRemoveBaseTypeOrInterface : Type 'System.Xml.Serialization.XmlSchemaImporter' does not inherit from base type 'System.Xml.Serialization.SchemaImporter' in the implementation but it does in the contract.
3-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeGenerationOptions, System.Xml.Serialization.ImportContext)' does not exist in the implementation but it does exist in the contract.
4-
MembersMustExist : Member 'System.Xml.Serialization.XmlSchemaImporter..ctor(System.Xml.Serialization.XmlSchemas, System.Xml.Serialization.CodeIdentifiers, System.Xml.Serialization.CodeGenerationOptions)' does not exist in the implementation but it does exist in the contract.
5-
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializationReader.ReadString()' does not exist in the implementation but it does exist in the contract.
2+
# Used by uap tooling for serializer generation
63
MembersMustExist : Member 'System.String System.Xml.Serialization.XmlSerializer.DefaultNamespace' does not exist in the implementation but it does exist in the contract.
74
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializer.Mode.get()' does not exist in the implementation but it does exist in the contract.
85
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializer.Mode.set(System.Xml.Serialization.SerializationMode)' does not exist in the implementation but it does exist in the contract.
96
MembersMustExist : Member 'System.Xml.Serialization.XmlSerializer.SetXmlSerializerContract(System.Xml.Serialization.XmlSerializerImplementation)' does not exist in the implementation but it does exist in the contract.
10-
Total Issues: 8
7+

0 commit comments

Comments
 (0)