LOL, I found this on our code this week, so your guess is as good as mine at this point
Item
is a member of IDictionary
but as Item[]
So if you add Item[]
as a member that is totally fine.
The exception doesn’t give many clues: Parameter Count Mismatch.
BaseObject["Item"]
=> error
BaseObject["Item[]"]
=> fine
I’ve added a sanitization routine for property names now - perhaps that should be in Core.Core.Models.DynamicBase
itself under IsPropertyNameValid
It’s still kicking the can down the road. Item
is problematic because of DynamicObject, IDynamicMetaObjectProvider
inheritance of Base. I’d happily be in favour of swapping that for a simpler Base : Dictionary<string, object>
- which is perfectly ok functionality wise, though a drop-in replacement might be difficult…
Okay, I’ve dug into this a bit more. Item
was actually hidden in plain sight, as this property:
I have a local fix that allows for Item
s to be set as dynamic props, as well as typed properties inside custom classes (also doing some fly-by caching and DRY-ing things up). Now I’ve also got the itch to cleanup the mess that accumulated in there re getting members from objects - I’ll leave that for another holiday though.
Great. It was only a rant that I had previously stumbled on, worked around, and then forgot about when encountering it again.
Property names added by the dictionary method skip the validity check for serialization. I’ve raised a PR to the docs with a note about that.