-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
Support for non-public setters/constructors. #179
Comments
Hi Marcus! Thanks for the kind complement! I'm always happy to hear from developers using Bogus! 👍 I'm always interested in seeing how we can make Bogus better. I would probably say the decision to avoid non-public constructors/setters was motivated by more of a feeling for best-practice rather than by-design. I envisioned a scenario like this could come up someday so I left open an extension point in Bogus' As you can see here. the default Line 35 in cd5e078
If you want to change the visibility of what members of public class MyBinder : Binder
{
public override Dictionary<string, MemberInfo> GetMembers(Type t)
{
// return a dictionary of <membername, memberinfo> I want to
// discover over type T
}
}
var myBinder = new MyBinder()
var faker = new Faker<T>( binder: myBinder ); There are probably situations where this might not be enough to completely resolve your issue, so I'd be interested in knowing more about your situation and how we could possibly resolve any issues you might have. If you could post some examples of what you're trying to achieve with Bogus that would be super helpful. Thanks, |
I upgraded to latest version of Bogus and have of my tests failed becaue of the issue, I am using internal properties in many places. I tried to use a non-public binder but it causes other errors on collections. |
… couldn't find a public setter. This change allows setting of non-public members. Reverts back to previous Bogus behavior which originally allowed setting of non-public members. Related #179.
… couldn't find a public setter. This change allows setting of non-public members. Reverts back to previous Bogus behavior which originally allowed setting of non-public members. Related #179.
Hey @waldimen , Thanks for letting me know. I took a deeper look at the issues here and it looks like we had a regression in PR #170. Prior to Bogus I think I've fixed the issue in the recent a3d2dc9 commit and will issue a new release shortly. The next release should restore the previous behavior prior to I appreciate the bug report! I apologize for the inconvenience. Thanks, |
Hey @waldimen, Bogus https://www.nuget.org/packages/Bogus/24.2.0 Please let me know if it resolves your issue. |
Hi Marcus, Thanks for testing and bringing up the issue. Let me know how it goes. :) Thanks, |
The new version works perfectly. Thanks for such quick fix :) |
Worked like a charm. Thanks 👍 |
That's great news. Thank you Marcus and @waldimen for testing. Please don't hesitate to post if there is a blocking issue. I try to resolve issues as quickly as I can. 😺 Thanks, 💼 👔 "Taking care of business every day... Taking care of business every way..." |
Hi! Great work so far with Bogus!
Bogus currently doesn't work with non-public parameterless constructors/setters. Is this behavior by-design? If not, I would like to work on that issue.
Thanks in advance.
The text was updated successfully, but these errors were encountered: