There are a couple of things that bother me about the current treatment of files in CCI.
OpenBinaryDocument in MetadataReaderHost uses MemoryMappedFile to map a file on disk into memory. The first problem with this is that the subsequent unmapping only occurs on finalisation, which is nondeterministic. Something, somewhere, should
implement IDisposable and let you say "I'm done with this file/assembly, close it down now".
Which brings me to my second issue. The standard implementation doesn't support reading an assembly that's already in memory (eg. in a MemoryStream). It's probably a less common case, and it looks like it's doable by overriding OpenBinaryDocument
completely, but it'd be nice if there was something standard for it.
If UnmanagedBinaryMemoryBlock supported being given an arbitrary stream instead of a filename, and if it implemented IDisposable, then that'd go a long way.
(This came about because I am trying to read assemblies that are packed into a zip file, so they need to be extracted in memory before they can be worked with. I tried extracting to a temporary folder, which worked well right up until the point where
I wanted to delete the folder at the end, and CCI still had the files open. I'd prefer not having to write the files to disk at all.)
I think I'll try implementing my own version of OpenBinaryDocument now. Hopefully that will get past this problem.
On a completely unrelated note: any chance one of the two PeToPe projects (sample app and test case) could be renamed? VSX gets grumpy trying to load a solution containing two projects with the same name.