Example #1
0
        public static int TestFile(DebugReaderProvider drp, IAuthenticationHeaderValueProvider authenticationHeaderValueProvider = null)
        {
            var missingDocs = new List <Document>();
            var erroredDocs = new List <Document>();
            var documents   = GetDocumentsWithUrlHashes(drp, authenticationHeaderValueProvider).GetAwaiter().GetResult();

            foreach (var doc in documents)
            {
                if (doc.IsEmbedded)
                {
                    //Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                    //Console.WriteLine("embedded");
                }
                else if (doc.Url != null)
                {
                    if (doc.Error == null)
                    {
                        //Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                        //Console.WriteLine(doc.Url);
                    }
                    else
                    {
                        erroredDocs.Add(doc);
                    }
                }
                else
                {
                    missingDocs.Add(doc);
                }
            }
            if (missingDocs.Count > 0)
            {
                Console.WriteLine("" + missingDocs.Count + " Documents without URLs:");
                foreach (var doc in missingDocs)
                {
                    Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                }
            }
            if (erroredDocs.Count > 0)
            {
                Console.WriteLine("" + erroredDocs.Count + " Documents with errors:");
                foreach (var doc in erroredDocs)
                {
                    Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                    Console.WriteLine(doc.Url);
                    Console.WriteLine("error: " + doc.Error);
                }
            }
            if (missingDocs.Count > 0 || erroredDocs.Count > 0)
            {
                Console.WriteLine("sourcelink test failed");
                return(4);
            }

            Console.WriteLine("sourcelink test passed: " + drp.Path);
            return(0);
        }
Example #2
0
        public static void PrintDocuments(CommandLineApplication command)
        {
            command.Description = "print the documents stored in the pdb or dll";
            var pdbArgument = command.Argument("path", "set path to pdb or dll", false);

            command.HelpOption("-h|--help");

            command.OnExecute(() =>
            {
                var path = pdbArgument.Value;
                if (path == null)
                {
                    command.ShowHelp();
                    return(2);
                }
                if (!File.Exists(path))
                {
                    Console.Error.WriteLine("file does not exist: " + path);
                    return(3);
                }

                using (var drp = DebugReaderProvider.Create(path))
                {
                    if (drp == null)
                    {
                        Console.Error.WriteLine("unable to read debug info: " + path);
                        return(4);
                    }
                    foreach (var doc in GetDocuments(drp))
                    {
                        Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                    }
                }

                return(0);
            });
        }
Example #3
0
        public static void PrintUrls(CommandLineApplication command)
        {
            command.Description = "print the URLs for each document based on the Source Link JSON";
            var pdbArgument = command.Argument("path", "set path to pdb or dll", false);

            command.HelpOption("-h|--help");

            command.OnExecute(() =>
            {
                var path = pdbArgument.Value;
                if (path == null)
                {
                    command.ShowHelp();
                    return(2);
                }
                if (!File.Exists(path))
                {
                    Console.Error.WriteLine("file does not exist: " + path);
                    return(3);
                }

                using (var drp = DebugReaderProvider.Create(path))
                {
                    if (drp == null)
                    {
                        Console.Error.WriteLine("unable to read debug info: " + path);
                        return(5);
                    }
                    var missingDocs = new List <Document>();
                    foreach (var doc in GetDocumentsWithUrls(drp))
                    {
                        if (doc.IsEmbedded)
                        {
                            Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                            Console.WriteLine("embedded");
                        }
                        else if (doc.Url != null)
                        {
                            Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                            Console.WriteLine(doc.Url);
                        }
                        else
                        {
                            missingDocs.Add(doc);
                        }
                    }
                    if (missingDocs.Count > 0)
                    {
                        Console.Error.WriteLine("" + missingDocs.Count + " Documents without URLs:");
                        foreach (var doc in missingDocs)
                        {
                            Console.Error.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
                        }
                        return(4);
                    }
                }

                return(0);
            });
        }