private bool TryGetFileMappingFromMetadataImporter(FileKey fileKey, out IMetaDataInfo info, out IntPtr pImage, out long length)
        {
            // We might not be able to use COM services to get this if VS is shutting down. We'll synchronize to make sure this
            // doesn't race against
            using (_readerWriterLock.DisposableRead())
            {
                // here, we don't care about timestamp since all those bits should be part of Fx. and we assume that
                // it won't be changed in the middle of VS running.
                var fullPath = fileKey.FullPath;

                info   = default;
                pImage = default;
                length = default;

                if (SmartOpenScopeServiceOpt == null)
                {
                    return(false);
                }

                if (ErrorHandler.Failed(SmartOpenScopeServiceOpt.OpenScope(fullPath, (uint)CorOpenFlags.ReadOnly, s_IID_IMetaDataImport, out var ppUnknown)))
                {
                    return(false);
                }

                info = ppUnknown as IMetaDataInfo;
                if (info == null)
                {
                    return(false);
                }

                return(ErrorHandler.Succeeded(info.GetFileMapping(out pImage, out length, out var mappingType)) && mappingType == CorFileMapping.Flat);
            }
        }
Exemplo n.º 2
0
        private bool TryGetFileMappingFromMetadataImporter(FileKey fileKey, out IMetaDataInfo info, out IntPtr pImage, out long length)
        {
            // here, we don't care about timestamp since all those bits should be part of Fx. and we assume that
            // it won't be changed in the middle of VS running.
            var fullPath = fileKey.FullPath;

            info   = default(IMetaDataInfo);
            pImage = default(IntPtr);
            length = default(long);

            var ppUnknown = default(object);

            if (ErrorHandler.Failed(_smartOpenScopeService.OpenScope(fullPath, (uint)CorOpenFlags.ReadOnly, s_IID_IMetaDataImport, out ppUnknown)))
            {
                return(false);
            }

            info = ppUnknown as IMetaDataInfo;
            if (info == null)
            {
                return(false);
            }

            CorFileMapping mappingType;

            return(ErrorHandler.Succeeded(info.GetFileMapping(out pImage, out length, out mappingType)) && mappingType == CorFileMapping.Flat);
        }
        private bool TryGetFileMappingFromMetadataImporter(FileKey fileKey, out IMetaDataInfo info, out IntPtr pImage, out long length)
        {
            // here, we don't care about timestamp since all those bits should be part of Fx. and we assume that 
            // it won't be changed in the middle of VS running.
            var fullPath = fileKey.FullPath;

            info = default(IMetaDataInfo);
            pImage = default(IntPtr);
            length = default(long);

            var ppUnknown = default(object);
            if (ErrorHandler.Failed(_smartOpenScopeService.OpenScope(fullPath, (uint)CorOpenFlags.ReadOnly, s_IID_IMetaDataImport, out ppUnknown)))
            {
                return false;
            }

            info = ppUnknown as IMetaDataInfo;
            if (info == null)
            {
                return false;
            }

            CorFileMapping mappingType;
            return ErrorHandler.Succeeded(info.GetFileMapping(out pImage, out length, out mappingType)) && mappingType == CorFileMapping.Flat;
        }
        private bool TryGetFileMappingFromMetadataImporter(FileKey fileKey, out IMetaDataInfo info, out IntPtr pImage, out long length)
        {
            // We might not be able to use COM services to get this if VS is shutting down. We'll synchronize to make sure this
            // doesn't race against 
            using (_readerWriterLock.DisposableRead())
            {
                // here, we don't care about timestamp since all those bits should be part of Fx. and we assume that 
                // it won't be changed in the middle of VS running.
                var fullPath = fileKey.FullPath;

                info = default(IMetaDataInfo);
                pImage = default(IntPtr);
                length = default(long);

                if (SmartOpenScopeServiceOpt == null)
                {
                    return false;
                }

                var ppUnknown = default(object);
                if (ErrorHandler.Failed(SmartOpenScopeServiceOpt.OpenScope(fullPath, (uint)CorOpenFlags.ReadOnly, s_IID_IMetaDataImport, out ppUnknown)))
                {
                    return false;
                }

                info = ppUnknown as IMetaDataInfo;
                if (info == null)
                {
                    return false;
                }

                CorFileMapping mappingType;
                return ErrorHandler.Succeeded(info.GetFileMapping(out pImage, out length, out mappingType)) && mappingType == CorFileMapping.Flat;
            }
        }