/// <summary> /// Gets metadata about a package from the <c>nuspec</c> files and other /// metadata such as package size, date published, download counts, etc. /// </summary> public object GetPackageInfo(string id, string version = "") { var packageSpec = new PackageSpec(id, version); var packages = LuceneRepository .LucenePackages .Where(p => p.Id == packageSpec.Id) .OrderBy(p => p.Version) .ToList(); var package = packageSpec.Version != null ? packages.Find(p => p.Version.SemanticVersion == packageSpec.Version) : packages.LastOrDefault(); if (package == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Package not found.")); } var versionHistory = packages.Select(pkg => new PackageVersionSummary(pkg, new Link(GetPackageInfoUrl(pkg), pkg.Version.ToString()))).ToList(); versionHistory.Select(v => v.Link).SetRelationships(packages.IndexOf(package)); var result = new PackageWithVersionHistory(); package.ShallowClone(result); result.PackageDownloadLink = new Link(Url.Link(RouteNames.Packages.Download, new { id = result.Id, version = result.Version }), "attachment", "Download Package"); result.VersionHistory = versionHistory.ToArray(); result.SymbolsAvailable = SymbolSource.AreSymbolsPresentFor(package); return(result); }
public override SymSourceCollection CreateSources(string aFileName) { System.Diagnostics.Debug.WriteLine(string.Format("[Symbol Memory] START -> {0:d12}, source: {1}", System.GC.GetTotalMemory(true), aFileName)); SymbolSource source = new SymbolSource(aFileName, this); return(new SymSourceCollection(source)); }
public override void ReadSource(SymSource aSource, TSynchronicity aSynchronicity) { SymbolSource source = (SymbolSource)aSource; // SymbolFileData data = source.ExcavateData(); SymbolFileReader reader = new SymbolFileReader(source, data); reader.Read(aSynchronicity); }
public SymbolFileReader(SymbolSource aSource, SymbolFileData aData) : base(aData, System.Threading.ThreadPriority.Lowest) { iSource = aSource; iData = aData; // Count the total number of lines - this enables us to report progress foreach (SymbolFileSegment segment in iData) { iTotalNumberOfLines += segment.NumberOfLines; } }
public ISymbolSource LoadSymbolSource(SymbolSource symSrcDef, byte [] bytes, string filename) { var type = Type.GetType(symSrcDef.TypeName, false); if (type == null) { var eventListener = services.RequireService <DecompilerEventListener>(); eventListener.Error(new NullCodeLocation(""), "Symbol source {0} in the Reko configuration failed to load.", symSrcDef.Name); return(null); } var symSrc = (ISymbolSource)Activator.CreateInstance(type); if (symSrc.CanLoad(filename, bytes)) { return(symSrc); } return(null); }
public async Task <HttpResponseMessage> DeletePackage(string id, string version = "") { if (string.IsNullOrWhiteSpace(id) || string.IsNullOrWhiteSpace(version)) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Must specify package id and version.")); } var package = LuceneRepository.FindPackage(id, new SemanticVersion(version)); if (package == null) { var message = string.Format("Package '{0}' version '{1}' not found.", id, version); return(Request.CreateErrorResponse(HttpStatusCode.NotFound, message)); } Audit("Delete package {0} version {1}", id, version); var task1 = LuceneRepository.RemovePackageAsync(package, CancellationToken.None); var task2 = SymbolSource.RemoveSymbolsAsync(package); await Task.WhenAll(task1, task2); return(Request.CreateResponse(HttpStatusCode.OK)); }
public static string GetSymbolFile(string fname, [CanBeNull] string o = null, SymbolSource src = SymbolSource.Symchk) { switch (src) { case SymbolSource.Symchk: break; case SymbolSource.Download: return(Download()); default: throw new ArgumentOutOfRangeException(nameof(src), src, null); } o ??= FileSystem.GetPath(KnownFolder.Downloads); // symchk.exe .\urlmon.dll /s SRV*"C:\Symbols\"*http://msdl.microsoft.com/download/symbols /osdbc \. //symchk /os <input> /su "SRV**http://msdl.microsoft.com/download/symbols" /oc <output> //symchk <input> /su "SRV**http://msdl.microsoft.com/download/symbols" /osc <output> if (!File.Exists(fname)) { throw new FileNotFoundException(null, fname); } const string symchk = "symchk"; var process = Command.Run(symchk); var info = process.StartInfo; info.Arguments = $"{fname} /su SRV**{EmbeddedResources.MicrosoftSymbolServer} /oscdb {o}"; process.Start(); process.WaitForExit(); var error = process.StandardError.ReadToEnd(); // var ee = process.StandardOutput.ReadToEnd(); if (!String.IsNullOrWhiteSpace(error)) { process.Dispose(); return(null); } process.Dispose(); // var f = ee.Split(' ')[1]; // var combine = Path.Combine(Path.GetFileName(s), o); // return combine; // var outFile = ee.Split("PDB: ")[1].Split("DBG: ")[0].Trim(); var outFile = Path.Combine(o, Path.GetFileNameWithoutExtension(fname) + ".pdb"); if (!File.Exists(outFile)) { throw new FileNotFoundException(null, outFile); } return(outFile); string Download() { // fname=FileSystem.SearchInPath(fname); fname = Path.GetFullPath(fname); using var peReader = new PEReader(File.OpenRead(fname)); var codeViewEntry = peReader.ReadDebugDirectory() .First(entry => entry.Type == DebugDirectoryEntryType.CodeView); var pdbData = peReader.ReadCodeViewDebugDirectoryData(codeViewEntry); // var cacheDirectoryPath = Global.ProgramData; o ??= FileSystem.GetPath(KnownFolder.Downloads); using var wc = new WebClient(); // Check if the correct version of the PDB is already cached var path = Path.ChangeExtension(fname, "pdb"); var fileName = Path.GetFileName(path); var pdbDirPath = Path.Combine(o, fileName); if (!Directory.Exists(pdbDirPath)) { Directory.CreateDirectory(pdbDirPath); } var pdbPlusGuidDirPath = Path.Combine(pdbDirPath, pdbData.Guid.ToString()); if (!Directory.Exists(pdbPlusGuidDirPath)) { Directory.CreateDirectory(pdbPlusGuidDirPath); } //var pdbFilePath = Path.Combine(pdbPlusGuidDirPath, path); var pdbFilePath = Path.Combine(pdbPlusGuidDirPath, fileName); if (File.Exists(pdbFilePath)) { Debug.WriteLine($"Using {pdbFilePath}", nameof(GetSymbolFile)); goto ret; } var uriString = EmbeddedResources.MicrosoftSymbolServer + $"{fileName}/" + $"{pdbData.Guid:N}{pdbData.Age}/{fileName}"; Debug.WriteLine($"Downloading {uriString}", nameof(GetSymbolFile)); //await wc.DownloadFileTaskAsync(new Uri(uriString), pdbFilePath); wc.DownloadFile(new Uri(uriString), pdbFilePath); Debug.WriteLine($"Downloaded to {pdbFilePath} ({pdbPlusGuidDirPath})", nameof(GetSymbolFile)); ret: return(pdbFilePath); } }
public SymbolFileData(SymbolSource aSource) { iSource = aSource; iData = File.ReadAllBytes(aSource.URI); }