public int GetReaderFromPdbStream(
            [MarshalAs(UnmanagedType.Interface)] IMetadataImportProvider metadataImportProvider,
            [MarshalAs(UnmanagedType.Interface)] object stream,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedReader reader)
        {
            IStream comStream = stream as IStream;

            if (metadataImportProvider == null || comStream == null)
            {
                reader = null;
                return(HResult.E_INVALIDARG);
            }

            reader = SymReader.CreateFromStream(comStream, new LazyMetadataImport(metadataImportProvider));
            return(HResult.S_OK);
        }
Example #2
0
        public int GetReaderFromPdbStream(
            [MarshalAs(UnmanagedType.Interface)] IMetadataImportProvider metadataImportProvider,
            [MarshalAs(UnmanagedType.Interface)] object stream,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedReader reader)
        {
            var comStream = stream as IStream ??
                            throw new ArgumentException(null, nameof(stream));

            if (metadataImportProvider == null)
            {
                throw new ArgumentException(null, nameof(metadataImportProvider));
            }

            reader = SymReader.CreateFromStream(comStream, new LazyMetadataImport(metadataImportProvider));
            return(HResult.S_OK);
        }
Example #3
0
        public int GetReaderFromStream(
            [MarshalAs(UnmanagedType.Interface)] object metadataImport,
            [MarshalAs(UnmanagedType.Interface)] object stream,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedReader reader)
        {
            reader = null;

            try
            {
                var comStream = stream as IStream ?? throw new ArgumentNullException(null, nameof(stream));
                var mdImport  = MetadataImport.FromObject(metadataImport) ?? throw new ArgumentException(null, nameof(metadataImport));

                reader = SymReader.CreateFromStream(comStream, new LazyMetadataImport(mdImport));
                return(HResult.S_OK);
            }
            finally
            {
                InteropUtilities.TransferOwnershipOrRelease(ref metadataImport, reader);
            }
        }
        public int GetReaderFromStream(
            [MarshalAs(UnmanagedType.Interface)] object metadataImport,
            [MarshalAs(UnmanagedType.Interface)] object stream,
            [MarshalAs(UnmanagedType.Interface)] out ISymUnmanagedReader reader)
        {
            reader = null;

            try
            {
                IStream comStream = stream as IStream;
                var     mdImport  = metadataImport as IMetadataImport;
                if (mdImport == null || comStream == null)
                {
                    return(HResult.E_INVALIDARG);
                }

                reader = SymReader.CreateFromStream(comStream, new LazyMetadataImport(mdImport));
                return(HResult.S_OK);
            }
            finally
            {
                InteropUtilities.TransferOwnershipOrRelease(ref metadataImport, reader);
            }
        }