fsprojects / FSharp.Interop.Dynamic

DLR interop for F# -- works like dynamic keyword in C#
https://fsprojects.github.io/FSharp.Interop.Dynamic/
Apache License 2.0
95 stars 14 forks source link

Is it possible to check if a key exists? #27

Open pkese opened 6 months ago

pkese commented 6 months ago

I'm getting some unstructured objects and would like to check if o?myProp exists before extracting it?

Does this library allow me to do that somehow?

Currently, when accessing o?myProp, I'm getting:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'System.Object' does not contain a definition for 'myProp'

dsyme commented 6 months ago

It doesn't look possible using the library today. I guess consider adding a Dyn.exists or Dyn.tryGet?

It looks like the engineering in this repo needs updating too!