private IEnumerable <ProjectFinalizer> DiscoverProjects() { var directories = Directory.GetDirectories(SolutionDestinationFolder); foreach (var directory in directories) { var referenceDirectory = Path.Combine(directory, Constants.ReferencesFileName); if (Directory.Exists(referenceDirectory)) { ProjectFinalizer finalizer = null; try { finalizer = new ProjectFinalizer(this, directory); } catch (Exception ex) { Log.Exception(ex, "Failure when creating a ProjectFinalizer for " + directory); finalizer = null; } if (finalizer != null) { yield return(finalizer); } } } }
private void CalculateReferencingAssemblies() { using (Disposable.Timing("Calculating referencing assemblies")) { foreach (var project in this.projects) { assemblyNameToProjectMap.Add(project.AssemblyId, project); } foreach (var project in this.projects) { if (project.ReferencedAssemblies != null) { foreach (var reference in project.ReferencedAssemblies) { ProjectFinalizer referencedProject = null; if (assemblyNameToProjectMap.TryGetValue(reference, out referencedProject)) { referencedProject.ReferencingAssemblies.Add(project.AssemblyId); } } } } var mostReferencedProjects = projects .OrderByDescending(p => p.ReferencingAssemblies.Count) .Select(p => p.AssemblyId + ";" + p.ReferencingAssemblies.Count) .Take(100) .ToArray(); var filePath = Path.Combine(this.SolutionDestinationFolder, Constants.TopReferencedAssemblies + ".txt"); File.WriteAllLines(filePath, mostReferencedProjects); } }
private void WriteBaseMember(ulong symbolId, StreamWriter writer) { Tuple <string, ulong> baseMemberLink; if (!BaseMembers.TryGetValue(symbolId, out baseMemberLink)) { return; } Write(writer, @"<div class=""rH"">Base:</div>"); var assemblyName = baseMemberLink.Item1; var baseSymbolId = baseMemberLink.Item2; ProjectFinalizer baseProject = null; if (!this.SolutionFinalizer.assemblyNameToProjectMap.TryGetValue(assemblyName, out baseProject)) { return; } DeclaredSymbolInfo symbol = null; if (baseProject.DeclaredSymbols.TryGetValue(baseSymbolId, out symbol)) { var sb = new StringBuilder(); Markup.WriteSymbol(symbol, sb); writer.Write(sb.ToString()); } }
private void WriteImplementedInterfaceMembers(ulong symbolId, StreamWriter writer) { HashSet <Tuple <string, ulong> > implementedInterfaceMembers; if (!ImplementedInterfaceMembers.TryGetValue(symbolId, out implementedInterfaceMembers)) { return; } Write(writer, string.Format(@"<div class=""rH"">Implemented interface member{0}:</div>", implementedInterfaceMembers.Count > 1 ? "s" : "")); foreach (var implementedInterfaceMember in implementedInterfaceMembers) { var assemblyName = implementedInterfaceMember.Item1; var interfaceSymbolId = implementedInterfaceMember.Item2; ProjectFinalizer baseProject = null; if (!this.SolutionFinalizer.assemblyNameToProjectMap.TryGetValue(assemblyName, out baseProject)) { return; } DeclaredSymbolInfo symbol = null; if (baseProject.DeclaredSymbols.TryGetValue(interfaceSymbolId, out symbol)) { var sb = new StringBuilder(); Markup.WriteSymbol(symbol, sb); writer.Write(sb.ToString()); } } }
private void PatchProjectExplorer(ProjectFinalizer project) { if (project.ReferencingAssemblies.Count == 0 || project.ReferencingAssemblies.Count > 100) { return; } var fileName = Path.Combine(project.ProjectDestinationFolder, Constants.ProjectExplorer + ".html"); if (!File.Exists(fileName)) { return; } var sourceLines = File.ReadAllLines(fileName); List<string> lines = new List<string>(sourceLines.Length + project.ReferencingAssemblies.Count + 2); RelativeState state = RelativeState.Before; foreach (var sourceLine in sourceLines) { switch (state) { case RelativeState.Before: if (sourceLine == "<div class=\"folderTitle\">References</div><div class=\"folder\">") { state = RelativeState.Inside; } break; case RelativeState.Inside: if (sourceLine == "</div>") { state = RelativeState.InsertionPoint; } break; case RelativeState.InsertionPoint: lines.Add("<div class=\"folderTitle\">Used By</div><div class=\"folder\">"); foreach (var referencingAssembly in project.ReferencingAssemblies) { string referenceHtml = Markup.GetProjectExplorerReference("/#" + referencingAssembly, referencingAssembly); lines.Add(referenceHtml); } lines.Add("</div>"); state = RelativeState.After; break; case RelativeState.After: break; default: break; } lines.Add(sourceLine); } File.WriteAllLines(fileName, lines); }
private IEnumerable<ProjectFinalizer> DiscoverProjects() { var directories = Directory.GetDirectories(SolutionDestinationFolder); foreach (var directory in directories) { var referenceDirectory = Path.Combine(directory, Constants.ReferencesFileName); if (Directory.Exists(referenceDirectory)) { ProjectFinalizer finalizer = null; try { finalizer = new ProjectFinalizer(this, directory); } catch (Exception ex) { Log.Exception(ex, "Failure when creating a ProjectFinalizer for " + directory); finalizer = null; } if (finalizer != null) { yield return finalizer; } } } }
private void PatchProjectExplorer(ProjectFinalizer project) { if (project.ReferencingAssemblies.Count == 0 || project.ReferencingAssemblies.Count > 100) { return; } var fileName = Path.Combine(project.ProjectDestinationFolder, Constants.ProjectExplorer + ".html"); if (!File.Exists(fileName)) { return; } var sourceLines = File.ReadAllLines(fileName); List <string> lines = new List <string>(sourceLines.Length + project.ReferencingAssemblies.Count + 2); RelativeState state = RelativeState.Before; foreach (var sourceLine in sourceLines) { switch (state) { case RelativeState.Before: if (sourceLine == "<div class=\"folderTitle\">References</div><div class=\"folder\">") { state = RelativeState.Inside; } break; case RelativeState.Inside: if (sourceLine == "</div>") { state = RelativeState.InsertionPoint; } break; case RelativeState.InsertionPoint: lines.Add("<div class=\"folderTitle\">Used By</div><div class=\"folder\">"); foreach (var referencingAssembly in project.ReferencingAssemblies) { string referenceHtml = Markup.GetProjectExplorerReference("/#" + referencingAssembly, referencingAssembly); lines.Add(referenceHtml); } lines.Add("</div>"); state = RelativeState.After; break; case RelativeState.After: break; default: break; } lines.Add(sourceLine); } File.WriteAllLines(fileName, lines); }