Esempio n. 1
0
        /// <summary>
        /// Creates a class report.
        /// </summary>
        /// <param name="class">The class.</param>
        /// <param name="fileAnalyses">The file analyses that correspond to the class.</param>
        public override void CreateClassReport(Class @class, IEnumerable <FileAnalysis> fileAnalyses)
        {
            Parallel.ForEach(fileAnalyses, fileAnalysis =>
            {
                if (string.IsNullOrEmpty(fileAnalysis.Error))
                {
                    using (var renderer = new HtmlRenderer(false, HtmlMode.InlineCssAndJavaScript))
                    {
                        var codeFile     = @class.Files.First(f => f.Path.Equals(fileAnalysis.Path));
                        string localPath = HtmlRenderer.GetFileReportFilename(codeFile.Path);

                        bool shouldGenerateReport;
                        lock (RenderedCodeFiles)
                        {
                            shouldGenerateReport = RenderedCodeFiles.Add(localPath);
                        }

                        if (shouldGenerateReport)
                        {
                            this.CreateFileReport(renderer, codeFile, fileAnalysis);
                        }
                    }
                }
            });
        }
Esempio n. 2
0
        private void PostProcessParserResult(ParserResult parserResult)
        {
            var filesMap = new Dictionary <string, List <CodeFile> >();

            foreach (Assembly a in parserResult.Assemblies)
            {
                foreach (Class c in a.Classes)
                {
                    foreach (CodeFile codeFile in c.Files)
                    {
                        string localPath = HtmlRenderer.GetFileReportFilename(codeFile.Path);
                        if (filesMap.TryGetValue(localPath, out var prevValues))
                        {
                            // merge new copy with last, and push the most complete in the end
                            codeFile.Merge(prevValues.Last());
                            prevValues.Add(codeFile);
                        }
                        else
                        {
                            filesMap.Add(localPath, new List <CodeFile> {
                                codeFile
                            });
                        }
                    }
                }
            }

            // now merge everything
            foreach (var codeFiles in filesMap.Values)
            {
                if (codeFiles.Count > 1)
                {
                    var fullInfo = codeFiles.Last();
                    codeFiles.RemoveAt(codeFiles.Count - 1);
                    foreach (var file in codeFiles)
                    {
                        file.Merge(fullInfo);
                    }
                }
            }
        }