bchavez / Bogus

:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Other
8.66k stars 495 forks source link

Random Date/Time Only #397

Closed rgarrison12345 closed 2 years ago

rgarrison12345 commented 2 years ago

Please describe why you are requesting a feature

With .NET 6 comes the new DateOnly and TimeOnly types. Would like to see a random value for both of these types just like random generators for date time and datetimeoffset.

Please provide a code example of what you are trying to achieve

(Please be complete. Include all code necessary to run your example in LINQPad.) (The more complete code examples are, the more accurate answers will be.) (https://www.linqpad.net)

Please answer any or all of the questions below

If the feature request is approved, would you be willing to submit a PR?

Yes / No (Help can be provided if you need assistance submitting a PR) Yes

bchavez commented 2 years ago

Sounds good - I think we can do this. However, some points:

The bad part about this is that the Bogus.nupkg is going to grow in size by another factor because we are shipping a new net6 specific TFM/DLL.

prasadtelkikar commented 2 years ago

Hi @bchavez ,

I am new to this repository but following it from long time. If @rgarrison12345 did not started working on this open issue, I would like to contribute to this repository.

@rgarrison12345 can I go ahead and try this out?

bchavez commented 2 years ago

Hey @prasadtelkikar, cool! That's fine with me. I'm sure we can all collaborate on it.

However, for whoever works on the PR initially, please just a few tips to keep in mind would be great:

Thanks so much @prasadtelkikar and @rgarrison12345. All these tips should help the review/merge process go smoothly.

rgarrison12345 commented 2 years ago

Hello @prasadtelkikar you can take on the PR if you would like.

prasadtelkikar commented 2 years ago

Hi @bchavez,

I just shared a design document for this feature implementation. I would like to know your thoughts on it. @rgarrison12345 I did not find your email address. I can forward you the same email if you would like to go through it.

bchavez commented 2 years ago

@prasadtelkikar , you can post the design doc in the Discussions tab: https://github.com/bchavez/Bogus/discussions

I would say, Approach 1: Add new functions to Date dataset instead of using inheritance.

For an initial start, here's the methods I would start with:

When implementing Approach 1, try to keep all of these new methods grouped into one code section (at the end of Date.cs) so that #if NET6 / #endif directive is only used once.

pdevito3 commented 2 years ago

I'm also running in to this and am blocked from some refactoring I was hoping to start tackling. Details here if it helps: https://github.com/nickdodd79/AutoBogus/issues/76

@bchavez those options would work well for my use cases

Also, looks like AppVeyor has .NET 6 support so shouldn't be any blockers there anymore based on your note :-)

bchavez commented 2 years ago

Hi @pdevito3, thanks a bunch for checking in and linking to the AppVeyor news. That's great.

After reading the news, looks like we're going to need a tooling update to get access to .NET 6.

https://github.com/bchavez/Bogus/blob/1406a8ba7ae326dca106bbf5bb827fcd7e47be82/appveyor.yml#L2

So, it looks like there is still some blocking work we need to do before merging a Date/TimeOnly PR.

Basically, we need to update our 1) AppVeyor image and 2) my tooling on my local dev box, and 3) our tests working on the .NET 6 SDK before we can merge a Date/TimeOnly PR.

bchavez commented 2 years ago

This is done now. Thanks for the help @prasadtelkikar!

It's very late right now... but I'll make a new release within the next few days.

pdevito3 commented 2 years ago

thanks guys! 🎉

bchavez commented 2 years ago

Hey all, Bogus v34.0.1 released with .NET 6 support for DateOnly and TimeOnly.