Beispiel #1
0
        internal OutOfProcTaskHostTaskResult(TaskCompleteType result, IDictionary <string, Object> finalParams, Exception taskException, string exceptionMessage, string[] exceptionMessageArgs)
        {
            // If we're returning a crashing result, we should always also be returning the exception that caused the crash, although
            // we may not always be returning an accompanying message.
            if (result == TaskCompleteType.CrashedDuringInitialization ||
                result == TaskCompleteType.CrashedDuringExecution ||
                result == TaskCompleteType.CrashedAfterExecution)
            {
                ErrorUtilities.VerifyThrowInternalNull(taskException, nameof(taskException));
            }

            if (exceptionMessage != null)
            {
                ErrorUtilities.VerifyThrow
                (
                    result == TaskCompleteType.CrashedDuringInitialization ||
                    result == TaskCompleteType.CrashedDuringExecution ||
                    result == TaskCompleteType.CrashedAfterExecution,
                    "If we have an exception message, the result type should be 'crashed' of some variety."
                );
            }

            if (exceptionMessageArgs?.Length > 0)
            {
                ErrorUtilities.VerifyThrow(exceptionMessage != null, "If we have message args, we need a message.");
            }

            Result = result;
            FinalParameterValues = finalParams;
            TaskException        = taskException;
            ExceptionMessage     = exceptionMessage;
            ExceptionMessageArgs = exceptionMessageArgs;
        }
Beispiel #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="result">Result of the task's execution.</param>
        /// <param name="buildProcessEnvironment">The build process environment as it was at the end of the task's execution.</param>
        public TaskHostTaskComplete(OutOfProcTaskHostTaskResult result, IDictionary <string, string> buildProcessEnvironment)
        {
            ErrorUtilities.VerifyThrowInternalNull(result, "result");

            _taskResult               = result.Result;
            _taskException            = result.TaskException;
            _taskExceptionMessage     = result.ExceptionMessage;
            _taskExceptionMessageArgs = result.ExceptionMessageArgs;

            if (result.FinalParameterValues != null)
            {
                _taskOutputParameters = new Dictionary <string, TaskParameter>(StringComparer.OrdinalIgnoreCase);
                foreach (KeyValuePair <string, object> parameter in result.FinalParameterValues)
                {
                    _taskOutputParameters[parameter.Key] = new TaskParameter(parameter.Value);
                }
            }

            if (buildProcessEnvironment != null)
            {
                _buildProcessEnvironment = buildProcessEnvironment as Dictionary <string, string>;

                if (_buildProcessEnvironment == null)
                {
                    _buildProcessEnvironment = new Dictionary <string, string>(buildProcessEnvironment);
                }
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        internal OutOfProcTaskHostTaskResult(TaskCompleteType result, IDictionary<string, Object> finalParams, Exception taskException, string exceptionMessage, string[] exceptionMessageArgs)
        {
            // If we're returning a crashing result, we should always also be returning the exception that caused the crash, although 
            // we may not always be returning an accompanying message. 
            if (result == TaskCompleteType.CrashedDuringInitialization ||
                result == TaskCompleteType.CrashedDuringExecution ||
                result == TaskCompleteType.CrashedAfterExecution)
            {
                ErrorUtilities.VerifyThrowInternalNull(taskException, "taskException");
            }

            if (exceptionMessage != null)
            {
                ErrorUtilities.VerifyThrow
                    (
                        result == TaskCompleteType.CrashedDuringInitialization ||
                        result == TaskCompleteType.CrashedDuringExecution ||
                        result == TaskCompleteType.CrashedAfterExecution,
                        "If we have an exception message, the result type should be 'crashed' of some variety."
                    );
            }

            if (exceptionMessageArgs != null && exceptionMessageArgs.Length > 0)
            {
                ErrorUtilities.VerifyThrow(exceptionMessage != null, "If we have message args, we need a message.");
            }

            Result = result;
            FinalParameterValues = finalParams;
            TaskException = taskException;
            ExceptionMessage = exceptionMessage;
            ExceptionMessageArgs = exceptionMessageArgs;
        }
        /// <summary>
        /// Helper method for testing invalid constructors
        /// </summary>
        private void AssertInvalidConstructorThrows(Type expectedExceptionType, TaskCompleteType taskResult, Exception taskException, string taskExceptionMessage, string[] taskExceptionMessageArgs, IDictionary <string, object> taskOutputParameters, IDictionary <string, string> buildProcessEnvironment)
        {
            bool exceptionCaught = false;

            try
            {
                TaskHostTaskComplete complete = new TaskHostTaskComplete(new OutOfProcTaskHostTaskResult(taskResult, taskOutputParameters, taskException, taskExceptionMessage, taskExceptionMessageArgs), buildProcessEnvironment);
            }
            catch (Exception e)
            {
                exceptionCaught = true;
                Assert.IsAssignableFrom(expectedExceptionType, e); // "Wrong exception was thrown!"
            }

            Assert.True(exceptionCaught); // "No exception was caught when one was expected!"
        }
 /// <summary>
 /// Constructor
 /// </summary>
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, Exception taskException, string exceptionMessage, string[] exceptionMessageArgs)
     : this(result, null /* no final parameters */, taskException, exceptionMessage, exceptionMessageArgs)
 {
     // do nothing else
 }
 /// <summary>
 /// Constructor
 /// </summary>
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, Exception taskException)
     : this(result, taskException, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
 /// <summary>
 /// Constructor
 /// </summary>
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, IDictionary<string, Object> finalParams)
     : this(result, finalParams, null /* no exception */, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
 /// <summary>
 /// Constructor 
 /// </summary>
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result)
     : this(result, null /* no final parameters */, null /* no exception */, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
        /// <summary>
        /// Helper method for testing invalid constructors
        /// </summary>
        private void AssertInvalidConstructorThrows(Type expectedExceptionType, TaskCompleteType taskResult, Exception taskException, string taskExceptionMessage, string[] taskExceptionMessageArgs, IDictionary<string, object> taskOutputParameters, IDictionary<string, string> buildProcessEnvironment)
        {
            bool exceptionCaught = false;

            try
            {
                TaskHostTaskComplete complete = new TaskHostTaskComplete(new OutOfProcTaskHostTaskResult(taskResult, taskOutputParameters, taskException, taskExceptionMessage, taskExceptionMessageArgs), buildProcessEnvironment);
            }
            catch (Exception e)
            {
                exceptionCaught = true;
                Assert.IsInstanceOfType(e, expectedExceptionType, "Wrong exception was thrown!");
            }

            Assert.IsTrue(exceptionCaught, "No exception was caught when one was expected!");
        }
Beispiel #10
0
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, Exception taskException, string exceptionMessage, string[] exceptionMessageArgs)
     : this(result, null /* no final parameters */, taskException, exceptionMessage, exceptionMessageArgs)
 {
     // do nothing else
 }
