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

Nullable annotations for AvaloniaObject/AvaloniaProperty etc. #7078

Merged
merged 4 commits into from
Dec 7, 2021

Conversation

grokys
Copy link
Member

@grokys grokys commented Dec 6, 2021

What does the pull request do?

Adds nullable annotations to AvaloniaObject/AvaloniaProperty-related classes and a few other uncontroversial files.

...to `AvaloniaObject`/`AvaloniaProperty`-related classes and a few other uncontroversial files.
@@ -279,14 +273,14 @@ public abstract class AvaloniaProperty : IEquatable<AvaloniaProperty>, IProperty
/// <returns>A <see cref="AvaloniaProperty{TValue}"/></returns>
public static AttachedProperty<TValue> RegisterAttached<TOwner, THost, TValue>(
string name,
TValue defaultValue = default(TValue),
TValue defaultValue = default!,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, and the other default! expressions in this file isn't great. Problem is that default is an invalid value if TValue is not nullable and there's not really any way to fix this without breaking changes.

For 11.0 we probably need to supply separate class and struct property registration overloads and only provide a default value for the struct overloads, but this would be a (pretty big) breaking change.

@grokys grokys mentioned this pull request Dec 7, 2021
13 tasks
@maxkatz6 maxkatz6 enabled auto-merge (squash) December 7, 2021 18:21
@maxkatz6 maxkatz6 merged commit dc3415c into master Dec 7, 2021
@maxkatz6 maxkatz6 deleted the fixes/avalonia-object-property-nullability branch December 7, 2021 18:37
danwalmsley pushed a commit that referenced this pull request Dec 7, 2021
* Add nullable annotations...

...to `AvaloniaObject`/`AvaloniaProperty`-related classes and a few other uncontroversial files.

* Check for null before first use.

* Don't need this check as base class does it.
# Conflicts:
#	src/Avalonia.Styling/Styling/Activators/PropertyEqualsActivator.cs
#	src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs
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