You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into this bug just this week and am curious if there's intent on a fix in an upcoming release? I can work around by adding a protected set; to the property, but would love to not have to do this as it reduces the integrity of the instantiated class.
The Binder is responsible for reflecting over / introspection of T in Faker<T> to determine what properties/fields are available on T. Also, the original post has a branch with some of the changes that seem to have worked around the original issue.
You can supply your custom Binder here in new Faker<T>(binder: MyCustomBinder):
Version Information
What locale are you using with Bogus?
en
What is the expected behavior?
Should not throw exception when enumerating properties.
What is the actual behavior?
System.Reflection.AmbiguousMatchException is thrown
Please provide a stack trace.
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
Any possible solutions?
Yes it is possible to ignore the indexer properties where the check for parent class properties is performed.
Have created a branch in my fork with a unit test and a possible solution.
How do you reproduce the issue?
By using fluent syntax with an object that has two read only indexers that are defined in a base class.
Have created a branch in my fork with a unit test and a possible solution.
Do you have a unit test that can demonstrate the bug?
Yes.
Have created a branch in my fork with a unit test and a possible solution.
Can you identify the location in Bogus' source code where the problem exists?
Yes.
Binder.cs line 114. Because both indexers have same default name Item resolving PropertyInfo by name fails.
If the bug is confirmed, would you be willing to submit a PR?
Yes.
The text was updated successfully, but these errors were encountered: