locked
New Analyzers for Directed Graphs (DGML) RRS feed

  • Question

  • Hello!

     

    I'd like to write a custom analyzer that I can apply to a directed graph.  I've attempted to extend the Microsoft.VisualStudio.Progression.Analyzer class, but when I place the library that I build in PrivateAssemblies\Providers, I receive three Architecture Explorer errors:

     

    Normal    Build Error    incomplete    Could not instantiate provider type MyAnalyzers.GraphAnalyzer        0
    Normal    Build Error    incomplete    Object reference not set to an instance of an object.        0
    Normal    Build Error    incomplete    Provider GraphAnalyzer failed to initialize        0

     

    I've attempted to follow the steps in http://www.clemensreijnen.nl/post/2010/01/18/VS2010-Architecture-Explorer-Analyzers.aspx, but the details there are a little too scant for me to properly implement what he's suggesting.  Requests for the source file have been unanswered (though I only asked a day ago).  Does anybody have any experience building their own analyzers, or any suggestions as to what the null reference exception that's firing could be?  I cannot debug into the Analyzer code.

     

    Here is my source:

     

        [Provider(Name = "GraphAnalyzer")]
        public class GraphAnalyzer : Analyzer
        {
           
            private static GraphProperty IndividualGraph =
                GraphProperty.Register(
                    "IndividualGraph",
                    typeof(bool),
                    new GraphMetadata
                    (
                        "IndividualGraph",
                        "This graph has been categorized as part of a particular graph.",
                        null,
                        GraphMetadataFlags.Default
                    ),
                    typeof(GraphAnalyzer)
                );

            private static int graphCount = 1;

            public override void Analyze(ActionContext context)
            {
                return;
                Graph g = context.Graph;

                foreach (Node n in g.VisibleNodes)
                {
                    AnalyzeNode(n);
                }
            }

            private void AnalyzeNode(Node n)
            {
                if (n[IndividualGraph] == null || n[IndividualGraph].Equals(string.Empty))
                {
                    AnalyzeDependents(String.Format("Graph {0}", graphCount++), n);
                }
            }

            private void AnalyzeDependents(string graphName, Node n)
            {
                if (n[IndividualGraph] == null || n[IndividualGraph].Equals(string.Empty))
                {
                    n[IndividualGraph] = graphName;
                    foreach (Link l in n.IncomingLinks.Union(n.OutgoingLinks))
                    {
                        AnalyzeDependents(graphName, n);
                    }
                }
            }

            public override string Label
            {
                get
                {
                    return "Categorize each isolated graph.";
                }
            }
        }

    Thursday, February 3, 2011 10:31 PM

Answers

  • Looking here the author has a link that he says includes the solution he used, that might be a start.  He also does call out that this is unsupported and not an official extension point, so I don't know how much help you will find as Microsoft doesn't intend people to extend the architecture explorer in this way (assuming his statement is correct, and the fact that the assemblies are located under PrivateAssemblies leads me to believe it is).

    Ryan

    • Marked as answer by Sebenius Thursday, February 3, 2011 11:26 PM
    Thursday, February 3, 2011 11:13 PM