The code generated for converting anonymous values into a map of string->object would not box value types correctly, resulting in the following exception: System.ArgumentException: Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'Void Add(System.String, System.Object)' (Parameter 'arg1').
This PR fixes this by adding an explicit check for value types, and calling Expression.TypeAs() if so.
Summary
The code generated for converting anonymous values into a map of string->object would not box value types correctly, resulting in the following exception:
System.ArgumentException: Expression of type 'System.Int32' cannot be used for parameter of type 'System.Object' of method 'Void Add(System.String, System.Object)' (Parameter 'arg1')
.This PR fixes this by adding an explicit check for value types, and calling
Expression.TypeAs()
if so.