Пример #1
0
        protected override void Run(bool success)
        {
            base.Run(success);

            Token.ThrowIfCancellationRequested();
            try
            {
                if (task.Status == TaskStatus.Created && !task.IsCompleted &&
                    ((task.CreationOptions & (TaskCreationOptions)512) == TaskCreationOptions.None))
                {
                    var scheduler = TaskManager.GetScheduler(Affinity);
                    Token.ThrowIfCancellationRequested();
                    task.RunSynchronously(scheduler);
                }
                else
                {
                    task.Wait();
                }
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
                Token.ThrowIfCancellationRequested();
            }
        }
Пример #2
0
        protected override T RunWithReturn(bool success)
        {
            T result = base.RunWithReturn(success);

            try
            {
                if (Callback != null)
                {
                    result = Callback(success);
                }
                else if (CallbackWithException != null)
                {
                    var thrown = GetThrownException();
                    result = CallbackWithException(success, thrown);
                }
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(result);
        }
Пример #3
0
 /// <summary>
 /// Pretty prints a QueryResult into an english representation.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     if (ThrownException == null)
     {
         return(ResultMessage + " " + RetrievedData);
     }
     else
     {
         return(ResultMessage + " with Exception : " + ThrownException.ToString());
     }
 }
Пример #4
0
        protected override T RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            wrapper = new ProcessWrapper(Name, Process, outputProcessor,
                                         () => OnStartProcess?.Invoke(this),
                                         () =>
            {
                try
                {
                    if (outputProcessor != null)
                    {
                        result = outputProcessor.Result;
                    }

                    if (typeof(T) == typeof(string) && result == null && !Process.StartInfo.CreateNoWindow)
                    {
                        result = (T)(object)"Process running";
                    }

                    if (!String.IsNullOrEmpty(Errors))
                    {
                        OnErrorData?.Invoke(Errors);
                    }
                }
                catch (Exception ex)
                {
                    if (thrownException == null)
                    {
                        thrownException = new ProcessException(ex.Message, ex);
                    }
                    else
                    {
                        thrownException = new ProcessException(thrownException.GetExceptionMessage(), ex);
                    }
                }

                if (thrownException != null && !RaiseFaultHandlers(thrownException))
                {
                    ThrownException.Rethrow();
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);

            wrapper.Run();

            return(result);
        }
Пример #5
0
        protected override List <T> RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            wrapper = new ProcessWrapper(Name, Process, outputProcessor,
                                         () => OnStartProcess?.Invoke(this),
                                         () =>
            {
                try
                {
                    if (outputProcessor != null)
                    {
                        result = outputProcessor.Result;
                    }
                    if (result == null)
                    {
                        result = new List <T>();
                    }

                    if (!String.IsNullOrEmpty(Errors))
                    {
                        OnErrorData?.Invoke(Errors);
                    }
                }
                catch (Exception ex)
                {
                    if (thrownException == null)
                    {
                        thrownException = new ProcessException(ex.Message, ex);
                    }
                    else
                    {
                        thrownException = new ProcessException(thrownException.GetExceptionMessage(), ex);
                    }
                }

                if (thrownException != null && !RaiseFaultHandlers(thrownException))
                {
                    ThrownException.Rethrow();
                }
            },
                                         (ex, error) =>
            {
                thrownException = ex;
                Errors          = error;
            },
                                         Token);
            wrapper.Run();

            return(result);
        }
