question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feedback on IsDefault and Default members

See original GitHub issue

There was PR https://github.com/AvaloniaUI/Avalonia/pull/9590 changing member names IsDefault and Default instead of IsEmpty and Empty. While old names using Empty can be used for area types like Rect they were much better than the current ones for a few reasons:

  • There’s default keyword not requiring any methods to be added, i.e. use == default or is default.
  • New names provide no sematic meaning. What is Default for the current case?

So I suggest to go back to Empty/IsEmpty or use Zero/IsZero instead. The last one is applicable to any numeric type, including vectors and in addition to that it’s a way forward to generic math even if it’s impossible to implement INumberBase<TSelf> for some types like Rect and Point (vector types can support generic math, by the way).

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Reactions:3
  • Comments:35 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
maxkatz6commented, Mar 9, 2023

Add IsZero/Zero for numerical types and leave the rest alone. This still wouldn’t fix the original inconsistent usage of IsEmpty and IsDefault though and we would now have Zero, Empty (for 1-2 types) and then Default.

Point, Size, Rect - remove Empty/Default. In the future we can add Zero to support INumeric APIs from .NET 7. It’s a good idea in general, but isn’t useful before we implement these interfaces. Which won’t happen in 11.0.

CornerRadius, Thickness - wpf doesn’t have anything for these, I wouldn’t add anything as well. Developers should use c# “default”.

Color, Rect - remove Empty/Default as it’s not consistent by behavior with WPF and Avalonia.

FontFamily - keep Default. Remove/make internal IsDefault (as suggested by @Gillibald).

Everything else (from original PR including boxshadow) - just use “default” C#, remove Empty/Default.

Discussed internally, and hopefully had an agreement.

1reaction
robloocommented, Mar 8, 2023

@MikeCodesDotNet @maxkatz6 Can this be added to 11.0 milestone? It needs to be resolved one way or another before API release and it’s on my todo list.

Either:

  1. Revert API changes due to complaints and just leave it unorganized in this area and not matching WPF. Shouldn’t revert the PR though as it had a few other fixes. As far as I can tell it’s one or two strong complaints though, I don’t know who is otherwise OK with it.
  2. Add IsZero/Zero for numerical types and leave the rest alone. This still wouldn’t fix the original inconsistent usage of IsEmpty and IsDefault though and we would now have Zero, Empty (for 1-2 types) and then Default.
  3. Just use Zero and IsZero for everything that is checking for Zero properties (whether numerical type or not). That would replace Empty terminology. There will still be some other types using the Default terminology though related to font and some of the newer classes.

Of course I’ll get to it myself but it will be a week or so and you’ll have to accept the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feedback on IsDefault and Default members · Issue #10264
There was PR #9590 changing member names IsDefault and Default instead of IsEmpty and Empty. While old names using Empty can be used...
Read more >
Button.IsDefaulted Property (System.Windows.Controls)
Gets a value that indicates whether a Button is the button that is activated when a user presses ENTER.
Read more >
Button.IsDefault Property (System.Windows.Controls)
Gets or sets a value that indicates whether a Button is the default button. A user invokes the default button by pressing the...
Read more >
Is default initializing class members always advisable?
To follow the advice, I have to explicitly initialize bar (e.g. int bar{}; ). But what if I always initialize the member by...
Read more >
What is default visibility for properties/methods in ...
Members or properties which have “protected” visibility are accessible only in their class or their subclasses. In this example, the protected ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found