From 79037eb65dd55bdbaabd54db6c70acbaa1212072 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 16 Mar 2021 14:45:48 +0100 Subject: [PATCH] Big-endian test case fixes: XML (#49689) * Update expected results for endian-dependent tests BinHex_9/BinHex_10 * Input strings for XML encode/decode tests are hard-coded little-endian --- .../Writers/XmlWriterApi/TCFullEndElement.cs | 18 ++++++++++++++++-- .../tests/XmlConvert/EncodeDecodeTests.cs | 4 +++- .../XmlConvert/XmlBaseCharConvertTests1.cs | 4 +++- .../XmlConvert/XmlBaseCharConvertTests2.cs | 4 +++- .../XmlConvert/XmlBaseCharConvertTests3.cs | 4 +++- .../XmlCombiningCharConvertTests1.cs | 4 +++- .../XmlCombiningCharConvertTests2.cs | 4 +++- .../XmlCombiningCharConvertTests3.cs | 4 +++- .../XmlConvert/XmlDigitCharConvertTests1.cs | 4 +++- .../XmlConvert/XmlDigitCharConvertTests2.cs | 4 +++- .../XmlConvert/XmlDigitCharConvertTests3.cs | 4 +++- .../XmlEmbeddedNullCharConvertTests1.cs | 4 +++- .../XmlEmbeddedNullCharConvertTests2.cs | 4 +++- .../XmlEmbeddedNullCharConvertTests3.cs | 4 +++- .../XmlIdeographicCharConvertTests1.cs | 4 +++- .../XmlIdeographicCharConvertTests2.cs | 4 +++- .../XmlIdeographicCharConvertTests3.cs | 4 +++- 17 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/TCFullEndElement.cs b/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/TCFullEndElement.cs index 2f60bbf13cf01..0e2e261ea494d 100644 --- a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/TCFullEndElement.cs +++ b/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/TCFullEndElement.cs @@ -5755,7 +5755,14 @@ public void BinHex_9(XmlWriterUtils utils) w.WriteBinHex(Wbase64, 0, (int)Wbase64len); w.WriteEndElement(); } - Assert.True(utils.CompareReader("")); + if (System.BitConverter.IsLittleEndian) + { + Assert.True(utils.CompareReader("")); + } + else + { + Assert.True(utils.CompareReader("")); + } } // Call WriteBinHex and verify results can be read as a string @@ -5777,7 +5784,14 @@ public void BinHex_10(XmlWriterUtils utils) w.WriteBinHex(Wbase64, 0, (int)Wbase64len); w.WriteEndElement(); } - Assert.True(utils.CompareReader("610062006300")); + if (System.BitConverter.IsLittleEndian) + { + Assert.True(utils.CompareReader("610062006300")); + } + else + { + Assert.True(utils.CompareReader("006100620063")); + } } } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/EncodeDecodeTests.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/EncodeDecodeTests.cs index ba7f39278e66e..deb5fa7edd8d1 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/EncodeDecodeTests.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/EncodeDecodeTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -47,7 +48,8 @@ public int v3() string strUni = string.Empty; for (int i = 0; i < _dbyte.Length; i = i + 2) { - strUni += (BitConverter.ToChar(_dbyte, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_dbyte, i, 2)); + strUni += c.ToString(); } CError.WriteLine(strUni + " " + XmlConvert.EncodeName(strUni)); CError.Compare(XmlConvert.EncodeName(strUni), "_xFF71_", "EncodeName"); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests1.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests1.cs index 64180821d65dc..f6ed436805d9e 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests1.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests1.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName4() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_BaseChar, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_BaseChar, i, 2)); + strEnVal = XmlConvert.EncodeName(c.ToString()); CError.Compare(strEnVal, _Expbyte_BaseChar[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests2.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests2.cs index 2d7ca1783f6c7..01fa29d3b09b9 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests2.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName5() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_BaseChar, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_BaseChar, i, 2)); + strEnVal = XmlConvert.EncodeNmToken(c.ToString()); if (_Expbyte_BaseChar[i / 2] != "_x0387_" && _Expbyte_BaseChar[i / 2] != "_x0640_" && _Expbyte_BaseChar[i / 2] != "_x064B_" && _Expbyte_BaseChar[i / 2] != "_x0670_" && _Expbyte_BaseChar[i / 2] != "_x06D6_" && _Expbyte_BaseChar[i / 2] != "_x06E4_" && _Expbyte_BaseChar[i / 2] != "_x06E7_" && _Expbyte_BaseChar[i / 2] != "_x093C_" && _Expbyte_BaseChar[i / 2] != "_x093E_" && _Expbyte_BaseChar[i / 2] != "_x0962_" && _Expbyte_BaseChar[i / 2] != "_x09E2_" && _Expbyte_BaseChar[i / 2] != "_x09EF_" && _Expbyte_BaseChar[i / 2] != "_x0A71_" && _Expbyte_BaseChar[i / 2] != "_x0ABC_" && _Expbyte_BaseChar[i / 2] != "_x0ABE_" && _Expbyte_BaseChar[i / 2] != "_x0B3C_" && _Expbyte_BaseChar[i / 2] != "_x0B3E_" && _Expbyte_BaseChar[i / 2] != "_x0E31_" && _Expbyte_BaseChar[i / 2] != "_x0E34_" && _Expbyte_BaseChar[i / 2] != "_x0E46_" && _Expbyte_BaseChar[i / 2] != "_x0EB1_" && _Expbyte_BaseChar[i / 2] != "_x0EB4_" && _Expbyte_BaseChar[i / 2] != "_x0EBC_" && _Expbyte_BaseChar[i / 2] != "_x0F3F_") { diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests3.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests3.cs index a5492547492a1..33400fba8b67a 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests3.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlBaseCharConvertTests3.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -28,7 +29,8 @@ public int XmlEncodeName6() string strDeVal = string.Empty; string strVal = string.Empty; - strVal = (BitConverter.ToChar(_byte_BaseChar, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_BaseChar, i, 2)); + strVal = c.ToString(); strEnVal = XmlConvert.EncodeName(strVal); CError.Compare(strEnVal, _Expbyte_BaseChar[i / 2], "Encode Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests1.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests1.cs index 9f7a72896e9a8..668791afd5ddb 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests1.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests1.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName1() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_CombiningChar, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_CombiningChar, i, 2)); + strEnVal = XmlConvert.EncodeName(c.ToString()); CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests2.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests2.cs index 614e4e555550e..4eed8aa1a4bf3 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests2.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName2() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_CombiningChar, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_CombiningChar, i, 2)); + strEnVal = XmlConvert.EncodeNmToken(c.ToString()); if (_Expbyte_CombiningChar[i / 2] != "_x0A6F_" && _Expbyte_CombiningChar[i / 2] != "_x0E46_") { CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests3.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests3.cs index 3567d3fc0170f..93c96521d90b8 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests3.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlCombiningCharConvertTests3.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -28,7 +29,8 @@ public int XmlEncodeName3() string strEnVal = string.Empty; string strVal = string.Empty; - strVal = (BitConverter.ToChar(_byte_CombiningChar, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_CombiningChar, i, 2)); + strVal = c.ToString(); strEnVal = XmlConvert.EncodeName(strVal); CError.Compare(strEnVal, _Expbyte_CombiningChar[i / 2], "Encode Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests1.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests1.cs index dfe456c438ef1..825c923f3d4ae 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests1.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests1.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName1() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_Digit, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Digit, i, 2)); + strEnVal = XmlConvert.EncodeName(c.ToString()); CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests2.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests2.cs index 9a5c3dfead0f9..01784cb330cdf 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests2.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName2() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_Digit, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Digit, i, 2)); + strEnVal = XmlConvert.EncodeNmToken(c.ToString()); if (_Expbyte_Digit[i / 2] != "_x0A70_") { CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests3.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests3.cs index 3be2e9359af28..b9eeda41232f0 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests3.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlDigitCharConvertTests3.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -28,7 +29,8 @@ public int XmlEncodeName3() string strEnVal = string.Empty; string strVal = string.Empty; - strVal = (BitConverter.ToChar(_byte_Digit, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Digit, i, 2)); + strVal = c.ToString(); strEnVal = XmlConvert.EncodeName(strVal); CError.Compare(strEnVal, _Expbyte_Digit[i / 2], "Encode Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests1.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests1.cs index 9d3219207e96d..21ca58a0cf6b6 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests1.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests1.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName1() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_EmbeddedNull, i, 2)); + strEnVal = XmlConvert.EncodeName(c.ToString()); CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests2.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests2.cs index ffd428e4f051b..c5e15bd7bcc6c 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests2.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName2() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_EmbeddedNull, i, 2)); + strEnVal = XmlConvert.EncodeNmToken(c.ToString()); CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests3.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests3.cs index 9f078c086a624..cead014f7c823 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests3.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlEmbeddedNullCharConvertTests3.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -28,7 +29,8 @@ public int XmlEncodeName3() string strEnVal = string.Empty; string strVal = string.Empty; - strVal = (BitConverter.ToChar(_byte_EmbeddedNull, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_EmbeddedNull, i, 2)); + strVal = c.ToString(); strEnVal = XmlConvert.EncodeName(strVal); CError.Compare(strEnVal, _Expbyte_EmbeddedNull[i / 2], "Encode Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests1.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests1.cs index 2ce9b6ace1cef..c33333f6ffe13 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests1.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests1.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeName((BitConverter.ToChar(_byte_Ideographic, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Ideographic, i, 2)); + strEnVal = XmlConvert.EncodeName(c.ToString()); CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Comparison failed at " + i); return TEST_PASS; } diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests2.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests2.cs index ee1be130945af..54aa5c7f5c851 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests2.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests2.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -26,7 +27,8 @@ public int XmlEncodeName() int i = ((CurVariation.id) - 1) * 2; string strEnVal = string.Empty; - strEnVal = XmlConvert.EncodeNmToken((BitConverter.ToChar(_byte_Ideographic, i)).ToString()); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Ideographic, i, 2)); + strEnVal = XmlConvert.EncodeNmToken(c.ToString()); if (_Expbyte_Ideographic[i / 2] != "_x302A_") { CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Comparison failed at " + i); diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests3.cs b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests3.cs index 101ed2ad39e1c..f57c2bc80a73b 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests3.cs +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/XmlIdeographicCharConvertTests3.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using OLEDB.Test.ModuleCore; +using System.Buffers.Binary; namespace System.Xml.Tests { @@ -28,7 +29,8 @@ public int XmlEncodeName() string strEnVal = string.Empty; string strVal = string.Empty; - strVal = (BitConverter.ToChar(_byte_Ideographic, i)).ToString(); + char c = (char)BinaryPrimitives.ReadUInt16LittleEndian(new Span(_byte_Ideographic, i, 2)); + strVal = c.ToString(); strEnVal = XmlConvert.EncodeName(strVal); CError.Compare(strEnVal, _Expbyte_Ideographic[i / 2], "Encode Comparison failed at " + i);