Esempio n. 1
0
 private void HandleCollectedMethods(ILParser ilParser)
 {
     Console.WriteLine("Parsing IL... ({0} methods){1}", collectedMethods.Count, Environment.NewLine);
     // dive into methods and collect, what they reference
     for (var i = 0; i < collectedMethods.Count; i++)
     {
         var method = collectedMethods[i];
         CollectReferencesFromILCode(ilParser, method.Method, method.MethodId, method.ClassId);
     }
 }
Esempio n. 2
0
        public void Index(string outputFileName)
        {
            // create the Sourcetrail data collector
            var dataCollector = new DataCollector(outputFileName);

            var pdbLocator = new PdbLocator();
            // set up the type handler
            var typeHandler = new TypeHandler(assemblies, nameFilter, namespaceFollowFilter, dataCollector, pdbLocator);

            typeHandler.MethodCollected += (sender, args) => collectedMethods.Add(args.CollectedMethod);

            foreach (var assembly in assemblies)
            {
                Console.WriteLine("Indexing assembly {0}{1}", assembly.Location, Environment.NewLine);

                pdbLocator.AddAssembly(assembly);
                try
                {
                    Console.WriteLine("Collecting types...");
                    // collect all types first
                    foreach (var type in assembly.GetTypes())
                    {
                        typeHandler.AddToDbIfValid(type);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception indexing assemby '{0}'\r\n{1}", assembly.Location, ex);
                }
            }

            Console.WriteLine("{1}Collected {0} types{1}", Cache.CollectedTypes.Count, Environment.NewLine);

            // set up the visitor for parsed methods
            var referenceVisitor = new MethodReferenceVisitor(typeHandler, dataCollector, pdbLocator);
            var ilParser         = new ILParser(referenceVisitor);

            referenceVisitor.ParseMethod += (sender, args) => CollectReferencesFromILCode(
                ilParser,
                args.CollectedMethod.Method, args.CollectedMethod.MethodId, args.CollectedMethod.ClassId);
            // parse IL of colected methods
            HandleCollectedMethods(ilParser);

            dataCollector.Dispose();
        }
Esempio n. 3
0
 private void CollectReferencesFromILCode(ILParser ilParser, MethodBase method, int methodId, int classId)
 {
     ilParser.Parse(method, methodId, classId);
 }