コード例 #1
0
        public void WhenCallingLogErrorShouldCallMSBuildLogError()
        {
            var buildEngineMock = new Mock<IBuildEngine>();

            var taskMock = new Mock<ITask>();
            taskMock.Setup(t => t.BuildEngine).Returns(buildEngineMock.Object);
            var helper = new TaskLoggingHelper(taskMock.Object);
            var logger = new MSBuildLogger(helper);

            logger.LogError("Error");
        }
コード例 #2
0
        /// <summary>
        /// Called from MSBuild when the task executes
        /// </summary>
        /// <returns>boolean indicating if the execution was sucessful</returns>
        public override bool Execute()
        {
            try
            {
                TaskMetricList ml = ParseMetrics();

                var logger = new MSBuildLogger(Log);
                var processExecutor = new ProcessExecutor(logger);
                CodeMetricsRunner runner = new CodeMetricsRunner(logger);
                RegisterProviders(runner, logger, processExecutor);
                ValidateMetricsList(runner, ml);

                runner.ComputeMetrics(ml.ToComputeMetricsParameterList());
                var report = GenerateReport(runner, ml);
                RunBuildFailChecks(report, ml);
                return true;
            }
            catch (MSBuildCodeMetricsTaskException e)
            {
                Log.LogError(e.Message);
                return false;
            }
        }