PdbImportScope ReadPdbImportScope(ref ImportScopeBlobReader importScopeBlobReader, uint importScope, GenericParamContext gpContext)
        {
            if (importScope == 0)
            {
                return(null);
            }
            const int      MAX       = 1000;
            PdbImportScope result    = null;
            PdbImportScope prevScope = null;

            for (int i = 0; importScope != 0; i++)
            {
                Debug.Assert(i < MAX);
                if (i >= MAX)
                {
                    return(null);
                }
                int token = new MDToken(Table.ImportScope, importScope).ToInt32();
                if (!pdbMetadata.TablesStream.TryReadImportScopeRow(importScope, out var row))
                {
                    return(null);
                }
                var scope = new PdbImportScope();
                GetCustomDebugInfos(token, gpContext, scope.CustomDebugInfos);
                if (result is null)
                {
                    result = scope;
                }
                if (prevScope is not null)
                {
                    prevScope.Parent = scope;
                }
                importScopeBlobReader.Read(row.Imports, scope.Imports);
                prevScope   = scope;
                importScope = row.Parent;
            }

            return(result);
        }