Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the test coverage of XmlWriter. #107680

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/libraries/Common/tests/System/Xml/XmlCoreTest/AsyncUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.XPath;
using OLEDB.Test.ModuleCore;

/// <summary>
Expand Down Expand Up @@ -1509,6 +1510,30 @@ public override Task WriteNodeAsync(XmlReader reader, bool defattr)
return CoreWriter.WriteNodeAsync(reader, defattr);
}

public override void WriteNode(XPathNavigator navigator, bool defattr)
{
if (AsyncUtil.RedirectWriter)
{
try
{
CoreWriter.WriteNodeAsync(navigator, defattr).Wait();
}
catch (AggregateException ae)
{
throw ae.InnerException;
}
}
else
{
CoreWriter.WriteNode(navigator, defattr);
}
}

public override Task WriteNodeAsync(XPathNavigator navigator, bool defattr)
{
return CoreWriter.WriteNodeAsync(navigator, defattr);
}

public override void WriteProcessingInstruction(string name, string text)
{
if (AsyncUtil.RedirectWriter)
Expand Down Expand Up @@ -1746,6 +1771,35 @@ public override Task WriteWhitespaceAsync(string ws)
return CoreWriter.WriteWhitespaceAsync(ws);
}

protected override void Dispose(bool disposing)
{
if (!disposing)
{
return;
}

if (AsyncUtil.RedirectWriter)
{
try
{
CoreWriter.DisposeAsync().AsTask().Wait();
}
catch (AggregateException ae)
{
throw ae.InnerException;
}
}
else
{
CoreWriter.Dispose();
}
}

protected override ValueTask DisposeAsyncCore()
{
return CoreWriter.DisposeAsync();
}

/// <summary>
/// ////////////////////////////////
/// </summary>
Expand Down Expand Up @@ -1788,9 +1842,9 @@ public override string XmlLang
}
}

public new void Dispose()
public override void Close()
{
CoreWriter.Dispose();
CoreWriter.Close();
}

public new void WriteStartElement(string localName, string ns)
Expand Down Expand Up @@ -1882,6 +1936,7 @@ public override void WriteValue(long value)
{
CoreWriter.WriteElementString(localName, ns, value);
}

#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ XmlWriter CreateWriterImpl()
FilePathUtil.addStream(_fileName, _writerStream);
XmlWriterSettings ws = _wSettings.Clone();
ws.CheckCharacters = true;
_xmlWriter = WriterHelper.Create(ww, ws, _overrideAsync, _async);
_xmlWriter = WriterHelper.Create(ww, ws, true);
break;
case WriterType.WrappedWriter:
_writerStream = new MemoryStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<Compile Include="Writers\XmlWriterApi\TCWriteAttributes.cs" />
<Compile Include="Writers\XmlWriterApi\TCWriteBuffer.cs" />
<Compile Include="Writers\XmlWriterApi\TCWriteNode_XmlReader.cs" />
<Compile Include="Writers\XmlWriterApi\TCWriteNode_XPathNavigator.cs" />
<Compile Include="Writers\XmlWriterApi\TCWriterSettingsMisc.cs" />
<Compile Include="Writers\XmlWriterApi\TCWriterWithMemoryStream.cs" />
<Compile Include="Writers\XmlWriterApi\TestExtensions.cs" />
Expand Down
Loading
Loading