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); }); }
public static int TestFile(string path, IAuthenticationHeaderValueProvider authenticationHeaderValueProvider = null) { using (var drp = DebugReaderProvider.Create(path)) { if (drp == null) { Console.Error.WriteLine("unable to read debug info: " + path); return(5); } return(TestFile(drp, authenticationHeaderValueProvider)); } }
public static void PrintJson(CommandLineApplication command) { command.Description = "print the Source Link JSON 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(5); } var bytes = GetSourceLinkBytes(drp); if (bytes == null || bytes.Length == 0) { Console.Error.WriteLine("Source Link JSON not found in file: " + path); return(4); } Console.WriteLine(Encoding.UTF8.GetString(bytes)); } return(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); }); }
public static int TestNupkg(string path, List <string> files, IAuthenticationHeaderValueProvider authenticationHeaderValueProvider = null) { var errors = 0; using (var p = new PackageArchiveReader(File.OpenRead(path))) { var dlls = new List <string>(); var pdbs = new HashSet <string>(); foreach (var f in p.GetFiles()) { switch (Path.GetExtension(f)) { case ".dll": dlls.Add(f); break; case ".pdb": pdbs.Add(f); break; } } if (files.Count == 0) { foreach (var dll in dlls) { var pdb = Path.ChangeExtension(dll, ".pdb"); if (pdbs.Contains(pdb)) { files.Add(pdb); } else if (!IsSatelliteAssembly(dll, dlls)) { files.Add(dll); } } } foreach (var file in files) { try { using (var stream = p.GetStream(file)) using (var ms = new MemoryStream()) // seek required { stream.CopyTo(ms); ms.Position = 0; using (var drp = DebugReaderProvider.Create(file, ms)) { if (drp == null) { Console.Error.WriteLine("unable to read debug info: " + path); return(5); } if (TestFile(drp, authenticationHeaderValueProvider) != 0) { Console.WriteLine("failed for " + file); errors++; } } } } catch (FileNotFoundException) { Console.WriteLine("file not found: " + file); errors++; } } } return(errors); }