Open pdevito3 opened 2 years ago
Right after I submitted, I realized I should have checked Bogus... seems like they are tracking this here, but once it is implemented It will still need to be added to here in a new package reference?
@nickdodd79 FYI, Bogus just pushed v34.x which should accommodate this
Hey @pdevito3
Thanks for the update. I will get some updates in place so the latest Bogus and .NET capabilities are available.
Watch this space.
Nick.
Sounds good. No rush, just wanted to flag it in case you hadn't seen. Happy Turkey week!
hey @nickdodd79, what would the lift be for this? I can look into a PR myself if you're open to it and can give me a ballpark of what i should be looking at
thanks @pdevito3: we are currently using this lib (thanks @nickdodd79 !) and this would definitely solve our issue.
@lsimone i ended up publishing a forked version of Autobogus given @nickdodd79's inactivity. It should fix this if you want to give it a whirl to resolve your issue. If you have any problems let me know: https://github.com/pdevito3/AutoBogus
Not sure how active I'll be maintaining it and really hoping nick takes things back over, but it's seeming more and more abandoned.
+1 for this fix, it's quite unfortunate. Thank you @pdevito3 for publishing the modified package. Just wondering, would using manual assembly binding redirects for Bogus also be an option?
As a workaround you can use a CustomInstantiator on your class which sets the value like so:
public sealed class EntityFaker : AutoFaker<Entity>
{
public EntityFaker()
{
CustomInstantiator(faker =>
new Entity(DateOnly.FromDateTime(DateTime.UtcNow)));
}
}
@pdevito3 graciously implemented this in soenneker.utils.autobogus as well!
I have an entity that looks like this in a .NET 6 project:
When I run this faker:
in a test like this:
I get this error.
I know .NET 6 is new, but I have tons of use cases I'd like to refactor a
DateOnly
prop and this is a definite blocker with how my tests are currently set up :-(