Don't close my stream!
When I upgraded to the newest version, I see that the Flush method of the BaseWriter is marked as obsolete. I wondered why I was calling flush explicitly instead of wrapping my writer in a using statement and letting .NET dispose it. Then I saw that I'm explicitly calling Flush because I don't want the underlying stream to be closed on me.
If I were instantiating a StreamWriter myself I would get around this by specifying that I want the base stream to remain open in the StreamWriter's constructor. But it looks like you guys don't have a constructor overload that allows me to pass in a StreamWriter. I assume you guys are constructing a StreamWriter under the covers inside the BaseWriter since your constructor lets us pass in a Stream and an encoding.
Could you add a constructor to the implementations of your writer that either takes in a StreamWriter or else at least lets me specify whether or not I want the stream closed on dispose? In the meantime, I'll just have to live with the little green "obsolete" squiggle... :)
Which EF Framework version are you using and what .NET version ? When Flush was retired a few versions ago, the writer stream is never closed. You can see here, in the following example:
is executed after the writer was disposed and the stream is still open.
I'm running on .NET 4.6.2 using (as of today) EF 9.7.7. But before today we were using EF 7.3.1. So maybe that's why we had that Flush there. If you don't close the stream for me, that's perfect. Thanks!
Please sign in to leave a comment.