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

Dispose XmlReader in SchemaExporter when done #103286

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

omajid
Copy link
Member

@omajid omajid commented Jun 11, 2024

No description provided.

@omajid omajid force-pushed the schema-exporter-xmlreader-dispose branch from 0f50c2c to d9bb905 Compare June 12, 2024 21:45
@@ -352,7 +352,8 @@ private XmlElement ExportGenericInfo(Type clrType, string elementName, string el
ignoreExtensionDataObject: false, preserveObjectReferences: true);
serializer.WriteObject(xmlWriter, surrogateData);
xmlWriter.Flush();
return (XmlElement?)XmlDoc.ReadNode(XmlReader.Create(new StringReader(stringWriter.ToString())));
using var xmlReader = XmlReader.Create(new StringReader(stringWriter.ToString()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this usage of XmlReader.Create(Stream input) will not dispose the underlying stream.

StringReader doesn't do a whole lot on dispose aside from reset position and null the underlying array...

Might still be worth it however?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, there's no functional benefit to this change; there are no resources here to Dispose.

@stephentoub stephentoub merged commit 56600b7 into dotnet:main Jul 9, 2024
81 of 83 checks passed
matouskozak added a commit to matouskozak/runtime that referenced this pull request Jul 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Serialization community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants