Esempio n. 1
0
 public CommentsWalker(string fileName, LocationStore commentLocationStore,
                       CommentStore commentStore, ClassStore classStore)
     : base(SyntaxWalkerDepth.StructuredTrivia)
 {
     _fileName             = fileName;
     _commentLocationStore = commentLocationStore;
     _commentStore         = commentStore;
     _classStore           = classStore;
 }
Esempio n. 2
0
        public void Write(CommentStore commentStore, ClassStore classStore)
        {
            using (ExcelPackage package = new ExcelPackage(_file))
            {
                new CommentsWorksheet(package, commentStore).Create("Comments");
                Console.WriteLine("Generated comments worksheet");
                new ClassesWorksheet(package, classStore).Create("Classes");
                Console.WriteLine("Generated classes worksheet");
                new ClassesWithMostSmellsWorksheet(package, classStore).Create("ClassesWithMostSmells");
                Console.WriteLine("Generated classes with most smells worksheet");
                new ClassesWithMostComments(package, classStore).Create("ClassesWithMostComments");
                Console.WriteLine("Generated classes with most comments worksheet");

                package.Save();
            }
        }
Esempio n. 3
0
        //static string folderName = "EntityFrameworkCore";
        //static string designiteFileName = "Designite_EFCore.xls";
        //static string solutionName = "EFCore";

        //static string folderName = "ScreenToGif";
        //static string designiteFileName = "Designite_GifRecorder.xls";
        //static string solutionName = "GifRecorder";

        static void Main(string[] args)
        {
            SmellsStore.Initialize($@"../../../../DesigniteResults/{designiteFileName}", solutionName);

            string                  fileContent;
            SyntaxTree              tree;
            SyntaxNode              root;
            CommentsWalker          commentsWalker;
            MethodsAndClassesWalker methodsAndClassesWalker;

            string[] files = Directory.GetFiles($@"../../../../Projects/{folderName}", $"*.cs", SearchOption.AllDirectories)
                             .Where(s => !s.EndsWith(".designer.cs", StringComparison.InvariantCultureIgnoreCase)).ToArray();
            var commentStore = new CommentStore();
            var classStore   = new ClassStore();

            Console.WriteLine("Reading files...");
            ProgressBar progressBar = new ProgressBar(files.Length);

            foreach (var file in files)
            {
                fileContent = File.ReadAllText(file);
                fileContent = TransformSingleLineComments(fileContent);

                tree = CSharpSyntaxTree.ParseText(fileContent);
                root = tree.GetRoot();
                var    locationStore = new LocationStore();
                string filePath      = new Regex($@"{folderName}\\(.*)").Match(file).Groups[1].ToString();

                methodsAndClassesWalker = new MethodsAndClassesWalker(filePath, locationStore, classStore);
                methodsAndClassesWalker.Visit(root);
                commentsWalker = new CommentsWalker(filePath, locationStore, commentStore, classStore);
                commentsWalker.Visit(root);

                progressBar.UpdateAndDisplay();
            }

            Console.WriteLine("\nCreating excel file...");

            ExcelWriter excelWriter = new ExcelWriter($"{solutionName}_comments.xlsx");

            excelWriter.Write(commentStore, classStore);

            Console.WriteLine("Finished");
            Console.ReadKey();
        }
Esempio n. 4
0
 public CommentsWorksheet(ExcelPackage package, CommentStore commentStore) : base(package)
 {
     _commentStore = commentStore;
 }