diff options
author | Michal Strehovský <michals@microsoft.com> | 2017-03-11 07:09:53 +0300 |
---|---|---|
committer | Michal Strehovský <michals@microsoft.com> | 2017-03-11 07:38:53 +0300 |
commit | 806bbf9b964f404a921475c0be83e72648ed0828 (patch) | |
tree | 61d66bebfc1f492d57e70c6829a3b06e67b1804c /src/ILCompiler.DependencyAnalysisFramework | |
parent | de440e995b53662d1fac764dd85792b22e8e0eb3 (diff) |
Make GetName method accept the dependency context
Diffstat (limited to 'src/ILCompiler.DependencyAnalysisFramework')
4 files changed, 14 insertions, 11 deletions
diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs index b0eefd4ad..707014146 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DependencyNodeCore.cs @@ -140,6 +140,6 @@ namespace ILCompiler.DependencyAnalysisFramework } // Force all non-abstract nodes to provide a name - protected internal abstract string GetName(); + protected internal abstract string GetName(DependencyContextType context); } } diff --git a/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs b/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs index 0e891493f..0ff83f4b1 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/src/DgmlWriter.cs @@ -12,9 +12,9 @@ namespace ILCompiler.DependencyAnalysisFramework { public class DgmlWriter { - public static void WriteDependencyGraphToStream<DependencyContextType>(Stream stream, DependencyAnalyzerBase<DependencyContextType> analysis) + public static void WriteDependencyGraphToStream<DependencyContextType>(Stream stream, DependencyAnalyzerBase<DependencyContextType> analysis, DependencyContextType context) { - DgmlWriter<DependencyContextType>.WriteDependencyGraphToStream(stream, analysis); + DgmlWriter<DependencyContextType>.WriteDependencyGraphToStream(stream, analysis, context); } } @@ -22,11 +22,14 @@ namespace ILCompiler.DependencyAnalysisFramework { private XmlWriter _xmlWrite; private bool _done = false; - public DgmlWriter(XmlWriter xmlWrite) + private DependencyContextType _context; + + public DgmlWriter(XmlWriter xmlWrite, DependencyContextType context) { _xmlWrite = xmlWrite; _xmlWrite.WriteStartDocument(); _xmlWrite.WriteStartElement("DirectedGraph", "http://schemas.microsoft.com/vs/2009/dgml"); + _context = context; } public void WriteNodesAndEdges(Action nodeWriter, Action edgeWriter) @@ -44,7 +47,7 @@ namespace ILCompiler.DependencyAnalysisFramework _xmlWrite.WriteEndElement(); } - public static void WriteDependencyGraphToStream(Stream stream, DependencyAnalyzerBase<DependencyContextType> analysis) + public static void WriteDependencyGraphToStream(Stream stream, DependencyAnalyzerBase<DependencyContextType> analysis, DependencyContextType context) { XmlWriterSettings writerSettings = new XmlWriterSettings(); writerSettings.Indent = true; @@ -52,7 +55,7 @@ namespace ILCompiler.DependencyAnalysisFramework using (XmlWriter xmlWriter = XmlWriter.Create(stream, writerSettings)) { - using (var dgmlWriter = new DgmlWriter<DependencyContextType>(xmlWriter)) + using (var dgmlWriter = new DgmlWriter<DependencyContextType>(xmlWriter, context)) { dgmlWriter.WriteNodesAndEdges(() => { @@ -103,7 +106,7 @@ namespace ILCompiler.DependencyAnalysisFramework private void AddNode(DependencyNodeCore<DependencyContextType> node) { - AddNode(node, node.GetName()); + AddNode(node, node.GetName(_context)); } private void AddNode(object node, string label) @@ -145,8 +148,8 @@ namespace ILCompiler.DependencyAnalysisFramework void IDependencyAnalyzerLogNodeVisitor<DependencyContextType>.VisitCombinedNode(Tuple<DependencyNodeCore<DependencyContextType>, DependencyNodeCore<DependencyContextType>> node) { - string label1 = node.Item1.GetName(); - string label2 = node.Item2.GetName(); + string label1 = node.Item1.GetName(_context); + string label2 = node.Item2.GetName(_context); AddNode(node, string.Concat("(", label1, ", ", label2, ")")); } diff --git a/src/ILCompiler.DependencyAnalysisFramework/tests/DependencyAnalysisFrameworkTests.cs b/src/ILCompiler.DependencyAnalysisFramework/tests/DependencyAnalysisFrameworkTests.cs index ca2baedaf..390299940 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/tests/DependencyAnalysisFrameworkTests.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/tests/DependencyAnalysisFrameworkTests.cs @@ -169,7 +169,7 @@ namespace ILCompiler.DependencyAnalysisFramework.Tests { BuildGraphUsingAllTypesOfRules(testGraph, analyzer); MemoryStream dgmlOutput = new MemoryStream(); - DgmlWriter.WriteDependencyGraphToStream(dgmlOutput, analyzer); + DgmlWriter.WriteDependencyGraphToStream(dgmlOutput, analyzer, testGraph); dgmlOutput.Seek(0, SeekOrigin.Begin); TextReader tr = new StreamReader(dgmlOutput); dgmlOutputs[analyzer.GetType().FullName] = tr.ReadToEnd(); diff --git a/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs b/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs index 195ff91bd..53a0f7690 100644 --- a/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs +++ b/src/ILCompiler.DependencyAnalysisFramework/tests/TestGraph.cs @@ -31,7 +31,7 @@ namespace ILCompiler.DependencyAnalysisFramework.Tests } } - protected override string GetName() + protected override string GetName(TestGraph context) { return _data; } |