Skip to content

Commit

Permalink
Update annotations with latest usages
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Nov 27, 2024
1 parent 6804bda commit 9c9b8ad
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion osu.Framework/Bindables/AggregateBindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void RemoveSource(IBindable<T> bindable)
return null;
}

private void recalculateAggregate(ValueChangedEvent<T> obj = null)
private void recalculateAggregate(ValueChangedEvent<T>? obj = null)
{
T calculated = initialValue;

Expand Down
6 changes: 3 additions & 3 deletions osu.Framework/Bindables/Bindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private void addWeakReference(WeakReference<Bindable<T>> weakReference)
/// </summary>
/// <param name="input">The input which is to be parsed.</param>
/// <param name="provider">An object that provides culture-specific formatting information about <paramref name="input"/>.</param>
public virtual void Parse(object input, IFormatProvider provider)
public virtual void Parse(object? input, IFormatProvider provider)
{
switch (input)
{
Expand All @@ -261,7 +261,7 @@ public virtual void Parse(object input, IFormatProvider provider)
// Nullable value types and reference types (annotated or not) are allowed to be initialised with `null`.
if (typeof(T).IsNullable() || typeof(T).IsClass)
{
Value = default;
Value = default!;
break;
}

Expand All @@ -281,7 +281,7 @@ public virtual void Parse(object input, IFormatProvider provider)
// Nullable value types and reference types are initialised to `null` on empty strings.
if (typeof(T).IsNullable() || typeof(T).IsClass)
{
Value = default;
Value = default!;
break;
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Bindables/BindableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ int IList.Add(object? value)
/// <param name="input">The input which is to be parsed.</param>
/// <param name="provider">Not valid for <see cref="BindableList{T}"/>.</param>
/// <exception cref="InvalidOperationException">Thrown if this <see cref="BindableList{T}"/> is <see cref="Disabled"/>.</exception>
public void Parse(object input, IFormatProvider provider)
public void Parse(object? input, IFormatProvider provider)
{
ensureMutationAllowed();

Expand Down
20 changes: 10 additions & 10 deletions osu.Framework/Bindables/RangeConstrainedBindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,25 @@ public float NormalizedValue
private static float convertToSingle(T val)
{
if (typeof(T) == typeof(sbyte))
return Convert.ToSingle((sbyte)(object)val);
return Convert.ToSingle((sbyte)(object)val!);
if (typeof(T) == typeof(byte))
return Convert.ToSingle((byte)(object)val);
return Convert.ToSingle((byte)(object)val!);
if (typeof(T) == typeof(short))
return Convert.ToSingle((short)(object)val);
return Convert.ToSingle((short)(object)val!);
if (typeof(T) == typeof(ushort))
return Convert.ToSingle((ushort)(object)val);
return Convert.ToSingle((ushort)(object)val!);
if (typeof(T) == typeof(int))
return Convert.ToSingle((int)(object)val);
return Convert.ToSingle((int)(object)val!);
if (typeof(T) == typeof(uint))
return Convert.ToSingle((uint)(object)val);
return Convert.ToSingle((uint)(object)val!);
if (typeof(T) == typeof(long))
return Convert.ToSingle((long)(object)val);
return Convert.ToSingle((long)(object)val!);
if (typeof(T) == typeof(ulong))
return Convert.ToSingle((ulong)(object)val);
return Convert.ToSingle((ulong)(object)val!);
if (typeof(T) == typeof(double))
return Convert.ToSingle((double)(object)val);
return Convert.ToSingle((double)(object)val!);
if (typeof(T) == typeof(float))
return (float)(object)val;
return (float)(object)val!;

throw new InvalidOperationException();
}
Expand Down

0 comments on commit 9c9b8ad

Please sign in to comment.