public PdbWriter(string fileName, Stream stream, Func <object> symWriterFactory = null) { this.stream = new ComStreamWrapper(stream); this.fileName = fileName; this.symWriterFactory = symWriterFactory; CreateSequencePointBuffers(capacity: 64); }
internal static bool GetStream(IntPtr pidl, out Stream stream) { lock (getStreamSyncObject) { stream = null; if (pidl == IntPtr.Zero) { return(false); } IStream piStream = null; if (HasSuchAttributes(pidl, NativeMethods.SFGAO_STREAM)) { NativeMethods.IShellFolder desktopFolder = null; if (NativeMethods.SHGetDesktopFolder(out desktopFolder) != 0) { return(false); } Guid guid = new Guid("0000000c-0000-0000-C000-000000000046"); IntPtr ppv = IntPtr.Zero; uint res = desktopFolder.BindToObject(pidl, IntPtr.Zero, ref guid, out ppv); Marshal.ReleaseComObject(desktopFolder); if (res != 0) { return(false); } object objUnk = Marshal.GetObjectForIUnknown(ppv); Marshal.Release(ppv); if (objUnk == null) { return(false); } piStream = objUnk as IStream; if (piStream == null) { return(false); } } if (piStream == null) { return(false); } ComStreamWrapper comStreamWrapper = new ComStreamWrapper(piStream); comStreamWrapper.Seek(0, System.IO.SeekOrigin.Begin); stream = (Stream)comStreamWrapper; return(true); } }
public int WriteUserOptions([In] IStream pOptionsStream, [In] string pszKey) { try { using (ComStreamWrapper wrapper = new ComStreamWrapper(pOptionsStream)) { IAnkhSccService scc; switch (pszKey) { case SccPendingChangeStream: WritePendingChanges(wrapper); break; case SccTranslateStream: scc = GetService <IAnkhSccService>(); if (scc != null) { scc.SerializeSccTranslateData(wrapper, true); } break; case SccExcludedStream: scc = GetService <IAnkhSccService>(); if (scc != null) { scc.SerializeSccExcludeData(wrapper, true); } break; default: // TODO: Add support for some service api for our services break; } } return(VSErr.S_OK); } finally { if (Marshal.IsComObject(pOptionsStream)) { Marshal.ReleaseComObject(pOptionsStream); // See Package.cs from MPF for reason } } }
public void GetReaderFromPdbStream() { var stream = new MemoryStream(TestResources.Documents.PortablePdb); var wrapper = new ComStreamWrapper(stream); ISymUnmanagedReader symReader; Assert.Equal(HResult.S_OK, SymBinder.GetReaderFromPdbStream(NotImplementedMetadataProvider.Instance, wrapper, out symReader)); int actualCount; Assert.Equal(HResult.S_OK, symReader.GetDocuments(0, out actualCount, null)); Assert.Equal(13, actualCount); Assert.Equal(HResult.S_FALSE, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Equal(HResult.S_OK, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Throws <ObjectDisposedException>(() => symReader.GetDocuments(0, out actualCount, null)); }
public void GetReaderFromStream() { var importer = new SymMetadataImport(new MemoryStream(TestResources.Documents.Dll)); var stream = new MemoryStream(TestResources.Documents.Pdb); var wrapper = new ComStreamWrapper(stream); ISymUnmanagedReader symReader; Assert.Equal(HResult.S_OK, SymBinder.GetReaderFromStream(importer, wrapper, out symReader)); int actualCount; Assert.Equal(HResult.S_OK, symReader.GetDocuments(0, out actualCount, null)); Assert.Equal(11, actualCount); Assert.Equal(HResult.S_FALSE, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Equal(HResult.S_OK, ((ISymUnmanagedDispose)symReader).Destroy()); Assert.Throws <ObjectDisposedException>(() => symReader.GetDocuments(0, out actualCount, null)); }
public int ReadUserOptions([In] IStream pOptionsStream, [In] string pszKey) { try { using (ComStreamWrapper wrapper = new ComStreamWrapper(pOptionsStream, true)) { IAnkhSccService scc; switch (pszKey) { case SccPendingChangeStream: LoadPendingChanges(wrapper); break; case SccTranslateStream: scc = GetService <IAnkhSccService>(); if (scc != null) { scc.SerializeSccTranslateData(wrapper, false); } break; case SccExcludedStream: scc = GetService <IAnkhSccService>(); if (scc != null) { scc.SerializeSccExcludeData(wrapper, false); } break; default: // TODO: Add support for some service api for our services break; } } return(VSErr.S_OK); // Our data is in subversion properties } catch (EndOfStreamException) { // Ignore: Old version? Broken Solution File? (Common error) return(VSErr.S_OK);; } catch (Exception ex) { #if DEBUG IAnkhErrorHandler handler = GetService <IAnkhErrorHandler>(); if (handler != null) { handler.OnError(ex); } #endif return(VSErr.S_OK); } finally { if (Marshal.IsComObject(pOptionsStream)) { Marshal.ReleaseComObject(pOptionsStream); // See Package.cs from MPF for reason } } }
public PdbWriter(string fileName, ComStreamWrapper stream) { this.stream = stream; this.fileName = fileName; CreateSequencePointBuffers(capacity: 64); }