Skip to content
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

ClrStaticTypeWrapper.PopulateMembers method incorrectly setups property for .NET indexed property #46

Open
nekobul opened this issue Jul 18, 2016 · 1 comment
Labels

Comments

@nekobul
Copy link

nekobul commented Jul 18, 2016

Reproduction:

  1. Pass ArrayList CLR object to JS and try to try to access element from the array like:

var element = arrayList.Item[0];

or

var element = arrayList.get_item(0);

Observed behavior:

First code fails with error "No overload for method 'get_Item' takes 0 arguments".
Second code fails with error "'arrayList.get_Item' is not a function".

Expected behavior:

The first code will obviously not work because there are no indexed properties in JS. The second code should work.

Propoposed solution:

ClrStaticTypeWrapper.PopulateMembers method must be modified to call PropertyInfo.GetIndexParameters method to verify if property is indexed. If property is indexed, it should not be setup as JS property. This is the code I propose:

                case MemberTypes.Property:
                    PropertyInfo property = (PropertyInfo)member;
                    if ( property.GetIndexParameters().Length > 0 )
                    {   // Indexed property. Do not setup as property.
                        continue;
                    }

                    ...
@paulbartrum
Copy link
Owner

It's likely this code is either going away, or at least moved into a separate package, so I'm not going to make any changes to ClrStaticTypeWrapper for the forseeable future. I'll keep the issue open in case I reconsider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants