From db7c54a63bebdda86a9d758b7a4e5eab6e0edf76 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Sat, 27 May 2023 21:53:46 +0800 Subject: [PATCH] Use MemberNotNullWhen to remove workaround for isLeased --- osu.Framework/Bindables/Bindable.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Framework/Bindables/Bindable.cs b/osu.Framework/Bindables/Bindable.cs index 2692b2d3fd..316cda7e63 100644 --- a/osu.Framework/Bindables/Bindable.cs +++ b/osu.Framework/Bindables/Bindable.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using JetBrains.Annotations; @@ -371,9 +372,8 @@ public void UnbindBindings() internal virtual void UnbindAllInternal() { - // TODO: annotate isLeased with [MemberNotNull(nameof(leasedBindable))] on .NET 5+ to satisfy the nullability check if (isLeased) - leasedBindable.AsNonNull().Return(); + leasedBindable.Return(); UnbindEvents(); UnbindBindings(); @@ -430,6 +430,7 @@ void ISerializableBindable.DeserializeFrom(JsonReader reader, JsonSerializer ser private LeasedBindable? leasedBindable; + [MemberNotNullWhen(true, nameof(leasedBindable))] private bool isLeased => leasedBindable != null; ///