public void IncrementalCrawler_Basic()
        {
            RoslynCompilationCrawler rcc = new RoslynCompilationCrawler();

            rcc.IncludeCodeLocations = false;
            rcc.IncludeMembers       = false;

            CrawlCounter counter = new CrawlCounter(rcc);

            // Walk. Verify at least three binaries were found (Elfie, Elfie.Indexer, Elfie.Test)
            IncrementalCrawler ic = new IncrementalCrawler(counter);
            PackageDatabase    db = ic.Walk(".");

            Assert.IsTrue(counter.Count >= 3);

            db.ConvertToImmutable();

            DateTime utcNow = DateTime.UtcNow;

            // Walk again. Verify nothing is new.
            counter.Count = 0;
            ic            = new IncrementalCrawler(counter, db, utcNow);
            PackageDatabase rebuild = ic.Walk(".");

            Assert.AreEqual(0, counter.Count);
            Assert.AreEqual(db.MemberCount, rebuild.MemberCount);
        }
Exemplo n.º 2
0
        public static PackageDatabase Index(IndexOptions arguments)
        {
            PackageIdentity identity = new PackageIdentity(arguments.PackageName ?? Path.GetFileName(arguments.PathToIndex))
            {
                ReleaseName = arguments.ReleaseName, DownloadCount = arguments.DownloadCount, ProjectUrl = arguments.ProjectUrl
            };

            PackageDatabase db;

            using (new TraceWatch("{0} Indexing '{1}'...", (arguments.IsFull ? "Full" : ""), arguments.PathToIndex))
            {
                // TODO: Make this configurable until SrmCrawler is all we want
                //SrmCrawler crawler = new SrmCrawler();
                RoslynCompilationCrawler crawler = new RoslynCompilationCrawler();

                if (arguments.IsFull == false)
                {
                    crawler.IncludeNonPublicMembers = false;
                    //crawler.IncludeCodeLocations = false;
                    //crawler.IncludeSignatures = false;
                    //crawler.IncludeMembers = false;
                }

                crawler.IncludeFrameworkTargets = arguments.IncludeFrameworkTargets;

                IncrementalCrawler ic = new IncrementalCrawler(crawler, arguments.PreviousDatabase, arguments.PreviousDatabaseWriteTimeUtc);
                ic.IncludeSymbolCacheIndices = arguments.IncludeSymbolCacheIndices;
                db = ic.Walk(arguments.PathToIndex, identity);
            }

            int locatedMemberCount = db.LocatedMemberCount;
            int totalMemberCount   = db.MemberCount;

            Trace.WriteLine(String.Format(
                                "Done. Database is {0:n0} types, {1:n0} members, {2:p0} located [{3}]\r\n\tsymbols: {4},\r\n\tfiles: {5},\r\n\tstrings: {6},\r\n\tindex: {7}.\r\n",
                                db.TypeCount,
                                db.MemberCount,
                                locatedMemberCount / (double)totalMemberCount,
                                db.Bytes.SizeString(),
                                db.SymbolStatistics.ToStatisticsString(),
                                db.FileStatistics.ToStatisticsString(),
                                db.StringStatistics.ToStatisticsString(),
                                db.IndexStatistics.ToStatisticsString()
                                ));

            if (locatedMemberCount < totalMemberCount)
            {
                using (new TraceWatch("Improving locations with syntax parse..."))
                {
                    RoslynSyntaxLocationExpander expander = new RoslynSyntaxLocationExpander();
                    expander.AddLocations(db);
                }

                Trace.WriteLine(String.Format("Done. {0:p0} located.\r\n", db.LocatedMemberCount / (double)totalMemberCount));
            }

            return(db);
        }