private TypeVertex GetVertex(TypeReference tref, string className, DetermineClassDeps dcd)
        {
            TypeVertex V;

            if (dcd.IsExternalType(tref))
            {
                className = DetermineClassDeps.AssemblyNameofType(tref);
            }
            if (classMap.ContainsKey(className))
            {
                V = classMap[className];
            }
            else
            {
                V         = (TypeVertex)this.AddVertex();
                V.Name    = className;
                V.TypeRef = tref;
                if (dcd.IsExternalType(tref))
                {
                    V.ImutableExternalType = true;
                }
                classMap[className] = V;
            }
            return(V);
        }
        public void LoadClassDependencies(DetermineClassDeps dcd, bool treatExternalTypesAsSingleImutable)
        {
            foreach (TypeDefinition tdef in dcd.ClassDependencies.Keys)
            {
                string className = tdef.FullName;
                foreach (UsedClass uc in dcd.ClassDependencies[tdef])
                {
                    string refclassName = uc.Type.FullName;
                    if (!String.IsNullOrEmpty(_examininationNSN))
                    {
                        if (!
                            (
                                (tdef.FullName.StartsWith(_examininationNSP) || tdef.FullName.StartsWith(_examininationNSN)) &&
                                (uc.Type.FullName.StartsWith(_examininationNSN) || uc.Type.FullName.StartsWith(_examininationNSP))
                            ))
                        {
                            continue;
                        }
                    }

                    TypeVertex usingVertex = GetVertex(tdef, className, dcd);
                    TypeVertex refVertex   = GetVertex(uc.Type, refclassName, dcd);

                    if (AllowParallel || !this.ContainsEdge(usingVertex, refVertex))
                    {
                        NamedEdge edge = (NamedEdge)this.AddEdge(usingVertex, refVertex);
                        edge.Name = uc.Use.ToString();
                    }
                }
            }
        }
Beispiel #3
0
 public void Setup()
 {
     dcd = new ACATool.DetermineClassDeps();
     dcd.AssemblyFile = this.GetType().Assembly.Location;
         //@"C:\dev\N\play\ACATool\TestAssem\bin\Debug\TestAssem.dll";
     dcd.GetAllTypes();
 }
Beispiel #4
0
        private void WriteAssemRefsItemGroup(XmlTextWriter xproj, CondensedVertex va)
        {
            xproj.WriteComment("Assembly Refs");
            xproj.WriteStartElement("ItemGroup");
            foreach (CondensedVertex projRef in Graph.AdjacentVertices(va))
            {
                if (projRef.ImutableExternalType)
                {
                    xproj.WriteStartElement("Reference");
                    string aRefShortName = "";

                    string aRefFQN = DetermineClassDeps.AssemblyNameofType(projRef.ContainedTypes[0]);


                    if (aRefFQN.StartsWith("mscorlib"))
                    {
                        aRefFQN = "System,";
                    }

                    int idx = aRefFQN.IndexOf(",");
                    if (idx > 0)
                    {
                        aRefShortName = aRefFQN.Substring(0, idx);
                    }

                    if (aRefFQN.StartsWith("System"))
                    {
                        xproj.WriteAttributeString("Include", aRefShortName);
                    }
                    else
                    {
                        xproj.WriteAttributeString("Include", aRefFQN);
                        string[] exts = new string[2] {
                            ".dll", ".exe"
                        };
                        foreach (string ext in exts)
                        {
                            string hintPath = Path.Combine(Path.GetDirectoryName(AssemblyFileName), aRefShortName) + ext;
                            if (File.Exists(hintPath))
                            {
                                xproj.WriteElementString("SpecificVersion", false.ToString());
                                //todo - manage directories better
                                xproj.WriteElementString("HintPath", Path.Combine("..", hintPath));
                                break;
                            }
                        }
                    }
                    xproj.WriteEndElement();
                }
            }
            xproj.WriteEndElement();
        }
