You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using (Stream stream = new FileStream("file.txt", FileMode.OpenOrCreate))
{
using (StreamWriter writer = new StreamWriter(stream)) // Noncompliant: 'stream' will be disposed twice
{
// Use the writer object...
}
}
Expected behavior
There should be no diagnostic raised for stream in this case since it is not disposed twice.
Actual behavior
A FP is raised reporting that the stream was disposed twice.
Description
StreamWriter
is closing and not disposing the underling stream. See: https://github.com/microsoft/referencesource/blob/master/mscorlib/system/io/streamwriter.cs#L269Rule description needs to be updated too since it's based on this FP.
Source: #209 (comment)
Repro steps
Expected behavior
There should be no diagnostic raised for
stream
in this case since it is not disposed twice.Actual behavior
A FP is raised reporting that the
stream
was disposed twice.Known workarounds
None.
Related information
The text was updated successfully, but these errors were encountered: