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

Commit 4982068

Browse files
authored
Fix stack overflow exception due to XmlDictionaryReader.Close override (#28408)
It looks like a virtual Close was added to XmlDictionaryReader when XmlReader.Close didn't yet exist in corefx. Then when XmlReader.Close was added, the virtual on the derived type was changed to an override, but that override's behavior doesn't play well with the base's. The fix is just to delete it, matching netfx.
1 parent dadbb55 commit 4982068

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

src/System.Private.DataContractSerialization/src/System/Xml/XmlDictionaryReader.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,11 +1322,6 @@ public virtual int ReadArray(XmlDictionaryString localName, XmlDictionaryString
13221322
return ReadArray(XmlDictionaryString.GetString(localName), XmlDictionaryString.GetString(namespaceUri), array, offset, count);
13231323
}
13241324

1325-
public override void Close()
1326-
{
1327-
base.Dispose();
1328-
}
1329-
13301325
private class XmlWrappedReader : XmlDictionaryReader, IXmlLineInfo
13311326
{
13321327
private XmlReader _reader;

src/System.Runtime.Serialization.Xml/tests/XmlDictionaryReaderTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,40 @@ private static string GenerateDoubleWideTestString(int charsToGenerate, int sing
183183

184184
return sb.ToString();
185185
}
186+
187+
[Fact]
188+
public static void Close_DerivedReader_Success()
189+
{
190+
new NotImplementedXmlDictionaryReader().Close();
191+
}
192+
193+
private sealed class NotImplementedXmlDictionaryReader : XmlDictionaryReader
194+
{
195+
public override ReadState ReadState => ReadState.Initial;
196+
197+
public override int AttributeCount => throw new NotImplementedException();
198+
public override string BaseURI => throw new NotImplementedException();
199+
public override int Depth => throw new NotImplementedException();
200+
public override bool EOF => throw new NotImplementedException();
201+
public override bool IsEmptyElement => throw new NotImplementedException();
202+
public override string LocalName => throw new NotImplementedException();
203+
public override string NamespaceURI => throw new NotImplementedException();
204+
public override XmlNameTable NameTable => throw new NotImplementedException();
205+
public override XmlNodeType NodeType => throw new NotImplementedException();
206+
public override string Prefix => throw new NotImplementedException();
207+
public override string Value => throw new NotImplementedException();
208+
public override string GetAttribute(int i) => throw new NotImplementedException();
209+
public override string GetAttribute(string name) => throw new NotImplementedException();
210+
public override string GetAttribute(string name, string namespaceURI) => throw new NotImplementedException();
211+
public override string LookupNamespace(string prefix) => throw new NotImplementedException();
212+
public override bool MoveToAttribute(string name) => throw new NotImplementedException();
213+
public override bool MoveToAttribute(string name, string ns) => throw new NotImplementedException();
214+
public override bool MoveToElement() => throw new NotImplementedException();
215+
public override bool MoveToFirstAttribute() => throw new NotImplementedException();
216+
public override bool MoveToNextAttribute() => throw new NotImplementedException();
217+
public override bool Read() => throw new NotImplementedException();
218+
public override bool ReadAttributeValue() => throw new NotImplementedException();
219+
public override void ResolveEntity() => throw new NotImplementedException();
220+
}
186221
}
187222
}

0 commit comments

Comments
 (0)