For some unit tests, I need to be able to read the contents of a
MemoryStream after it has been closed. As this isn't possible, I want to create a memory stream proxy where the call to
Close is a no-op, allowing me to read from it even when code outside of my control has attemped closing it. This however won't work.
(import [System.IO MemoryStream StreamWriter])
(let [stream (proxy [MemoryStream]  (Close  (println "close!")))]
(doto (StreamWriter. stream)
Execution error (InvalidProgramException) at System.Diagnostics.StackFrame/Write (NO_FILE:0).
Cannot create boxed ByRef-like values.
While it's evident my proxied
Close method is called, an error is thrown just after.