nickdodd79 / AutoBogus

A C# library complementing the Bogus generator by adding auto creation and population capabilities.
MIT License
431 stars 50 forks source link

Generation of properties with custom get / set #18

Closed plaisted closed 5 years ago

plaisted commented 5 years ago

Properties with custom getters and setters appear to be ignored. Is this intentional? Is there a way to force these to be faked?

nickdodd79 commented 5 years ago

Hi @plaisted

Ignoring properties with valid setters is not intentional. Can you provide an example of where this is happening and I will investigate.

Nick.

plaisted commented 5 years ago

I created a minimal example to show the error but it populated correctly. I'll dig into the project that I had problems with and reopen if I can narrow the problems down to something with AutoBogus.

plaisted commented 5 years ago

Okay, this turned out to be something due to AutoBogus populating a protected field and wiping out the internal state of the object.

@nickdodd79 , is there a way to have it ignore a field/property? I tried .RuleFor() but couldn't find a way to just get it to do nothing to a particular field.

nickdodd79 commented 5 years ago

Hey @plaisted

Currently AutoBogus executes on the basis that all properties are to be populated. The RuleFor approach is the workaround at the moment.

Another issue (#17) was raised not long before yours which also asked for a setting to ignore properties. I will start looking at including this and let you know when it is ready. I will also post all updates in the other issue thread.

Thanks. Nick.