public int Do() { // Look for nuspec files to process and read their contents var nuspecDataList = ReadNuGetFiles(InputFolder, GroupFolder, UsePrefixes, Verbose); if (nuspecDataList == null) { return(0); } // Add nodes to graph foreach (var nuspecData in nuspecDataList) { _dgmlWriter.AddNode(nuspecData.PackageId, nuspecData.Label, PackageCategory, nuspecData.FilePath, nuspecData.Container); } // Add dependencies to graph foreach (var nuspecData in nuspecDataList) { foreach (var dependency in nuspecData.Dependencies) { if (!_dgmlWriter.ExistsNode(dependency.Id)) { _dgmlWriter.AddNode(dependency.Id, dependency.GetLabel(), ExternalPackageCategory, ""); _dgmlWriter.SetParent("ext", dependency.Id); } _dgmlWriter.AddLink(dependency.Id, nuspecData.PackageId, dependency.Version, "DependsOn"); } } return(nuspecDataList.Count); }
public string SaveDgml(string filePath, bool whatIf = false) { var writer = new DgmlWriter(); Console.WriteLine("Analyzing the async graphs..."); var visualContext = VisuaNodes.VisualContext.Create(Nodes, simplify: true); foreach (var node in visualContext.EnumerateVisualNodes()) { writer.AddNode(new DgmlWriter.Node(id: node.Id, label: node.DisplayText)); //foreach (var dependency in node.Dependencies.OrderBy(d => d.Id)) foreach (var dependency in node.AwaitsOn) { writer.AddLink(new DgmlWriter.Link( source: node.Id, target: dependency.Id, label: null)); } } if (whatIf) { return(writer.SerializeAsString()); } if (File.Exists(filePath)) { var existingFile = File.ReadAllText(filePath); var newFile = writer.SerializeAsString(); if (existingFile == newFile) { Console.WriteLine("No changes were detected!"); } else { Console.WriteLine("The diagram has changaed!"); writer.Serialize(filePath); } } else { writer.Serialize(filePath); } return(writer.SerializeAsString()); }
/// <summary> /// Exports the contents of the given pip graph. It is expected to no longer change as of the start of this call. /// </summary> public override int Analyze() { DgmlWriter writer = new DgmlWriter(); Dictionary <PipId, PipReference> concretePipValues = new Dictionary <PipId, PipReference>(); HashSet <PipReference> allValuePips = new HashSet <PipReference>(PipGraph.RetrievePipReferencesOfType(PipType.Value)); foreach (var valuePip in allValuePips) { foreach (var incoming in DataflowGraph.GetIncomingEdges(valuePip.PipId.ToNodeId())) { if (!PipTable.GetPipType(incoming.OtherNode.ToPipId()).IsMetaPip()) { concretePipValues[valuePip.PipId] = valuePip; } } } foreach (var concretePipValue in concretePipValues.Values) { var value = ((ValuePip)concretePipValue.HydratePip()).Symbol.ToString(SymbolTable); writer.AddNode(new DgmlWriter.Node(concretePipValue.PipId.ToString(), value)); foreach (var incoming in DataflowGraph.GetIncomingEdges(concretePipValue.PipId.ToNodeId())) { var incomingId = incoming.OtherNode.ToPipId(); if (concretePipValues.ContainsKey(incomingId)) { writer.AddLink(new DgmlWriter.Link( incomingId.ToString(), concretePipValue.PipId.ToString(), label: null)); } } } writer.Serialize(m_dgmlFilePath); return(0); }