http://bugzilla.novell.com/show_bug.cgi?id=568955

http://bugzilla.novell.com/show_bug.cgi?id=568955#c5


Pablo Ruiz <pr...@netway.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #355170|0                           |1
        is obsolete|                            |

--- Comment #5 from Pablo Ruiz <pr...@netway.org> 2010-04-20 13:59:18 UTC ---
Created an attachment (id=355584)
 --> (http://bugzilla.novell.com/attachment.cgi?id=355584)
List changed work-a-round v2.

Here it's an updated work-a-round which avoids the 'List changed' problem, but
does not fully resolve the Bug, as the compiled code wont work either, as the
generated Expression is invalid.

You can reproduce the new fault compiling the following code:

-----------
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Diagnostics;

namespace Test
{
        public class Rate
        {
                public int Id { get; set; }
        }

        public class Specification
        {
                public Expression<Func<Rate, bool>> expression;
                public Func<Rate, bool> fn;

                public Specification(Expression<Func<Rate, bool>> predicate)
                {
                        this.expression = predicate;
                        this.fn = predicate.Compile() as Func<Rate, bool>;
                }
        }

        public class RateById : Specification
        {
                public RateById(int id)
                        : base(x => x.Id == id)
                {
                }
        }

        public class Program
        {
                static void Main()
                {
                        var obj = new Rate() { Id = 1 };

                        var s1 = new RateById(1);
                        var s2 = new RateById(2);

                        Debug.Assert(s1.fn.Invoke(obj) == true);
                        Debug.Assert(s2.fn.Invoke(obj) == false);
                }
        }
}
----------

gmcs /target:exe p.cs && mono ./p.exe

Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: expression
  at System.Linq.Expressions.Expression.Property
(System.Linq.Expressions.Expression expression, System.Reflection.MethodInfo
propertyAccessor) [0x00080] in
/usr/src/redhat/BUILD/mono-2.6.3/mcs/class/System.Core/System.Linq.Expressions/Expression.cs:2112
  at Test.RateById..ctor (Int32 id) [0x00000] in <filename unknown>:0
  at Test.Program.Main () [0x00000] in <filename unknown>:0

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  mono-bugs@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to