[Mono-bugs] [Bug 568955] System.InvalidOperationException: List has changed. from gmcs while compiling.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 20 09:59:20 EDT 2010



Pablo Ruiz <pruiz at netway.org> changed:

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

--- Comment #5 from Pablo Ruiz <pruiz at 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
  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.

More information about the mono-bugs mailing list