Example #1
0
        private static IEnumerable <Expression> TryCatchBuilder(LightExceptionTests self)
        {
            using (new DepthHolder(self)) {
                foreach (var body in self.GetStatements())
                {
                    foreach (var handler in self.GetStatements())
                    {
                        for (int i = 0; i < _catchExtras.Length; i++)
                        {
                            var extra = _catchExtras[i];

                            yield return(AddLogging(
                                             Expression.TryCatch(
                                                 Expression.Block(typeof(void), body),
                                                 Expression.Catch(
                                                     typeof(Exception),
                                                     AddLogging(Expression.Block(typeof(void), handler, extra), "catch " + i)
                                                     )
                                                 ),
                                             "try"
                                             ));

                            yield return(AddLogging(
                                             Expression.TryCatch(
                                                 Expression.Block(typeof(void), body),
                                                 Expression.Catch(
                                                     typeof(InvalidOperationException),
                                                     AddLogging(Expression.Block(typeof(void), handler, extra), "invalidEx catch 1 " + i)
                                                     )
                                                 ),
                                             "try"
                                             ));

                            yield return(AddLogging(
                                             Expression.TryCatch(
                                                 Expression.Block(typeof(void), body),
                                                 Expression.Catch(
                                                     typeof(InvalidOperationException),
                                                     AddLogging(Expression.Block(typeof(void), handler, extra), "invalidEx catch 2 " + i)
                                                     ),
                                                 Expression.Catch(
                                                     typeof(InvalidOperationException),
                                                     AddLogging(Expression.Block(typeof(void), handler, extra), "catch " + i)
                                                     )
                                                 ),
                                             "try"
                                             ));
                        }
                    }
                }
            }
        }
 private static IEnumerable<Expression> TryFinallyBuilder(LightExceptionTests self) {
     using (new DepthHolder(self)) {
         foreach (var body in self.GetStatements()) {
             foreach (var handler in self.GetStatements()) {
                 yield return Expression.TryFinally(AddLogging(body, "try finally"), AddLogging(handler, "finally"));
             }
         }
     }
 }
        private static IEnumerable<Expression> TryCatchBuilder(LightExceptionTests self) {
            using (new DepthHolder(self)) {
                foreach (var body in self.GetStatements()) {
                    foreach (var handler in self.GetStatements()) {
                        for (int i = 0; i < _catchExtras.Length; i++) {
                            var extra = _catchExtras[i];

                            yield return AddLogging(
                                Expression.TryCatch(
                                    Expression.Block(typeof(void), body),
                                    Expression.Catch(
                                        typeof(Exception),
                                        AddLogging(Expression.Block(typeof(void), handler, extra), "catch " + i)
                                    )
                                ),
                                "try"
                            );

                            yield return AddLogging(
                                Expression.TryCatch(
                                    Expression.Block(typeof(void), body),
                                    Expression.Catch(
                                        typeof(InvalidOperationException),
                                        AddLogging(Expression.Block(typeof(void), handler, extra), "invalidEx catch 1 " + i)
                                    )
                                ),
                                "try"
                            );

                            yield return AddLogging(
                                Expression.TryCatch(
                                    Expression.Block(typeof(void), body),
                                    Expression.Catch(
                                        typeof(InvalidOperationException),
                                        AddLogging(Expression.Block(typeof(void), handler, extra), "invalidEx catch 2 " + i)
                                    ),
                                    Expression.Catch(
                                        typeof(InvalidOperationException),
                                        AddLogging(Expression.Block(typeof(void), handler, extra), "catch " + i)
                                    )
                                ),
                                "try"
                            );
                        }

                    }
                }
            }
        }