/// <summary> /// Opens a binary document. /// </summary> public override IBinaryDocumentMemoryBlock OpenBinaryDocument(IBinaryDocument sourceDocument) { try { IBinaryDocumentMemoryBlock binDocMemoryBlock = UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(sourceDocument.Location, sourceDocument); return(binDocMemoryBlock); } catch (IOException) { return(null); } }
/// <summary> /// override this here to not use memory mapped files since we want to use asmmeta in msbuild and it is sticky /// </summary> public override IBinaryDocumentMemoryBlock /*?*/ OpenBinaryDocument(IBinaryDocument sourceDocument) { try { IBinaryDocumentMemoryBlock binDocMemoryBlock = UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(sourceDocument.Location, sourceDocument); this.disposableObjectAllocatedByThisHost.Add((IDisposable)binDocMemoryBlock); return(binDocMemoryBlock); } catch (IOException) { return(null); } }
public override IBinaryDocumentMemoryBlock OpenBinaryDocument(IBinaryDocument sourceDocument) { VSServiceProvider.Current.Logger.WriteToLog("Opening document: " + sourceDocument.Name + " from: " + sourceDocument.Location); try { IBinaryDocumentMemoryBlock binDocMemoryBlock = UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(sourceDocument.Location, sourceDocument); return(binDocMemoryBlock); } catch (IOException) { VSServiceProvider.Current.Logger.WriteToLog("Failed to open document."); return(null); } }
public override IBinaryDocumentMemoryBlock /*?*/ OpenBinaryDocument(IBinaryDocument parentSourceDocument, string childDocumentName) { try { string directory = Path.GetDirectoryName(parentSourceDocument.Location); string fullPath = Path.Combine(directory, childDocumentName); IBinaryDocument newBinaryDocument = BinaryDocument.GetBinaryDocumentForFile(fullPath, this); var block = UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(newBinaryDocument.Location, newBinaryDocument); this.disposableObjectAllocatedByThisHost.Add((IDisposable)block); return(block); } catch (IOException) { return(null); } }
// Overriding this method allows us to read the binaries without blocking the files. The default // implementation will use a memory mapped file (MMF) which causes the files to be locked. That // means you can delete them, but you can't overwrite them in-palce, which is especially painful // when reading binaries directly from a build ouput folder. // // Measuring indicated that performance implications are negligible. That's why we decided to // make this the default and not exposing any (more) options to our ctor. public override IBinaryDocumentMemoryBlock OpenBinaryDocument(IBinaryDocument sourceDocument) { // First let's see whether the document is a stream-based document. In that case, we'll // call the overload that processes the stream. var streamDocument = sourceDocument as StreamDocument; if (streamDocument != null) { return(UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(streamDocument.Stream, sourceDocument)); } // Otherwise we assume that we can load the data from the location of sourceDocument. try { var memoryBlock = UnmanagedBinaryMemoryBlock.CreateUnmanagedBinaryMemoryBlock(sourceDocument.Location, sourceDocument); disposableObjectAllocatedByThisHost.Add(memoryBlock); return(memoryBlock); } catch (IOException) { return(null); } }