Skip to content
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

Please support DateOnly params in constructors of sub view models or support it for MinDate property of the bp:DatePicker control #1791

Open
liviriniu opened this issue Mar 3, 2024 · 6 comments

Comments

@liviriniu
Copy link

Hi,

Currently it crashes if I use a DateOnly parameter in a primary constructor for a sub view model.

The primary constructor:
image

The crash log:
image

@exyi
Copy link
Member

exyi commented Mar 4, 2024 via email

@liviriniu
Copy link
Author

Yeees, sure. But... sigh 😿

@liviriniu
Copy link
Author

liviriniu commented Mar 6, 2024

Because then I must do the conversion in the markup for which, by the way, the intellisense does not suggest the
ToDateTime method.

image

... I was lazy in giving sufficient context in the issue content.

@liviriniu
Copy link
Author

liviriniu commented Mar 6, 2024

Which, although it makes the markup squiggly warning go away, it crashes with:

image

@liviriniu liviriniu changed the title Please support DateOnly params in constructors of sub view models Please support DateOnly params in constructors of sub view models or support it for MinDate property of the bp:DatePicker control Mar 6, 2024
@exyi
Copy link
Member

exyi commented Mar 7, 2024

It wouldn't be hard to add support for the ToDateTime method, but can't you simply change the constructor argument to DateTime? DateTime->DateOnly isn't even implicitly convertible, so the serializer fails legitimately.

(however, BP:DatePicker should just work with DateOnly)

@liviriniu
Copy link
Author

liviriniu commented Mar 8, 2024

BP:DatePicker simply crashes if I use DateOnly

image

but can't you simply change the constructor argument to DateTime?

Sure, this is how I currently go about because I have no choice. I can live with this because although the business logic/layer uses DateOnly as best practice / standard, the points of conversion are small and can get smaller (by encapsulating in an extension method):

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants