You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Method GetProperty(object target, string name) in the PathBinder.cs and IteratorBinder.cs cause memory leak in highload application. Could you use another way for getting property value instead of using RuntimeBuilder class?
Hi!
Maybe we can use ExpressionTrees instead RuntimeBuilder?
For example:
var parameter = Expression.Parameter(typeof(object));
var cast = Expression.Convert(parameter, value.GetType());
var propertyGetter = Expression.Property(cast, propertyName);
var castResult = Expression.Convert(propertyGetter, typeof(object));//for boxing
var propertyRetriver = Expression.Lambda<Func<object, object>>(castResult, parameter).Compile();
var retrivedPropertyValue = propertyRetriver(value);
I know that's not a cheap operation because expression threes should be compiled. But i think that's it should be faster then DLR. What do you think?
I don't understand how this api can help. Usually this api uses for custom DynamicObject implementation and contains describing get methods of custom DynamicObject. Could you please clarify idea for using this api.
Do you mean "Value" property? It does't work for ExpandoObject. It just return null.
Instead of we can call Expression that contains logic access to the member
Every custom DynamicMetaObject that inherited from DynamicMetaObject can override BindGetMember and provide Expression for access to their members.
Look at example for JObject from Json.NET library
If you know another way I will be grateful for the help
ExpandoObject implements IDictionary<string,object> so you may want to consider reordering the type checks to give that precedence. The structure of the routine should be that if a value isn't resolvable after one attempt, fall back up and keep trying others.
Activity
rexm commentedon Aug 1, 2019
PR welcome
DmitryDem commentedon Aug 1, 2019
Hi!
Maybe we can use ExpressionTrees instead RuntimeBuilder?
For example:
var parameter = Expression.Parameter(typeof(object));
var cast = Expression.Convert(parameter, value.GetType());
var propertyGetter = Expression.Property(cast, propertyName);
var castResult = Expression.Convert(propertyGetter, typeof(object));//for boxing
var propertyRetriver = Expression.Lambda<Func<object, object>>(castResult, parameter).Compile();
var retrivedPropertyValue = propertyRetriver(value);
I know that's not a cheap operation because expression threes should be compiled. But i think that's it should be faster then DLR. What do you think?
rexm commentedon Aug 1, 2019
DmitryDem commentedon Aug 1, 2019
Yea, sorry, didn't notice
DmitryDem commentedon Aug 1, 2019
What do you think about CallSite caching? I think it's should help. The main problem occurs when creating CallSite objects.
For example:
rexm commentedon Aug 1, 2019
Looking at this: https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicmetaobject.bindgetmember?view=netframework-4.8#System_Dynamic_DynamicMetaObject_BindGetMember_System_Dynamic_GetMemberBinder_
DmitryDem commentedon Aug 2, 2019
I don't understand how this api can help. Usually this api uses for custom DynamicObject implementation and contains describing get methods of custom DynamicObject. Could you please clarify idea for using this api.
DmitryDem commentedon Aug 2, 2019
I have just implemented some solution. What do you think?
rexm commentedon Aug 2, 2019
That all makes sense to me except I don’t entirely understand the Lambda wrapper bit - can you explain?
DmitryDem commentedon Aug 2, 2019
Yes lambda wrapper could be simplified. I think we could replace Lambda wrapper with this
These lines do not make sense.
rexm commentedon Aug 2, 2019
The
DynamicMetaObjecthas other properties that look like they give direct access to the underlying value without creating a new expression tree - take a look at the Properties section on https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicmetaobject?view=netframework-4.8DmitryDem commentedon Aug 2, 2019
Do you mean "Value" property? It does't work for ExpandoObject. It just return null.



Instead of we can call Expression that contains logic access to the member
Every custom DynamicMetaObject that inherited from DynamicMetaObject can override BindGetMember and provide Expression for access to their members.
Look at example for JObject from Json.NET library
If you know another way I will be grateful for the help
rexm commentedon Aug 2, 2019
ExpandoObjectimplementsIDictionary<string,object>so you may want to consider reordering the type checks to give that precedence. The structure of the routine should be that if a value isn't resolvable after one attempt, fall back up and keep trying others.XcoderBlood commentedon Jan 16, 2020
Was this ever fixed?
Extreme refactoring/enhancements