protected internal virtual bool ComputeOutOfDateSources()
 {
     if (this.MinimalRebuildFromTracking || this.TrackFileAccess)
     {
         this.AssignDefaultTLogPaths();
     }
     if (!this.MinimalRebuildFromTracking || this.ForcedRebuildRequired())
     {
         this.SourcesCompiled = this.TrackedInputFiles;
         if ((this.SourcesCompiled == null) || (this.SourcesCompiled.Length == 0))
         {
             this.SkippedExecution = true;
             return(this.SkippedExecution);
         }
     }
     else
     {
         this.sourceOutputs      = new CanonicalTrackedOutputFiles(this, this.TLogWriteFiles);
         this.sourceDependencies = new CanonicalTrackedInputFiles(this, this.TLogReadFiles, this.TrackedInputFiles, this.ExcludedInputPaths, this.sourceOutputs, this.UseMinimalRebuildOptimization, this.MaintainCompositeRootingMarkers);
         ITaskItem[] sourcesOutOfDateThroughTracking = this.SourceDependencies.ComputeSourcesNeedingCompilation(false);
         this.SourcesCompiled = this.MergeOutOfDateSourceLists(sourcesOutOfDateThroughTracking, this.GenerateSourcesOutOfDateDueToCommandLine());
         if (this.SourcesCompiled.Length == 0)
         {
             this.SkippedExecution = true;
             return(this.SkippedExecution);
         }
         this.SourcesCompiled = this.AssignOutOfDateSources(this.SourcesCompiled);
         this.SourceDependencies.RemoveEntriesForSource(this.SourcesCompiled);
         this.SourceDependencies.SaveTlog();
         if (this.DeleteOutputOnExecute)
         {
             DeleteFiles(this.sourceOutputs.OutputsForSource(this.SourcesCompiled, false));
         }
         this.sourceOutputs.RemoveEntriesForSource(this.SourcesCompiled);
         this.sourceOutputs.SaveTlog();
     }
     if ((this.TrackFileAccess || this.TrackCommandLines) && string.IsNullOrEmpty(this.RootSource))
     {
         this.RootSource = FileTracker.FormatRootingMarker(this.SourcesCompiled);
     }
     this.SkippedExecution = false;
     return(this.SkippedExecution);
 }
        protected int TrackerExecuteTool(string pathToTool, string responseFileCommands, string commandLineCommands)
        {
            string filePath    = Environment.ExpandEnvironmentVariables(pathToTool);
            string arguments   = Environment.ExpandEnvironmentVariables(commandLineCommands);
            string tmpFilePath = null;

            try
            {
                string trackerPath;
                string dllName = null;
                this.pathToLog = filePath;

                bool trackFileAccess = this.TrackFileAccess;

                if (trackFileAccess)
                {
                    try
                    {
                        trackerPath = FileTracker.GetTrackerPath(this.TrackerSdkPath);
                        if (trackerPath == null)
                        {
                            object[] messageArgs = new object[] { "tracker.exe" };
                            base.Log.LogErrorFromResources("Error.MissingFile", messageArgs);
                        }
                    }
                    catch (Exception exception1)
                    {
                        if (ExceptionHandling.NotExpectedException(exception1))
                        {
                            throw;
                        }
                        object[] messageArgs = new object[] { "TrackerSdkPath", base.GetType().Name };
                        base.Log.LogErrorWithCodeFromResources("General.InvalidValue", messageArgs);
                        return(-1);
                    }

                    try
                    {
                        dllName = FileTracker.GetFileTrackerPath(this.TrackerFrameworkPath);
                    }
                    catch (Exception exception3)
                    {
                        if (ExceptionHandling.NotExpectedException(exception3))
                        {
                            throw;
                        }
                        object[] messageArgs = new object[] { "TrackerFrameworkPath", base.GetType().Name };
                        base.Log.LogErrorWithCodeFromResources("General.InvalidValue", messageArgs);
                        return(-1);
                    }
                }
                else
                {
                    trackerPath = filePath;
                }

                if (string.IsNullOrEmpty(trackerPath))
                {
                    return(-1);
                }

                {
                    ErrorUtilities.VerifyThrowInternalRooted(trackerPath);

                    string trackerArguments;

                    if (trackFileAccess)
                    {
                        string strrsp = FileTracker.TrackerResponseFileArguments(dllName, this.TrackerIntermediateDirectory, this.RootSource, base.CancelEventName);
                        string strcmd = FileTracker.TrackerCommandArguments(filePath, arguments);

                        base.Log.LogMessageFromResources(MessageImportance.Low, "Native_TrackingCommandMessage");
                        base.Log.LogMessage(MessageImportance.Low, trackerPath + (this.AttributeFileTracking ? " /a " : " ") + (this.TrackReplaceFile ? "/f " : "") + (strrsp + strcmd) + " " + responseFileCommands);

                        tmpFilePath = FileUtilities.GetTemporaryFile();
                        using (StreamWriter writer = new StreamWriter(tmpFilePath, false, Encoding.Unicode))
                        {
                            writer.Write(strrsp);
                        }

                        trackerArguments = (this.AttributeFileTracking ? "/a @\"" : "@\"") + tmpFilePath + "\"" + (this.TrackReplaceFile ? " /f " : "") + strcmd;
                    }
                    else
                    {
                        trackerArguments = arguments;
                    }

                    //**ClangCompile::Execute** //Not Implement //Instantiate by Reflection
                    //=>TrackedVCToolTask::Execute
                    //=>VCToolTask::Execute
                    //=>ToolTask::Execute
                    //=>ClangCompile::ExecuteTool //virtual -> override
                    //=>TrackedVCToolTask::ExecuteTool //Tracker.exe
                    //=>ToolTask::ExecuteTool //StartProcess
                    return(base.ExecuteTool(trackerPath, responseFileCommands, trackerArguments));
                }
            }
            finally
            {
                if (tmpFilePath != null)
                {
                    base.DeleteTempFile(tmpFilePath);
                }
            }
        }
 protected virtual int PostExecuteTool(int exitCode)
 {
     if (this.MinimalRebuildFromTracking || this.TrackFileAccess)
     {
         this.SourceOutputs      = new CanonicalTrackedOutputFiles(this.TLogWriteFiles);
         this.SourceDependencies = new CanonicalTrackedInputFiles(this.TLogReadFiles, this.TrackedInputFiles, this.ExcludedInputPaths, this.SourceOutputs, false, this.MaintainCompositeRootingMarkers);
         string[] strArray = null;
         IDictionary <string, string> sourcesToCommandLines = this.MapSourcesToCommandLines();
         if (exitCode != 0)
         {
             this.SourceOutputs.RemoveEntriesForSource(this.SourcesCompiled);
             this.SourceOutputs.SaveTlog();
             this.SourceDependencies.RemoveEntriesForSource(this.SourcesCompiled);
             this.SourceDependencies.SaveTlog();
             if (this.TrackCommandLines)
             {
                 if (this.MaintainCompositeRootingMarkers)
                 {
                     sourcesToCommandLines.Remove(this.RootSource);
                 }
                 else
                 {
                     foreach (ITaskItem item in this.SourcesCompiled)
                     {
                         sourcesToCommandLines.Remove(FileTracker.FormatRootingMarker(item));
                     }
                 }
                 this.WriteSourcesToCommandLinesTable(sourcesToCommandLines);
             }
         }
         else
         {
             this.AddTaskSpecificOutputs(this.SourcesCompiled, this.SourceOutputs);
             this.RemoveTaskSpecificOutputs(this.SourceOutputs);
             this.SourceOutputs.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled);
             if (this.MaintainCompositeRootingMarkers)
             {
                 strArray = this.SourceOutputs.RemoveRootsWithSharedOutputs(this.SourcesCompiled);
                 foreach (string str in strArray)
                 {
                     this.SourceDependencies.RemoveEntryForSourceRoot(str);
                 }
             }
             if ((this.TrackedOutputFilesToIgnore == null) || (this.TrackedOutputFilesToIgnore.Length == 0))
             {
                 this.SourceOutputs.SaveTlog();
             }
             else
             {
                 Dictionary <string, ITaskItem> trackedOutputFilesToRemove = new Dictionary <string, ITaskItem>(StringComparer.OrdinalIgnoreCase);
                 ITaskItem[] trackedOutputFilesToIgnore = this.TrackedOutputFilesToIgnore;
                 int         index = 0;
                 while (true)
                 {
                     if (index >= trackedOutputFilesToIgnore.Length)
                     {
                         this.SourceOutputs.SaveTlog(fullTrackedPath => !trackedOutputFilesToRemove.ContainsKey(fullTrackedPath.ToUpperInvariant()));
                         break;
                     }
                     ITaskItem item2 = trackedOutputFilesToIgnore[index];
                     string    key   = item2.GetMetadata("FullPath").ToUpperInvariant();
                     if (!trackedOutputFilesToRemove.ContainsKey(key))
                     {
                         trackedOutputFilesToRemove.Add(key, item2);
                     }
                     index++;
                 }
             }
             DeleteEmptyFile(this.TLogWriteFiles);
             this.RemoveTaskSpecificInputs(this.SourceDependencies);
             this.SourceDependencies.RemoveDependenciesFromEntryIfMissing(this.SourcesCompiled);
             if ((this.TrackedInputFilesToIgnore == null) || (this.TrackedInputFilesToIgnore.Length == 0))
             {
                 this.SourceDependencies.SaveTlog();
             }
             else
             {
                 Dictionary <string, ITaskItem> trackedInputFilesToRemove = new Dictionary <string, ITaskItem>(StringComparer.OrdinalIgnoreCase);
                 ITaskItem[] trackedInputFilesToIgnore = this.TrackedInputFilesToIgnore;
                 int         index = 0;
                 while (true)
                 {
                     if (index >= trackedInputFilesToIgnore.Length)
                     {
                         this.SourceDependencies.SaveTlog(fullTrackedPath => !trackedInputFilesToRemove.ContainsKey(fullTrackedPath));
                         break;
                     }
                     ITaskItem item3 = trackedInputFilesToIgnore[index];
                     string    key   = item3.GetMetadata("FullPath").ToUpperInvariant();
                     if (!trackedInputFilesToRemove.ContainsKey(key))
                     {
                         trackedInputFilesToRemove.Add(key, item3);
                     }
                     index++;
                 }
             }
             DeleteEmptyFile(this.TLogReadFiles);
             if (this.TrackCommandLines)
             {
                 if (!this.MaintainCompositeRootingMarkers)
                 {
                     string   str6             = this.SourcesPropertyName ?? "Sources";
                     string[] switchesToRemove = new string[] { str6 };
                     string   str7             = base.GenerateCommandLineExceptSwitches(switchesToRemove, VCToolTask.CommandLineFormat.ForTracking, VCToolTask.EscapeFormat.Default);
                     foreach (ITaskItem item4 in this.SourcesCompiled)
                     {
                         sourcesToCommandLines[FileTracker.FormatRootingMarker(item4)] = str7 + " " + item4.GetMetadata("FullPath").ToUpperInvariant();
                     }
                 }
                 else
                 {
                     string str4 = base.GenerateCommandLine(VCToolTask.CommandLineFormat.ForTracking, VCToolTask.EscapeFormat.Default);
                     sourcesToCommandLines[this.RootSource] = str4;
                     if (strArray != null)
                     {
                         foreach (string str5 in strArray)
                         {
                             sourcesToCommandLines.Remove(str5);
                         }
                     }
                 }
                 this.WriteSourcesToCommandLinesTable(sourcesToCommandLines);
             }
         }
     }
     return(exitCode);
 }
        protected virtual List <ITaskItem> GenerateSourcesOutOfDateDueToCommandLine()
        {
            IDictionary <string, string> dictionary = this.MapSourcesToCommandLines();
            List <ITaskItem>             list       = new List <ITaskItem>();

            if (this.TrackCommandLines)
            {
                if (dictionary.Count == 0)
                {
                    foreach (ITaskItem item in this.TrackedInputFiles)
                    {
                        list.Add(item);
                    }
                }
                else if (!this.MaintainCompositeRootingMarkers)
                {
                    string   str3             = this.SourcesPropertyName ?? "Sources";
                    string[] switchesToRemove = new string[] { str3 };
                    string   str4             = base.GenerateCommandLineExceptSwitches(switchesToRemove, VCToolTask.CommandLineFormat.ForTracking, VCToolTask.EscapeFormat.Default);
                    foreach (ITaskItem item4 in this.TrackedInputFiles)
                    {
                        string str5 = this.ApplyPrecompareCommandFilter(str4 + " " + item4.GetMetadata("FullPath").ToUpperInvariant());
                        string str6 = null;
                        if (!dictionary.TryGetValue(FileTracker.FormatRootingMarker(item4), out str6))
                        {
                            list.Add(item4);
                        }
                        else
                        {
                            str6 = this.ApplyPrecompareCommandFilter(str6);
                            if ((str6 == null) || !str5.Equals(str6, StringComparison.Ordinal))
                            {
                                list.Add(item4);
                            }
                        }
                    }
                }
                else
                {
                    string str  = this.ApplyPrecompareCommandFilter(base.GenerateCommandLine(VCToolTask.CommandLineFormat.ForTracking, VCToolTask.EscapeFormat.Default));
                    string str2 = null;
                    if (!dictionary.TryGetValue(FileTracker.FormatRootingMarker(this.TrackedInputFiles), out str2))
                    {
                        foreach (ITaskItem item3 in this.TrackedInputFiles)
                        {
                            list.Add(item3);
                        }
                    }
                    else
                    {
                        str2 = this.ApplyPrecompareCommandFilter(str2);
                        if ((str2 == null) || !str.Equals(str2, StringComparison.Ordinal))
                        {
                            foreach (ITaskItem item2 in this.TrackedInputFiles)
                            {
                                list.Add(item2);
                            }
                        }
                    }
                }
            }
            return(list);
        }