Linq Interpreter bug



I’m creating a linq expression and compiling it, in order to filter a collection of items. In android it works perfectly, but in UWP the expression is “interpreted” and behaves strangely.

The expression basically query the properties of a class and check whether it satisfy certain condition.
Something like this “Convert(dataItem).Symbol.ToUpper().Contains(“A”)”.

So far so good, the problem is in UWP. When the compiled lambda is called, it ends up setting the value of the property (Despite the expression never sets the value, it should only get the value)

here is the callstack I can see

System.Linq.Expressions.dll!System.Linq.Expressions.Interpreter.PropertyByRefUpdater.Update(System.Linq.Expressions.Interpreter.InterpretedFrame frame, object value)	Unknown
System.Linq.Expressions.dll!System.Linq.Expressions.Interpreter.ByRefMethodInfoCallInstruction.Run(System.Linq.Expressions.Interpreter.InterpretedFrame frame)	Unknown
System.Linq.Expressions.dll!System.Linq.Expressions.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Linq.Expressions.Interpreter.InterpretedFrame frame)	Unknown
System.Linq.Expressions.dll!System.Linq.Expressions.Interpreter.Interpreter.Run(System.Linq.Expressions.Interpreter.InterpretedFrame frame)	Unknown
System.Linq.Expressions.dll!System.Linq.Expressions.Interpreter.LightLambda.Run(object[] arguments)	Unknown

I can’t understand why “PropertyByRefUpdater.Update” is called. Exactly the same code runs fine in a non-interpreted environment.

The System.Linq.Expressions library is the version 4.3.0



Do you have short example code that reproduces the problem? It makes it much easier when trying to understand and fix problems like this.

Also, could you open this as an issue on the corefx repo? That’s where issues in .Net Core libraries belong (and I believe UWP uses .Net Core).

.NET Foundation Website | Blog | Projects | Code of Conduct