Пример #6
0
        protected override NPath RunWithReturn(bool success)
        {
            var ret = BaseRun(success);

            try
            {
                ret = RunUnzip(success);
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(ret);
        }
Пример #7
0
        protected override GitInstallationState RunWithReturn(bool success)
        {
            var ret = base.RunWithReturn(success);

            try
            {
                ret = SetupGitIfNeeded();
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(ret);
        }
Пример #8
0
        protected override NPath RunWithReturn(bool success)
        {
            var result = base.RunWithReturn(success);

            try
            {
                result = RunDownload(success);
            }
            catch (Exception ex)
            {
                if (!RaiseFaultHandlers(ex))
                {
                    ThrownException.Rethrow();
                }
            }
            return(result);
        }
Пример #9
0
 protected override void Run(bool success)
 {
     base.Run(success);
     try
     {
         Callback?.Invoke(success);
         if (CallbackWithException != null)
         {
             var thrown = GetThrownException();
             CallbackWithException?.Invoke(success, thrown);
         }
     }
     catch (Exception ex)
     {
         if (!RaiseFaultHandlers(ex))
         {
             ThrownException.Rethrow();
         }
     }
 }
Пример #10
0
 public MethodEventArgs(Method method, Method callingMethod, ThrownException exception)
 {
     this.Method = method;
     this.CallingMethod = callingMethod;
     this.Exception = exception;
 }
Пример #11
0
        /// <summary>
        /// Makes a new item.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="method">The method.</param>
        /// <param name="group">The group.</param>
        /// <returns></returns>
        protected ItemInfo MakeItem(ThrownException exception, Method method = null, ListViewGroup group = null)
        {
            bool isMethod = (method != null);
            bool isProperty = isMethod && method.MethodBase.IsProperty();
            bool isThrow = !isMethod && (exception != null);

            if (!isMethod)
            {
                method = exception.Method;
            }

            ListViewItem item;
            PropertyInfo pi = null;
            if (isProperty)
            {
                bool getter = method.MethodBase.Name.StartsWith("get_");
                pi = method.MethodBase.GetMethodProperty();
                item = new ListViewItem(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", pi.Name, getter ? "get" : "set"));
            }
            else
            {
                item = new ListViewItem(method.ToString());
            }

            if (isProperty)
            {
                item.ImageKey = NodeInfo.ImageKeyFromObject(pi);
            }
            else if (isMethod)
            {
                // use the method for the icon
                item.ImageKey = NodeInfo.ImageKeyFromObject(method.MethodBase);
            }
            else
            {
                // use the exception for the icon
                item.ImageKey = NodeInfo.ImageKeyFromObject(exception.Exception);
            }

            ItemInfo info;
            MethodItem me = new MethodItem(method, exception);

            if (exception == null)
            {
                info = new ItemInfo(item, me, NodeType.Method);
                item.SubItems.Add("");
            }
            else
            {
                info = new ItemInfo(item, me, NodeType.Method);
                info.Expandable = !isThrow;
                item.SubItems.Add(exception.Exception.Name);

            }

            item.Tag = info;

            item.SubItems.Add(method.MethodBase.DeclaringType.Name);
            item.SubItems.Add(method.MethodBase.DeclaringType.Module.Name);

            item.IndentCount = 1;

            if (group != null)
            {
                item.Group = group;
            }

            return info;
        }
Пример #12
0
 public void NoExceptionsShouldHaveBeenThrown()
 {
     ThrownException.ShouldBe(null);
 }
Пример #13
0
 public void ThrowsNotSupportedException()
 {
     ThrownException.ShouldBeAssignableTo <NotSupportedException>();
 }
Пример #14
0
        /// <summary>
        /// Returns all the exceptions that a tree nodeInfo and it's child nodeInfo point to.
        /// </summary>
        /// <param name="nodeInfo">The nodeInfo.</param>
        /// <returns>
        /// The exceptions that a nodeInfo and it's child nodeInfo point to.
        /// </returns>
        private IEnumerable<ThrownException> AddList(TreeNode node)
        {
            Class cls = node.GetInfo().GetAnalysisObject<Class>();

            IEnumerable<ThrownException> l = null;

            if (cls != null)
            {
                Type type = cls.ClassType;
                l = this.ExceptionTree.ExceptionDictionary.GetList(type);
            }
            else
            {
                l = new ThrownException[] { };
            }

            foreach (TreeNode child in node.Nodes)
            {
                l = l.Concat(this.AddList(child));
            }

            node.GetInfo().ExtraData = l;
            return l;
        }
 public void ShouldThrowAnException()
 {
     ThrownException.ShouldBeOfType <UnknownUserException>();
 }
 public void ExceptionShouldBeOfExpectedType()
 {
     ThrownException.ShouldBeAssignableTo <InvalidOperationException>();
 }
Пример #17
0
 public void ShouldSeeException()
 {
     ThrownException.ShouldBeTypeOf <NotSupportedException>();
 }
 public void ShouldThrownInvalidOperationException()
 {
     ThrownException.Should().BeOfType <InvalidOperationException>();
     ThrownException.Message.Should().Be($"There is no sorter for {SortBy}");
 }
 public void DuplicateRegionsAreRejectedWithException()
 {
     ThrownException.ShouldNotBeNull();
     ThrownException.ShouldBeAssignableTo <InvalidOperationException>();
 }
Пример #20
0
        /// <summary>Adds the exception.</summary>
        /// <param name="offset">The offset of this method.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="thrownHere">if set to <c>true</c> if the exception was thrown by this method.</param>
        public void AddException(int offset, ThrownException exception)
        {
            // !! This method is the most frequently called non-trivial method !!

            if (this.MethodBody != null)
            {
                // see if any exception handler covers this instruction
                foreach (ExceptionHandlingClause handler in this.MethodBody.ExceptionHandlingClauses)
                {
                    if ((handler.Flags != ExceptionHandlingClauseOptions.Fault) && (handler.Flags != ExceptionHandlingClauseOptions.Finally))
                    {
                        if ((offset >= handler.TryOffset) && (offset < handler.TryOffset + handler.TryLength))
                        {
                            // is it for this exception?
                            if (this.CheckSubclass(handler.CatchType, exception.Exception))
                            {
                                return;
                            }
                        }
                    }
                }
            }
            else
            {
            }

            this.UnhandledExceptions.Add(exception);
        }
Пример #21
0
 /// <summary>
 /// A copy constructor that allocates an instance that is the same as the given template, except for its containing block.
 /// </summary>
 /// <param name="containingBlock">The containing block of the copied postcondition. This should be different from the containing block of the template postcondition.</param>
 /// <param name="template">The statement to copy.</param>
 private ThrownException(BlockStatement containingBlock, ThrownException template)
     : base(template.SourceLocation)
 {
     this.exceptionType = (TypeExpression)template.ExceptionType.MakeCopyFor(containingBlock);
       this.postcondition = template.Postcondition.MakeCopyFor(containingBlock);
 }
Пример #22
0
 /// <summary>
 /// Rewrites the children of the given thrown exception.
 /// </summary>
 public virtual void RewriteChildren(ThrownException thrownException)
 {
     thrownException.ExceptionType = this.Rewrite(thrownException.ExceptionType);
       thrownException.Postcondition = this.Rewrite((Postcondition)thrownException.Postcondition);
 }
Пример #23
0
 public void ExceptionIsNotThrown()
 {
     ThrownException.ShouldBeNull();
 }
Пример #24
0
 protected void ThenAnInvalidOperationExceptionIsThrownWithMessage(string expectedMessage)
 {
     ThrownException.Should().BeOfType <InvalidOperationException>();
     ThrownException.Message.Should().Be(expectedMessage);
 }
Пример #25
0
 protected void ThenAnExceptionIsThrown()
 {
     ThrownException.Should().NotBeNull();
 }
Пример #26
0
 protected void ThenAConcurrencyExceptionIsThrown()
 {
     ThrownException.Should().BeOfType <ConcurrencyException>();
 }
Пример #27
0
 public void ShowCallStack(CallStack callStack, ThrownException thrownException)
 {
     TreeNode node = this.SelectedClassNode;
     Job worker = Job.Analysis.NewJob(this.ClassTree, (cancelToken) =>
     {
         this.ExceptionTree.Preselect = thrownException.Exception;
         this.ClassTree.ShowCallStack(callStack, node, cancelToken);
     });
     worker.Execute();
 }
Пример #28
0
 public void ThrowsNotImplementedException()
 {
     ThrownException.ShouldBeOfType <NotImplementedException>();
 }
Пример #29
0
        void ShowExceptionThrow(Method caller, ThrownException te)
        {
            if (caller == null)
            {
                caller = te.Method;
            }

            Job.SourceView.NewJob(this.SourceViewer, (cancelToken) =>
            {
                if (Environment.TickCount == 123)
                {
                    throw new TimeZoneNotFoundException();
                }
                List<SourceViewer.HighlightItem> items = new List<SourceViewer.HighlightItem>();

                foreach (ThrownException ex in caller.UnhandledExceptions)
                {
                    if (ex.Exception == te.Exception)
                    {
                        SourceViewer.HighlightItem item = new SourceViewer.HighlightItem(te.Exception)
                        {
                            Display = Decompiler.SourceViewer.HighlightDisplay.Highlight,
                            Offset = ex.Offset
                        };

                        if (ex.IsXmlDoc)
                        {
                            item.HighlightType |= Decompiler.SourceViewer.HighlightType.DocumentedException;
                        }

                        items.Add(item);
                    }
                }

                this.SourceViewer.SetSource(caller.MethodBase, items, cancelToken);
            }).Execute();
        }
Пример #30
0
 public void ThrowsException()
 {
     ThrownException.ShouldBeOfType <Exception>();
 }
Пример #31
0
 public void ConfigItemsAreRequired()
 {
     ThrownException.ShouldBeAssignableTo <ArgumentNullException>();
 }
Пример #32
0
 public void NoExceptionIsThrownByConfig()
 {
     ThrownException.ShouldBeNull();
 }
 public void ConfigItemsAreRequired()
 {
     ThrownException.ShouldNotBeNull();
     ThrownException.ShouldBeAssignableTo <InvalidOperationException>();
 }
 public void ExceptionThrown()
 {
     ThrownException.ShouldNotBeNull();
 }
Пример #35
0
        private List<ListViewItem> GetCallstackItems(ItemInfo info, ThrownException ex)
        {
            List<ListViewItem> items = new List<ListViewItem>();

            //MethodContainer.CallStack stack = this.MethodContainer.Analysis.GetCallstack(ex.Method);
            CallStack stack = ((MethodItem)info.Data).Method.Analysis.GetCallstack(ex.Method);

            // add the methods in it
            if (stack != null)
            {
                bool first = true;
                ItemInfo previous = null;
                foreach (Method m in stack)
                {
                    if (first)
                    {
                        first = false;
                        continue;
                    }

                    ItemInfo child = MakeItem(null, m);
                    if (previous != null)
                    {
                        ((MethodItem)child.Data).CalledBy = ((MethodItem)previous.Data).Method;
                    }
                    else
                    {
                        ((MethodItem)child.Data).CalledBy = ((MethodItem)info.Data).Method;
                    }

                    child.Item.IndentCount = info.Item.IndentCount + 1;

                    child.Parent = info;
                    child.PreviousChild = previous;

                    previous = child;

                    items.Add(child.Item);
                }

                // add an item for the throw statement
                ItemInfo throwItem = MakeItem(ex);
                throwItem.Item.Text = "throw " + ex.Exception.Name;
                throwItem.Item.IndentCount++;

                throwItem.PreviousChild = previous;
                throwItem.Parent = info;

                items.Add(throwItem.Item);
            }
            return items;
        }
Пример #36
0
 /// <summary>
 /// Visits the specified thrown exception.
 /// </summary>
 /// <param name="thrownException">The thrown exception.</param>
 public virtual IThrownException Visit(ThrownException thrownException)
 {
     thrownException.ExceptionType = this.Visit(thrownException.ExceptionType);
       thrownException.Postcondition = this.Visit(thrownException.Postcondition);
       return thrownException;
 }
Пример #37
0
 public MethodItem(Method method, ThrownException exception)
 {
     this.Method = method;
     this.Exception = exception;
 }
Пример #38
0
 /// <summary>
 /// Get the mutable copy of a thrown exception.
 /// </summary>
 /// <param name="thrownException"></param>
 /// <returns></returns>
 public virtual ThrownException GetMutableCopy(IThrownException thrownException)
 {
     object cachedValue;
       if (this.cache.TryGetValue(thrownException, out cachedValue))
     return (ThrownException)cachedValue;
       var result = new ThrownException(thrownException);
       // Probably not necessary, no two thrown exceptions are shared.
       this.cache.Add(thrownException, result);
       this.cache.Add(result, result);
       return result;
 }
Пример #39
0
 public void ExceptionIsThrownBecauseHandlerIsNotRegisteredInContainer()
 {
     ThrownException.ShouldBeAssignableTo <HandlerNotRegisteredWithContainerException>();
 }
Пример #40
0
 /// <summary>
 /// Visits the specified thrown exception.
 /// </summary>
 /// <param name="thrownException">The thrown exception.</param>
 protected virtual IThrownException DeepCopy(ThrownException thrownException)
 {
     thrownException.ExceptionType = this.Substitute(thrownException.ExceptionType);
       thrownException.Postcondition = this.Substitute(thrownException.Postcondition);
       return thrownException;
 }
Пример #41
0
 public void InvalidOperationIsThrown()
 {
     ThrownException.ShouldBeAssignableTo <InvalidOperationException>();
 }
 public void ExceptionShouldBeOfExpectedType()
 {
     ThrownException.ShouldBeTypeOf <InvalidOperationException>();
 }
Пример #43
0
 public void NoExceptionIsThrown()
 {
     // Specifying failover regions mean that messages can be registered more than once.
     ThrownException.ShouldBeNull();
 }
Пример #44
0
 /// <summary>
 /// Visits the specified thrown exception.
 /// </summary>
 /// <param name="thrownException">The thrown exception.</param>
 public virtual IThrownException Visit(IThrownException thrownException)
 {
     ThrownException mutableThrownException = thrownException as ThrownException;
       if (!this.copyOnlyIfNotAlreadyMutable || mutableThrownException == null)
     mutableThrownException = new ThrownException(thrownException);
       return this.Visit(mutableThrownException);
 }