Example #1
0
        public bool CanProcessorIncremental(IDocumentProcessor processor)
        {
            if (!CanVersionIncremental)
            {
                IncrementalInfo.ReportProcessorStatus(processor.Name, false);
                return(false);
            }

            var cpi = CurrentBuildVersionInfo.Processors.Find(p => p.Name == processor.Name);

            if (cpi == null)
            {
                string message = $"Current BuildVersionInfo missed processor info for {processor.Name}.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogWarning(message);
                return(false);
            }
            var lpi = LastBuildVersionInfo.Processors.Find(p => p.Name == processor.Name);

            if (lpi == null)
            {
                string message = $"Processor {processor.Name} disable incremental build because last build doesn't contain version {Version}.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (cpi.IncrementalContextHash != lpi.IncrementalContextHash)
            {
                string message = $"Processor {processor.Name} disable incremental build because incremental context hash changed.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            if (cpi.Steps.Count != lpi.Steps.Count)
            {
                string message = $"Processor {processor.Name} disable incremental build because steps count is different.";
                IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                Logger.LogVerbose(message);
                return(false);
            }
            for (int i = 0; i < cpi.Steps.Count; i++)
            {
                if (!object.Equals(cpi.Steps[i], lpi.Steps[i]))
                {
                    string message = $"Processor {processor.Name} disable incremental build because steps changed, from step {lpi.Steps[i].ToJsonString()} to {cpi.Steps[i].ToJsonString()}.";
                    IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
                    Logger.LogVerbose(message);
                    return(false);
                }
            }
            IncrementalInfo.ReportProcessorStatus(processor.Name, true);
            Logger.LogVerbose($"Processor {processor.Name} enable incremental build.");
            return(true);
        }
Example #2
0
 public bool ShouldProcessorTraceInfo(IDocumentProcessor processor)
 {
     if (!(processor is ISupportIncrementalDocumentProcessor))
     {
         string message = $"Processor {processor.Name} cannot suppport incremental build because the processor doesn't implement {nameof(ISupportIncrementalDocumentProcessor)} interface.";
         IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
         Logger.LogVerbose(message);
         return(false);
     }
     if (!processor.BuildSteps.All(step => step is ISupportIncrementalBuildStep))
     {
         string message = $"Processor {processor.Name} cannot suppport incremental build because the following steps don't implement {nameof(ISupportIncrementalBuildStep)} interface: {string.Join(",", processor.BuildSteps.Where(step => !(step is ISupportIncrementalBuildStep)).Select(s => s.Name))}.";
         IncrementalInfo.ReportProcessorStatus(processor.Name, false, message);
         Logger.LogVerbose(message);
         return(false);
     }
     return(true);
 }