Skip to content

Commit

Permalink
implement for netfx and enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Sep 29, 2021
1 parent a155490 commit 80d9dc8
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Xml;
using Microsoft.Data.SqlTypes;

namespace Microsoft.Data.SqlClient
{
Expand Down Expand Up @@ -134,26 +135,7 @@ internal SqlXml ToSqlXml()
[MethodImpl(MethodImplOptions.NoInlining)]
internal XmlReader ToXmlReader()
{
//XmlTextReader xr = new XmlTextReader(fragment, XmlNodeType.Element, null);
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ConformanceLevel = ConformanceLevel.Fragment;

// Call internal XmlReader.CreateSqlReader from System.Xml.
// Signature: internal static XmlReader CreateSqlReader(Stream input, XmlReaderSettings settings, XmlParserContext inputContext);
MethodInfo createSqlReaderMethodInfo = typeof(System.Xml.XmlReader).GetMethod("CreateSqlReader", BindingFlags.Static | BindingFlags.NonPublic);
object[] args = new object[3] { ToStream(), readerSettings, null };
XmlReader xr;

new System.Security.Permissions.ReflectionPermission(System.Security.Permissions.ReflectionPermissionFlag.MemberAccess).Assert();
try
{
xr = (XmlReader)createSqlReaderMethodInfo.Invoke(null, args);
}
finally
{
System.Security.Permissions.ReflectionPermission.RevertAssert();
}
return xr;
return SqlTypeWorkarounds.SqlXmlCreateSqlXmlReader(ToStream(), closeInput: false, async: false);
}

public bool IsNull
Expand Down
Loading

0 comments on commit 80d9dc8

Please sign in to comment.