How to make property take precedence over indexer. #1462
Replies: 2 comments
-
The behavior comes from here: jint/Jint/Runtime/Interop/Reflection/ReflectionAccessor.cs Lines 43 to 58 in 4e1893d So for some reason the indexer is preferred first. If you can create a test case that shows fixed priority usage, create required tweak to this code logic and other interop tests still pass, a pull request would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
I re-checked this and this is just too ambiguous to handle. Your indexer should return null when "MyProp" is requested, otherwise indexer wins as Jint doesn't know which one you would like to use anyway. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have a class which contains indexer and property at the same time like below.
I want to get value from MyProp when I call myobj.MyProp but I want to get other values from indexer.
But when I run the following code, I get value from indexer instead of myobj.MyProp.
How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions