Skip to content

Commit

Permalink
Dispose objects in PayloadWriter.
Browse files Browse the repository at this point in the history
These objects implement IDisposable and trigger (false positive)
analysis warnings about undisposed objects.

PayloadWriter should not be made IDisposable because it could be
rewritten to use ArrayPool (and manage its own memory); clients don't
need to worry about this implementation detail.
  • Loading branch information
bgrainger committed Jun 20, 2017
1 parent d518c8c commit 0cf3f74
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/MySqlConnector/Serialization/PayloadWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Text;

Expand Down Expand Up @@ -53,7 +53,9 @@ public void WriteNullTerminatedString(string value)
public byte[] ToBytes()
{
m_writer.Flush();
return m_stream.ToArray();
using (m_writer)
using (m_stream)
return m_stream.ToArray();
}

readonly MemoryStream m_stream;
Expand Down

0 comments on commit 0cf3f74

Please sign in to comment.