-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and copyDynamicProperties #27
Conversation
@@ -21,11 +21,8 @@ type DynamicObj() = | |||
/// Gets property value | |||
member this.TryGetValue name = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix #25 ? If so, please add a regression test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, not related
src/DynamicObj/DynamicObj.fs
Outdated
/// Sets property value, creating a new property if none exists | ||
member this.SetValue (name,value) = // private | ||
// first check to see if there's a native property to set | ||
|
||
match ReflectionUtils.tryGetPropertyInfo this name with | ||
match ReflectionUtils.tryGetStaticPropertyInfo this name with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you have this.TryGetStaticPropertyInfo
, can you use it here instead of an external module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What module do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReflectionUtils.tryGetStaticPropertyInfo
is used although a method with the exact same name exists on the class. On other members, you used the instance method instead of the functions from ReflectionUtils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, you used this.TryGetPropertyInfo
in the Remove method instead of ReflectionUtils.tryGetPropertyInfo
@@ -137,6 +164,23 @@ type DynamicObj() = | |||
#endif | |||
|> Seq.filter (fun kv -> kv.Key.ToLower() <> "properties") | |||
|
|||
/// Copies all dynamic members of the DynamicObj to the target DynamicObj. | |||
member this.CopyDynamicPropertiesTo(target:#DynamicObj, ?overWrite) = | |||
let overWrite = Option.defaultValue false overWrite |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also defaultArg
, i vaguely remember that being better to use in these scenarios, but i do not remember why. Your call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Fable you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no i mean in general for determining default args for optional arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here it doesn't matter.
In cases where the default expression is computationally expensive, it's worth to switch to an explicit match. But not sure whether Option.defaultValue
and defaultArg
even have different implementations.
#26