Beispiel #5
0
        public void Execute()
        {
            DetermineClassDeps  dcd = new DetermineClassDeps();
            TypeDependencyGraph tdg = new TypeDependencyGraph(false);

            dcd.AssemblyFile      = AssemblyFileName;
            dcd.IgnoreOutsideRefs = false;
            dcd.Execute();
            tdg.LoadClassDependencies(dcd, true);
            this._graph = tdg.CondenseGraph();

            WritePDBasXML pdbxmlWritterTask = new WritePDBasXML();

            pdbxmlWritterTask.AssemblyName = new TaskItem(this.AssemblyFileName);

            if (pdbxmlWritterTask.Execute())
            {
                this._pDBDataFile = pdbxmlWritterTask.PDBAsXmlFile.ItemSpec;
                pdbXPathDoc       = new XPathDocument(PDBDataFile);
                pdbNav            = pdbXPathDoc.CreateNavigator();
            }



            Directory.CreateDirectory(OutputDirectory);
            foreach (CondensedVertex va in Graph.Vertices)
            {
                if (va.ImutableExternalType)
                {
                    continue;
                }
                va.AssemblyName = GetAssemblyName(va);
                if (va.AssemblyName.StartsWith("<"))
                {
                    continue;
                }

                va.AssemblyGUID = Guid.NewGuid();
                va.ProjectFile  = va.AssemblyName + ".csproj"; // );//Path.Combine(OutputDirectory,
            }

            foreach (CondensedVertex vassem in Graph.Vertices)
            {
                CreateProjectFile(vassem);
            }

            CreateSolutionFile();
        }
        public void Execute()
        {
            DetermineClassDeps dcd = new DetermineClassDeps();
            TypeDependencyGraph tdg = new TypeDependencyGraph(false);
            dcd.AssemblyFile = AssemblyFileName;
            dcd.IgnoreOutsideRefs = false;
            dcd.Execute();
            tdg.LoadClassDependencies(dcd, true);
            this._graph = tdg.CondenseGraph();

            WritePDBasXML pdbxmlWritterTask = new WritePDBasXML();
            pdbxmlWritterTask.AssemblyName = new TaskItem(this.AssemblyFileName);

            if (pdbxmlWritterTask.Execute())
            {
                this._pDBDataFile = pdbxmlWritterTask.PDBAsXmlFile.ItemSpec;
                pdbXPathDoc = new XPathDocument(PDBDataFile);
                pdbNav = pdbXPathDoc.CreateNavigator();
            }

            Directory.CreateDirectory(OutputDirectory);
            foreach (CondensedVertex va in Graph.Vertices)
            {
                if (va.ImutableExternalType) continue;
                va.AssemblyName =  GetAssemblyName(va);
                if (va.AssemblyName.StartsWith("<"))
                    continue;

                va.AssemblyGUID = Guid.NewGuid();
                va.ProjectFile = va.AssemblyName + ".csproj"; // );//Path.Combine(OutputDirectory,
            }

            foreach (CondensedVertex vassem in Graph.Vertices)
            {
                CreateProjectFile(vassem);
            }

            CreateSolutionFile();
        }
        public void LoadClassDependencies(DetermineClassDeps dcd,bool treatExternalTypesAsSingleImutable)
        {
            foreach (TypeDefinition tdef in dcd.ClassDependencies.Keys)
            {
                string className = tdef.FullName;
                foreach (UsedClass uc in dcd.ClassDependencies[tdef])
                {
                    string refclassName = uc.Type.FullName;
                    if (!String.IsNullOrEmpty(_examininationNSN))
                    {
                        if (!
                            (
                            (tdef.FullName.StartsWith(_examininationNSP) || tdef.FullName.StartsWith(_examininationNSN)) &&
                            (uc.Type.FullName.StartsWith(_examininationNSN) || uc.Type.FullName.StartsWith(_examininationNSP))
                            ))
                            continue;
                    }

                    TypeVertex usingVertex = GetVertex(tdef, className,dcd);
                    TypeVertex refVertex = GetVertex(uc.Type, refclassName,dcd);

                    if (AllowParallel || !this.ContainsEdge(usingVertex, refVertex))
                    {
                        NamedEdge edge = (NamedEdge)this.AddEdge(usingVertex, refVertex);
                        edge.Name = uc.Use.ToString();
                    }
                }
            }
        }
 private TypeVertex GetVertex(TypeReference tref, string className,DetermineClassDeps dcd)
 {
     TypeVertex V;
     if (dcd.IsExternalType(tref))
         className = DetermineClassDeps.AssemblyNameofType(tref);
     if (classMap.ContainsKey(className))
     {
         V = classMap[className];
     }
     else
     {
         V = (TypeVertex)this.AddVertex();
         V.Name = className;
         V.TypeRef = tref;
         if (dcd.IsExternalType(tref))
             V.ImutableExternalType = true;
         classMap[className] = V;
     }
     return V;
 }