private string GetUrl(ISymUnmanagedDocument doc)
        {
            lock (this)
            {
                if (_urlCache == null)
                {
                    _urlCache = new Dictionary <ISymUnmanagedDocument, string>();
                }

                string url;
                if (_urlCache.TryGetValue(doc, out url))
                {
                    return(url);
                }

                int urlLength;
                ThrowExceptionForHR(doc.GetUrl(0, out urlLength, null));

                // urlLength includes terminating '\0'
                char[] urlBuffer = new char[urlLength];
                ThrowExceptionForHR(doc.GetUrl(urlLength, out urlLength, urlBuffer));

                url = new string(urlBuffer, 0, urlLength - 1);
                _urlCache.Add(doc, url);
                return(url);
            }
        }
Example #2
0
        private string GetUrl(ISymUnmanagedDocument doc)
        {
            string url;

            if (_urlCache.TryGetValue(doc, out url))
            {
                return(url);
            }

            int urlLength;

            ThrowExceptionForHR(doc.GetUrl(0, out urlLength, null));

            // urlLength includes terminating '\0'
            char[] urlBuffer = new char[urlLength];
            ThrowExceptionForHR(doc.GetUrl(urlLength, out urlLength, urlBuffer));

            url = new string(urlBuffer, 0, urlLength - 1);

            // Map the URL, if a map is available
            if (_sourceFileMap != null)
            {
                url = _sourceFileMap[url];
            }

            _urlCache.Add(doc, url);
            return(url);
        }
Example #3
0
    public SymDocument(ISymUnmanagedDocument doc)
    {
        if (doc == null)
        {
            throw new ArgumentNullException(nameof(doc));
        }

        int len;

        doc.GetUrl(0, out len, null);
        if (len > 0)
        {
            var urlChars = new char[len];
            doc.GetUrl(len, out len, urlChars);
            Url = new string(urlChars, 0, len - 1);
        }

        doc.GetChecksum(0, out len, null);
        if (len > 0)
        {
            Checksum = new byte[len];
            doc.GetChecksum(len, out len, Checksum);
        }

        Guid id = Guid.Empty;

        doc.GetChecksumAlgorithmId(ref id);
        ChecksumAlgorithmId = id;
    }
Example #4
0
        public static void ValidateDocumentUrl(ISymUnmanagedDocument document, string url)
        {
            int actualCount, actualCount2;
            Assert.Equal(HResult.S_OK, document.GetUrl(0, out actualCount, null));

            char[] actualUrl = new char[actualCount];
            Assert.Equal(HResult.S_OK, document.GetUrl(actualCount, out actualCount2, actualUrl));
            Assert.Equal(url, new string(actualUrl, 0, actualUrl.Length - 1));
        }
        public static void ValidateDocumentUrl(ISymUnmanagedDocument document, string url)
        {
            int actualCount, actualCount2;

            Assert.Equal(HResult.S_OK, document.GetUrl(0, out actualCount, null));

            char[] actualUrl = new char[actualCount];
            Assert.Equal(HResult.S_OK, document.GetUrl(actualCount, out actualCount2, actualUrl));
            Assert.Equal(url, new string(actualUrl, 0, actualUrl.Length - 1));
        }
Example #6
0
                public SymDocument(ISymUnmanagedDocument doc)
                {
                    if (doc == null)
                    {
                        throw new ArgumentNullException(nameof(doc));
                    }

                    int len;
                    var hr = doc.GetUrl(0, out len, null);

                    ThrowExceptionForHR(hr);
                    if (len > 0)
                    {
                        var urlChars = new char[len];
                        hr = doc.GetUrl(len, out len, urlChars);
                        ThrowExceptionForHR(hr);
                        Url = new string(urlChars, 0, len - 1);
                    }

                    hr = doc.GetChecksum(0, out len, null);
                    ThrowExceptionForHR(hr);

                    if (len > 0)
                    {
                        Checksum = new byte[len];
                        hr       = doc.GetChecksum(len, out len, Checksum);
                        ThrowExceptionForHR(hr);
                    }

                    var id = Guid.Empty;

                    hr = doc.GetChecksumAlgorithmId(ref id);
                    ThrowExceptionForHR(hr);

                    ChecksumAlgorithmId = id;
                    if (id == CorSym_SourceHash_MD5)
                    {
                        ChecksumAlgorithm = ChecksumAlgorithmKind.Md5;
                    }
                    else if (id == CorSym_SourceHash_SHA1)
                    {
                        ChecksumAlgorithm = ChecksumAlgorithmKind.Sha1;
                    }
                }
        private string GetUrl(ISymUnmanagedDocument doc)
        {
            lock (this)
            {
                if (_urlCache == null)
                    _urlCache = new Dictionary<ISymUnmanagedDocument, string>();

                string url;
                if (_urlCache.TryGetValue(doc, out url))
                    return url;

                int urlLength;
                ThrowExceptionForHR(doc.GetUrl(0, out urlLength, null));

                // urlLength includes terminating '\0'
                char[] urlBuffer = new char[urlLength];
                ThrowExceptionForHR(doc.GetUrl(urlLength, out urlLength, urlBuffer));

                url = new string(urlBuffer, 0, urlLength - 1);
                _urlCache.Add(doc, url);
                return url;
            }
        }