Skip to content

Conversation

maxkatz6
Copy link
Member

@maxkatz6 maxkatz6 commented Feb 14, 2025

A small improvement with more user-friendly validation.

What is the current behavior?

Before this PR it was possible to break the layout by passing invalid property value, by passing negative font size.
It is somewhat important, since user can now handle unhandled dispatcher exception and continue app running, with broken layout.

What is the updated/expected behavior with this PR?

With this PR, FontSize property will validate input values itself, and throw validation exception, discarding any invalid input from being actually set.
It's also consistent with WPF behavior. Although there is a difference in which values are allowed, as WPF only allows range 0.003...16000. But Avalonia doesn't enforce these limitations.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054910-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 merged commit 355cf16 into master Feb 15, 2025
11 checks passed
@maxkatz6 maxkatz6 deleted the fontsize-property-validation branch February 15, 2025 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants