question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot Ignore Protected Property

See original GitHub issue

First of all, great lib and great work!

The issue I’m having is as described. I cannot opt to ignore a property if that property is protected. In fact, I cannot do anything to a hidden property. The method .Ignore() (and all others) only allows for an expression to be passed in. That makes it dificult to handle hidden members.

My suggestion is that these methods have an overload with a string parameter (like EF does) to allow a property name to be passed in, like .Ignore("MyProtectedProperty") or .RuleFor<string>("MyProtectedProperty", f =>f.Random.Word()).

To work around this issue, I manage to get it working by using .RuleForType<TType>(Type, Func) after some try and error to get the types correct, however, if the type is shared between multiple properties, there is no way to configure the target property alone.

That’s all. Keep up the good work!

Thanks,

Cleverson Nascimento

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bchavezcommented, Sep 10, 2019

Great work Nick! Thanks for keeping AutoBogus up to date! Also, thanks again for your help! If you need anything else, please don’t hesitate to let me know. 👍

1reaction
nickdodd79commented, Sep 10, 2019

Hey @SuricateCan and @bchavez,

I have just pushed v2.7.0 which upgrades to the latest version of Bogus and adds a string version of the skip config:

.WithSkip<Person>("Age");

Nick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entity Framework 5 Cannot use Ignore method on the ...
"You cannot use Ignore method on the property 'MyProperty' on type 'Namespace.MyEntity' because this type inherits from the type 'MyBaseEntity' ...
Read more >
Ignore the protected $with = []; property
I'm can't find out how I can bypass the $with property of my model. I have a specific query that I have to...
Read more >
Are protected properties evil? [duplicate]
A property or field being protected just tells you that this is an internal implementation detail which is likely to be relevant for...
Read more >
Ignore protected access warning on $this
Hi. I have a PHP file for the class definition and a separate HTML/PHP file for the template. The template file is included...
Read more >
CA1051: Do not declare visible instance fields
To fix a violation of this rule, make the field private or internal and expose it by using an externally visible property. When...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found