Ejemplo n.º 1
0
        /// <summary>
        /// Creates a report from a MsBuild logfile.
        /// </summary>
        /// <param name="fileSystem">Cake file system instance.</param>
        /// <param name="logFile">Path of the MsBuild logfile.</param>
        /// <param name="report">Type of report which should be created.</param>
        /// <param name="outputFile">Path of the generated report file.</param>
        public static void CreateCodeAnalysisReport(
            IFileSystem fileSystem,
            FilePath logFile,
            CodeAnalysisReport report,
            FilePath outputFile)
        {
            fileSystem.NotNull(nameof(fileSystem));
            logFile.NotNull(nameof(logFile));
            report.NotUndefined(nameof(report));
            outputFile.NotNull(nameof(outputFile));

            var xmlFile    = fileSystem.GetFile(logFile);
            var resultFile = fileSystem.GetFile(outputFile);

            using (Stream
                   xmlStream = xmlFile.OpenRead(),
                   resultStream = resultFile.OpenWrite())
            {
                var xslReader = XmlReader.Create(new StringReader(EmbeddedResourceHelper.GetReportStyleSheet(report.GetStyleSheetResourceName())));
                var xmlReader = XmlReader.Create(xmlStream);

                var resultWriter =
                    XmlWriter.Create(
                        resultStream,
                        GetSettings());

                Transform(xslReader, xmlReader, resultWriter);
            }
        }
        public static void CreateMsBuildCodeAnalysisReport(
            this ICakeContext context,
            FilePath logFile,
            CodeAnalysisReport report,
            FilePath outputFile)
        {
            context.NotNull(nameof(context));
            logFile.NotNull(nameof(logFile));
            report.NotUndefined(nameof(report));
            outputFile.NotNull(nameof(outputFile));

            MsBuildCodeAnalysisReporter.CreateCodeAnalysisReport(
                context.FileSystem,
                logFile,
                report,
                outputFile);
        }