/// <summary>
        /// Deserializes an instance of <see cref="SandboxedProcessOutput"/>.
        /// </summary>
        public static SandboxedProcessOutput Deserialize(BuildXLReader reader)
        {
            long     length   = reader.ReadInt64();
            string   value    = reader.ReadNullableString();
            string   fileName = reader.ReadNullableString();
            Encoding encoding = reader.ReadEncoding();
            SandboxedProcessStandardFiles standardFiles = reader.ReadNullable(r => SandboxedProcessStandardFiles.Deserialize(r));
            ISandboxedProcessFileStorage  fileStorage   = null;

            if (standardFiles != null)
            {
                fileStorage = new StandardFileStorage(standardFiles);
            }
            SandboxedProcessFile file      = (SandboxedProcessFile)reader.ReadUInt32Compact();
            BuildXLException     exception = reader.ReadNullable(r => new BuildXLException(r.ReadNullableString(), (ExceptionRootCause)r.ReadUInt32Compact()));

            return(new SandboxedProcessOutput(
                       length,
                       value,
                       fileName,
                       encoding,
                       fileStorage,
                       file,
                       exception));
        }
        /// <summary>
        /// Create generic result for failure.
        /// </summary>
        protected SandboxedProcessResult CreateResultForFailure(
            int exitCode,
            bool killed,
            bool timedOut,
            string output,
            string error,
            string hint)
        {
            var standardFiles = new SandboxedProcessStandardFiles(GetStdOutPath(hint), GetStdErrPath(hint));
            var storage       = new StandardFileStorage(standardFiles);

            return(new SandboxedProcessResult
            {
                ExitCode = exitCode,
                Killed = killed,
                TimedOut = timedOut,
                HasDetoursInjectionFailures = false,
                StandardOutput = new SandboxedProcessOutput(output.Length, output, null, Console.OutputEncoding, storage, SandboxedProcessFile.StandardOutput, null),
                StandardError = new SandboxedProcessOutput(error.Length, error, null, Console.OutputEncoding, storage, SandboxedProcessFile.StandardError, null),
                HasReadWriteToReadFileAccessRequest = false,
                AllUnexpectedFileAccesses = EmptyFileAccessesSet,
                FileAccesses = EmptyFileAccessesSet,
                DetouringStatuses = new ProcessDetouringStatusData[0],
                ExplicitlyReportedFileAccesses = EmptyFileAccessesSet,
                Processes = new ReportedProcess[0],
                MessageProcessingFailure = null,
                DumpCreationException = DumpCreationException,
                DumpFileDirectory = WorkingDirectory,
                PrimaryProcessTimes = new ProcessTimes(0, 0, 0, 0),
                SurvivingChildProcesses = new ReportedProcess[0],
            });
        }
        private SandboxedProcessResult CreateResultForFailure()
        {
            string output        = m_output.ToString();
            string error         = m_error.ToString();
            string hint          = Path.GetFileNameWithoutExtension(m_toolPath);
            var    standardFiles = new SandboxedProcessStandardFiles(GetStdOutPath(hint), GetStdErrPath(hint));
            var    storage       = new StandardFileStorage(standardFiles);

            return(new SandboxedProcessResult
            {
                ExitCode = m_processExecutor.TimedOut ? ExitCodes.Timeout : Process.ExitCode,
                Killed = m_processExecutor.Killed,
                TimedOut = m_processExecutor.TimedOut,
                HasDetoursInjectionFailures = false,
                StandardOutput = new SandboxedProcessOutput(output.Length, output, null, Console.OutputEncoding, storage, SandboxedProcessFile.StandardOutput, null),
                StandardError = new SandboxedProcessOutput(error.Length, error, null, Console.OutputEncoding, storage, SandboxedProcessFile.StandardError, null),
                HasReadWriteToReadFileAccessRequest = false,
                AllUnexpectedFileAccesses = s_emptyFileAccessesSet,
                FileAccesses = s_emptyFileAccessesSet,
                DetouringStatuses = new ProcessDetouringStatusData[0],
                ExplicitlyReportedFileAccesses = s_emptyFileAccessesSet,
                Processes = new ReportedProcess[0],
                MessageProcessingFailure = null,
                DumpCreationException = m_dumpCreationException,
                DumpFileDirectory = GetOutputDirectory(),
                PrimaryProcessTimes = new ProcessTimes(0, 0, 0, 0),
                SurvivingChildProcesses = new ReportedProcess[0],
            });
        }