diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs index cbb815091a66a85000092ab7d45a5430b6e00006..ae19fc44bc2070cb38ef3dd958c2d5221560acd4 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryAsyncCheckWriter.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.CompilerServices; @@ -11,13 +12,14 @@ namespace System.Xml { - internal sealed class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter + internal sealed class XmlDictionaryAsyncCheckWriter : XmlDictionaryWriter, IXmlTextWriterInitializer { private readonly XmlDictionaryWriter _coreWriter; private Task? _lastTask; public XmlDictionaryAsyncCheckWriter(XmlDictionaryWriter writer) { + Debug.Assert(writer is IXmlTextWriterInitializer); _coreWriter = writer; } @@ -694,5 +696,14 @@ protected override void Dispose(bool disposing) CheckAsync(); CoreWriter.Dispose(); } + + public void SetOutput(Stream stream, Encoding encoding, bool ownsStream) + { + if (CoreWriter is IXmlTextWriterInitializer initializer) + { + CheckAsync(); + initializer.SetOutput(stream, encoding, ownsStream); + } + } } }