public static void ReadIndex(Index index, string rootPath) { index.indexFinishedPopulating = false; bool retry = false; do { try { index.ClearAll(); ReadFilesCore(index, rootPath); retry = false; index.loadErrorMessage = null; } catch (Exception ex) { index.loadErrorMessage = ex.ToString(); retry = true; Thread.Sleep(10000); } } while (retry); index.indexFinishedPopulating = true; for (int i = 0; i < 10; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); } }
private static Index ReadIndex() { Index index = new Index(); string rootPath = GetRootPath(); IndexLoader.ReadIndex(index, rootPath); return(index); }
public string Generate(Stopwatch sw = null, Index index = null, string usageStats = null) { sb.Clear(); if (query.HasDiagnostics) { sb.AppendLine(Markup.Note(query.Diagnostics)); AppendAffiliateLinks(query); return sb.ToString(); } if (!query.HasResults) { var symbolSearchTerm = query.GetSearchTermForSymbolSearch(); if (!string.IsNullOrEmpty(symbolSearchTerm) && symbolSearchTerm.Length < 3) { sb.AppendLine(Markup.Note("Please specify at least 3 characters for the symbol name, otherwise too many results would be returned")); } else { sb.AppendLine(Markup.Note("No results found")); } if (index != null) { sb.Append(Markup.P(index.RootPath + (@"\" + index.ProjPath ?? ""))); } AppendAffiliateLinks(query); return sb.ToString(); } WriteSymbolResults(index); WriteAssemblyResults(index); WriteProjectResults(index); WriteGuidResults(index); WriteMSBuildPropertiesResults(index); WriteMSBuildItemsResults(index); WriteMSBuildTargetsResults(index); WriteMSBuildTasksResults(index); if (sw != null) { string message = "Generated in " + sw.ElapsedMilliseconds + " ms."; if (usageStats != null) { message += "<br>" + usageStats; } message = Markup.Note(message); sb.AppendLine(message); } return sb.ToString(); }
//[TestMethod] public void LoadIndex() { Index index = ReadIndex(); var matches = index.FindSymbols("Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamedTypeSymbol"); var expected = new DeclaredSymbolInfo() { AssemblyName = "Microsoft.CodeAnalysis.CSharp", Description = "Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamedTypeSymbol", Glyph = 1, ID = 6622120691603058343UL, // { 167, 174, 195, 250, 174, 127, 230, 91 } Kind = "class", Name = "SourceNamedTypeSymbol", ProjectFilePath = "Source\\Compilers\\CSharp\\Source\\CSharpCodeAnalysis.csproj" }; Verify(matches, expected); var query = new Query("System.Core"); index.FindAssemblies(query); Assert.AreEqual("System.Core", query.ResultAssemblies.First().AssemblyName); }
private static void CurrentDomain_DomainUnload(object sender, EventArgs e) { if (instance != null) { instance.Dispose(); instance = null; } }
private static void ReadFilesCore(Index index, string rootPath) { using (Measure.Time("Read index")) { using (Measure.Time("Read project info")) { ReadProjectInfo( rootPath, index.assemblies, index.projects, index.projectToAssemblyIndexMap); } using (Measure.Time("Read declared symbols")) { ReadDeclaredSymbols( rootPath, index.symbols, index.assemblies, index.projects, ref index.huffman, ref index.progress); } ReadGuids(rootPath, index.guids); ReadMSBuildProperties(rootPath, index.msbuildProperties); ReadMSBuildItems(rootPath, index.msbuildItems); ReadMSBuildTargets(rootPath, index.msbuildTargets); ReadMSBuildTasks(rootPath, index.msbuildTasks); } }
private void WriteSymbolResults(Index index) { if (query.ResultSymbols == null || !query.ResultSymbols.Any()) { return; } GenerateResultCount(); var groups = query.ResultSymbols .GroupBy(s => s.AssemblyName) .Select(g => new { AssemblyName = g.Key, Results = g, AssemblyWeight = GetAssemblyWeight(g), NumberOfReferences = GetNumberOfReferences(g.Key, index) }) .OrderBy(g => g.AssemblyWeight) .ThenByDescending(g => g.NumberOfReferences); foreach (var symbolsInAssembly in groups) { WriteAssembly(symbolsInAssembly.Results); } }
private void WriteProjectResults(Index index = null) { if (query.ResultProjects == null || !query.ResultProjects.Any()) { return; } WriteLine("<div class=\"resultGroup\">"); WriteLine("<div class=\"resultGroupHeader\" onClick=\"toggle(this, '{0}');\">", "Projects"); string count = query.ResultProjects.Count.ToString(); if (count == Index.MaxRawResults.ToString()) { count = "showing first " + Index.MaxRawResults.ToString(); } string assemblyHeader = "Projects in '" + query.GetSearchTermForProjectSearch() + "' (" + count + ")"; WriteLine("<div class=\"resultGroupAssemblyName\">{0}</div>", assemblyHeader); //WriteLine(sb, "<div class=\"resultGroupProjectPath\">{0}</div>", Markup.HtmlEscape(symbolsInAssembly.First().ProjectFilePath)); WriteLine("</div>"); WriteLine("<div id=\"{0}\">", "Projects"); foreach (var project in query.ResultProjects) { var url = project; Write( "<a href=\"{0}/ProjectExplorer.html\" target=\"n\"><div class=\"resultItem\"><div class=\"resultLine\">{1}</div>", url.AssemblyName, index.projects[url.ProjectKey]); WriteLine("<div class=\"resultDescription\">{0}</div></div></a>", Markup.HtmlEscape(url.AssemblyName)); } WriteLine("</div></div>"); }
private void WriteMSBuildTasksResults(Index index) { if (query.ResultMSBuildTasks == null || !query.ResultMSBuildTasks.Any()) { return; } WriteLine("<div class=\"resultGroup\">"); WriteLine("<div class=\"resultGroupHeader\" onClick=\"toggle(this, '{0}');\">", "MSBuild Tasks"); string count = query.ResultMSBuildTasks.Count.ToString(); if (count == Index.MaxRawResults.ToString()) { count = "showing first " + Index.MaxRawResults.ToString(); } string header = "MSBuild tasks that match '" + query.OriginalString + "' (" + count + ")"; WriteLine("<div class=\"resultGroupAssemblyName\">{0}</div>", header); WriteLine("</div>"); WriteLine("<div id=\"{0}\">", "MSBuild Tasks"); foreach (var text in query.ResultMSBuildTasks) { var url = text; WriteLine( "<a href=\"{0}/{1}/{2}.html\" target=\"n\"><div class=\"resultItem\"><div class=\"resultLine\">{2}</div>", Constants.MSBuildTasksAssembly, Constants.ReferencesFileName, text); WriteLine("</div></a>"); } WriteLine("</div></div>"); }
private void WriteAssemblyResults(Index index = null) { if (query.ResultAssemblies == null || !query.ResultAssemblies.Any()) { return; } WriteLine("<div class=\"resultGroup\">"); WriteLine("<div class=\"resultGroupHeader\" onClick=\"toggle(this, '{0}');\">", "Assemblies"); string count = query.ResultAssemblies.Count.ToString(); if (count == Index.MaxRawResults.ToString()) { count = "showing first " + Index.MaxRawResults.ToString(); } string assemblySearchTerm = query.GetSearchTermForAssemblySearch() ?? ""; if (!string.IsNullOrEmpty(assemblySearchTerm)) { assemblySearchTerm = "that start with '" + assemblySearchTerm + "' "; } string assemblyHeader = "Assemblies " + assemblySearchTerm + "(" + count + ")"; WriteLine("<div class=\"resultGroupAssemblyName\">{0}</div>", assemblyHeader); //WriteLine(sb, "<div class=\"resultGroupProjectPath\">{0}</div>", Markup.HtmlEscape(symbolsInAssembly.First().ProjectFilePath)); WriteLine("</div>"); WriteLine("<div id=\"{0}\">", "Assemblies"); foreach (var assembly in query.ResultAssemblies) { var url = assembly; WriteLine("<a href=\"/#{0}\" target=\"_top\"><div class=\"resultItem\"><div class=\"resultLine\">{0}</div>", url.AssemblyName); var projectKey = url.ProjectKey; if (projectKey >= 0) { WriteLine("<div class=\"resultDescription\">{0}</div></div></a>", index.projects[projectKey]); } else { WriteLine("</div></a>"); } } WriteLine("</div></div>"); }
private int GetNumberOfReferences(string assemblyName, Index index) { return index.GetReferencingAssembliesCount(assemblyName); }
private void WriteGuidResults(Index index) { if (query.ResultGuids == null || !query.ResultGuids.Any()) { return; } WriteLine("<div class=\"resultGroup\">"); WriteLine("<div class=\"resultGroupHeader\" onClick=\"toggle(this, '{0}');\">", "Guids"); string count = query.ResultGuids.Count.ToString(); if (count == Index.MaxRawResults.ToString()) { count = "showing first " + Index.MaxRawResults.ToString(); } string guidHeader = "Guids that match '" + query.OriginalString + "' (" + count + ")"; WriteLine("<div class=\"resultGroupAssemblyName\">{0}</div>", guidHeader); WriteLine("</div>"); WriteLine("<div id=\"{0}\">", "Guids"); foreach (var guidText in query.ResultGuids) { var url = guidText; WriteLine( "<a href=\"{0}/{1}/{2}.html\" target=\"n\"><div class=\"resultItem\"><div class=\"resultLine\">{2}</div>", SourceConfig.GetUrlPath + Constants.GuidAssembly, Constants.ReferencesFileName, guidText); WriteLine("</div></a>"); } WriteLine("</div></div>"); }
private static Index ReadIndex() { Index index = new Index(); string rootPath = GetRootPath(); IndexLoader.ReadIndex(index, rootPath); return index; }