{"action":"created","issue":{"url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/61","labels_url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/61/comments","events_url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/61/events","html_url":"https://github.com/hazzik/DelegateDecompiler/issues/61","id":114281754,"number":61,"title":"ArgumentException when the Computed Expression Body has a call to a method passing an enum value","user":{"login":"pedroreys","id":130238,"avatar_url":"https://avatars.githubusercontent.com/u/130238?v=3","gravatar_id":"","url":"https://api.github.com/users/pedroreys","html_url":"https://github.com/pedroreys","followers_url":"https://api.github.com/users/pedroreys/followers","following_url":"https://api.github.com/users/pedroreys/following{/other_user}","gists_url":"https://api.github.com/users/pedroreys/gists{/gist_id}","starred_url":"https://api.github.com/users/pedroreys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pedroreys/subscriptions","organizations_url":"https://api.github.com/users/pedroreys/orgs","repos_url":"https://api.github.com/users/pedroreys/repos","events_url":"https://api.github.com/users/pedroreys/events{/privacy}","received_events_url":"https://api.github.com/users/pedroreys/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazzik/DelegateDecompiler/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-30T14:35:55Z","updated_at":"2015-12-23T00:59:01Z","closed_at":"2015-11-25T10:54:09Z","body":"When the computed expression body has a call to a method that takes an enum as an argument, an invalid operation exception is thrown because it tries to pass the integer value instead of the typed enum one.\r\n\r\nHere is a repro:\r\n\r\n````csharp\r\npublic class Foo\r\n{\r\n    public Decimal Value { get; set; }\r\n\r\n    [Computed]\r\n    public Decimal RoundedValue\r\n    {\r\n        get\r\n        {\r\n            return Decimal.Round(Value, 3, MidpointRounding.AwayFromZero);\r\n        }\r\n    }\r\n}\r\n\r\npublic void Should_be_able_to_decompile_the_rounded_value()\r\n{\r\n    var roundedValues = Enumerable.Range(1,10)\r\n                                    .Select(x => new Foo {Value =123.4561m})\r\n                                    .AsQueryable()\r\n                                    .Select(x => x.RoundedValue)\r\n                                    .Decompile();\r\n\r\n    roundedValues.Distinct().Count().ShouldBe(2);\r\n    roundedValues.ShouldContain(123.456m);\r\n    roundedValues.ShouldContain(123.457m);\r\n}\r\n````\r\n\r\nThe test above fails with the following Exception:\r\n\r\n````\r\nSystem.ArgumentException\r\n    Expression of type 'System.Int32' cannot be used for parameter of type 'System.MidpointRounding' of method 'System.Decimal Round(System.Decimal, Int32, System.MidpointRounding)'   \r\n    at System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)\r\n    at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments)\r\n    at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)\r\n    at DelegateDecompiler.Processor.BuildMethodCallExpression(MethodInfo m, Address instance, Expression[] arguments)\r\n    at DelegateDecompiler.Processor.Call(ProcessorState state, MethodInfo m)\r\n    at DelegateDecompiler.Processor.Process()\r\n    at DelegateDecompiler.Processor.Process(VariableInfo[] locals, IList`1 args, Instruction instruction, Type returnType)\r\n    at DelegateDecompiler.MethodBodyDecompiler.Decompile()\r\n    at DelegateDecompiler.DecompileExtensions.<>c__DisplayClass1.<Decompile>b__0(MethodInfo m)\r\n    at DelegateDecompiler.Cache`2.GetOrAdd(TKey key, Func`2 func)\r\n    at DelegateDecompiler.DecompileExtensions.Decompile(MethodInfo method)\r\n    at DelegateDecompiler.DecompileExpressionVisitor.Decompile(MethodInfo method, Expression instance, IList`1 arguments)\r\n    at DelegateDecompiler.DecompileExpressionVisitor.VisitMember(MemberExpression node)\r\n    at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor)\r\n    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n    at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)\r\n    at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)\r\n    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n    at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)\r\n    at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor)\r\n    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n    at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)\r\n    at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n    at DelegateDecompiler.DecompileExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n    at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)\r\n    at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n    at DelegateDecompiler.DecompiledQueryProvider.CreateQuery[TElement](Expression expression)\r\n    at DelegateDecompiler.DecompileExtensions.Decompile[T](IQueryable`1 self)\r\n````"},"comment":{"url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/comments/166770750","html_url":"https://github.com/hazzik/DelegateDecompiler/issues/61#issuecomment-166770750","issue_url":"https://api.github.com/repos/hazzik/DelegateDecompiler/issues/61","id":166770750,"user":{"login":"hazzik","id":144791,"avatar_url":"https://avatars.githubusercontent.com/u/144791?v=3","gravatar_id":"","url":"https://api.github.com/users/hazzik","html_url":"https://github.com/hazzik","followers_url":"https://api.github.com/users/hazzik/followers","following_url":"https://api.github.com/users/hazzik/following{/other_user}","gists_url":"https://api.github.com/users/hazzik/gists{/gist_id}","starred_url":"https://api.github.com/users/hazzik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hazzik/subscriptions","organizations_url":"https://api.github.com/users/hazzik/orgs","repos_url":"https://api.github.com/users/hazzik/repos","events_url":"https://api.github.com/users/hazzik/events{/privacy}","received_events_url":"https://api.github.com/users/hazzik/received_events","type":"User","site_admin":false},"created_at":"2015-12-23T00:59:01Z","updated_at":"2015-12-23T00:59:01Z","body":"Sure not today. Probably before 5th of Jan\nOn Wed, 23 Dec 2015 at 1:11 PM Pedro Reys <notifications@github.com> wrote:\n\n> Hey @hazzik <https://github.com/hazzik>, do you have an ETA for when this\n> fix will be available in Nuget?\n>\n> Thanks again!\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/hazzik/DelegateDecompiler/issues/61#issuecomment-166766349>\n> .\n>\n"}}