Beispiel #11
0
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, Exception taskException)
     : this(result, taskException, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
Beispiel #12
0
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result, IDictionary <string, Object> finalParams)
     : this(result, finalParams, null /* no exception */, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
Beispiel #13
0
 internal OutOfProcTaskHostTaskResult(TaskCompleteType result)
     : this(result, null /* no final parameters */, null /* no exception */, null /* no exception message */, null /* and no args to go with it */)
 {
     // do nothing else
 }
Beispiel #14
0
 public void InitTaskId(int id, TaskCompleteType type)
 {
     m_TaskId = id;
     taskType = type;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="result">Result of the task's execution.</param>
        /// <param name="buildProcessEnvironment">The build process environment as it was at the end of the task's execution.</param>
        public TaskHostTaskComplete(OutOfProcTaskHostTaskResult result, IDictionary<string, string> buildProcessEnvironment)
        {
            ErrorUtilities.VerifyThrowInternalNull(result, "result");

            _taskResult = result.Result;
            _taskException = result.TaskException;
            _taskExceptionMessage = result.ExceptionMessage;
            _taskExceptionMessageArgs = result.ExceptionMessageArgs;

            if (result.FinalParameterValues != null)
            {
                _taskOutputParameters = new Dictionary<string, TaskParameter>(StringComparer.OrdinalIgnoreCase);
                foreach (KeyValuePair<string, object> parameter in result.FinalParameterValues)
                {
                    _taskOutputParameters[parameter.Key] = new TaskParameter(parameter.Value);
                }
            }

            if (buildProcessEnvironment != null)
            {
                _buildProcessEnvironment = buildProcessEnvironment as Dictionary<string, string>;

                if (_buildProcessEnvironment == null)
                {
                    _buildProcessEnvironment = new Dictionary<string, string>(buildProcessEnvironment);
                }
            }
        }