Skip to content

Commit

Permalink
Use MemberNotNullWhen to remove workaround for isLeased
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed May 27, 2023
1 parent 0045365 commit db7c54a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions osu.Framework/Bindables/Bindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using JetBrains.Annotations;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -430,6 +430,7 @@ void ISerializableBindable.DeserializeFrom(JsonReader reader, JsonSerializer ser

private LeasedBindable<T>? leasedBindable;

[MemberNotNullWhen(true, nameof(leasedBindable))]
private bool isLeased => leasedBindable != null;

/// <summary>
Expand Down

0 comments on commit db7c54a

Please sign in to comment.