Getting exception in OnError before OnAfterExecute on simple call with parameter

Issue #4 resolved
Former user created an issue
public class LoggingInterceptor : ICopIntercept, ICopErrorHandle
    {
        public void OnBeforeExecute(InterceptionContext context)
        {
            Console.WriteLine("OnBeforeExecute");
        }

        public void OnAfterExecute(InterceptionContext context)
        {
            Console.WriteLine("OnAfterExecute");
        }

        public void OnError(InterceptionContext context)
        {
            Console.WriteLine("An exception occured: {0}", context.Exception.Message);
        }
    }
 class Program
    {
        static void Main()
        {
            Cop.Intercept();

           Test1();
           Test2(32);

        }

        public static void Test1()
        {
            Console.WriteLine("hohoho");
        }

        public static void Test2(int i)
        {
            Console.WriteLine($"hohoho: {i}");
        }
    }
{
  "Types": [
    {
      "TypeName": "ConsoleApplication3.Program, ConsoleApplication3",
      "Methods": [
        {
          "MethodSignature": "Test1()",
          "Interceptors": [
            "LoggingInterceptor"
          ]
        },
        {
          "MethodSignature": "Test2(System.Int32)",
          "Interceptors": [
            "LoggingInterceptor"
          ]
        }
      ],
      "GenericArgumentTypes": []
    }
  ],
  "GlobalInterceptors": [
    "LoggingInterceptor"
  ],
    "Key": ""
}

Build: VS2015, 64bit, <useLegacyJit enabled="1" />, codecop 1.2.2. Call to Test2 will generate OnBeforeExecute and then go to OnError with Exception {"Object of type 'System.Linq.Enumerable+WhereSelectListIterator`2[CodeCop.Core.Parameter,System.Object]' cannot be converted to type 'System.Int32'."} System.Exception {System.ArgumentException}

and then call OnAfterExecute

Comments (7)

  1. Ricardo Barbosa

    Hi Alexander,

    Thanks for your kind words and also for reporting this issue back to us.

    Please upgrade CodeCop to v.1.2.3 where this issue is now fixed.

    Tell us if it did the job for you.

    Thanks,

    Ricardo

  2. Ricardo Barbosa

    Hi Alexander,

    Have you had a chance to try our proposed solution and see it it works?

    Thanks,

    Ricardo

  3. Log in to comment