Skip to content

Commit

Permalink
Update InspectCode nullability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Nov 27, 2024
1 parent 9c9b8ad commit 7e4284e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Bindables/AggregateBindableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void TestResultBounds()
[Test]
public void TestClassAggregate()
{
var aggregate = new AggregateBindable<BoxedInt>((a, b) => new BoxedInt((a?.Value ?? 0) + (b?.Value ?? 0)));
var aggregate = new AggregateBindable<BoxedInt>((a, b) => new BoxedInt((a.Value) + (b.Value)));

Check failure on line 53 in osu.Framework.Tests/Bindables/AggregateBindableTest.cs

View workflow job for this annotation

GitHub Actions / Results

osu.Framework.Tests.Bindables.AggregateBindableTest ► TestClassAggregate

Failed test found in: TestResults-Linux-MultiThreaded-Debug.trx TestResults-Linux-SingleThread-Debug.trx Error: System.NullReferenceException : Object reference not set to an instance of an object.
Raw output
System.NullReferenceException : Object reference not set to an instance of an object.
   at osu.Framework.Tests.Bindables.AggregateBindableTest.<>c.<TestClassAggregate>b__2_0(BoxedInt a, BoxedInt b) in /home/runner/work/osu-framework/osu-framework/osu.Framework.Tests/Bindables/AggregateBindableTest.cs:line 53
   at osu.Framework.Bindables.AggregateBindable`1.recalculateAggregate(ValueChangedEvent`1 obj) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/AggregateBindable.cs:line 99
   at osu.Framework.Bindables.Bindable`1.BindValueChanged(Action`1 onChange, Boolean runOnceImmediately) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/Bindable.cs:line 221
   at osu.Framework.Bindables.AggregateBindable`1.AddSource(IBindable`1 bindable) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/AggregateBindable.cs:line 53
   at osu.Framework.Tests.Bindables.AggregateBindableTest.TestClassAggregate() in /home/runner/work/osu-framework/osu-framework/osu.Framework.Tests/Bindables/AggregateBindableTest.cs:line 58
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Check failure on line 53 in osu.Framework.Tests/Bindables/AggregateBindableTest.cs

View workflow job for this annotation

GitHub Actions / Results

osu.Framework.Tests.Bindables.AggregateBindableTest ► TestClassAggregate

Failed test found in: TestResults-Linux-MultiThreaded-Release.trx TestResults-Linux-SingleThread-Release.trx Error: System.NullReferenceException : Object reference not set to an instance of an object.
Raw output
System.NullReferenceException : Object reference not set to an instance of an object.
   at osu.Framework.Tests.Bindables.AggregateBindableTest.<>c.<TestClassAggregate>b__2_0(BoxedInt a, BoxedInt b) in /home/runner/work/osu-framework/osu-framework/osu.Framework.Tests/Bindables/AggregateBindableTest.cs:line 53
   at osu.Framework.Bindables.AggregateBindable`1.recalculateAggregate(ValueChangedEvent`1 obj) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/AggregateBindable.cs:line 88
   at osu.Framework.Bindables.Bindable`1.BindValueChanged(Action`1 onChange, Boolean runOnceImmediately) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/Bindable.cs:line 221
   at osu.Framework.Bindables.AggregateBindable`1.AddSource(IBindable`1 bindable) in /home/runner/work/osu-framework/osu-framework/osu.Framework/Bindables/AggregateBindable.cs:line 53
   at osu.Framework.Tests.Bindables.AggregateBindableTest.TestClassAggregate() in /home/runner/work/osu-framework/osu-framework/osu.Framework.Tests/Bindables/AggregateBindableTest.cs:line 58
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Assert.AreEqual(null, aggregate.Result.Value);

Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Bindables/BindableDoubleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void TestParsingNumberLocale(double value, string locale, string expected
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(locale);

var bindable = new BindableDouble(value);
string? asString = bindable.ToString();
string asString = bindable.ToString();
Assert.AreEqual(expected, asString);
Assert.DoesNotThrow(() => bindable.Parse(asString, CultureInfo.CurrentCulture));
Assert.AreEqual(value, bindable.Value, Precision.DOUBLE_EPSILON);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Bindables/BindableFloatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void TestParsingNumberLocale(float value, string locale, string expected)
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo(locale);

var bindable = new BindableFloat(value);
string? asString = bindable.ToString();
string asString = bindable.ToString();
Assert.AreEqual(expected, asString);
Assert.DoesNotThrow(() => bindable.Parse(asString, CultureInfo.CurrentCulture));
Assert.AreEqual(value, bindable.Value, Precision.FLOAT_EPSILON);
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework.Tests/Bindables/BindableLeasingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void TestDoubleLeaseFails()
public void TestIncorrectEndLease()
{
// end a lease when no lease exists.
Assert.Throws<InvalidOperationException>(() => original.EndLease(null));
Assert.Throws<InvalidOperationException>(() => original.EndLease(null!));

// end a lease with an incorrect bindable
original.BeginLease(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ protected override void LoadComplete()
}));
}

private void updateText() => valueText.Text = bindable.ToString() ?? "<null>";
private void updateText() => valueText.Text = bindable?.ToString() ?? "<null>";

Check failure on line 62 in osu.Framework.Tests/Visual/Platform/FrameworkConfigVisualiser.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Conditional access qualifier expression is never null according to nullable reference types' annotations in osu.Framework.Tests\Visual\Platform\FrameworkConfigVisualiser.cs on line 62
}
}

0 comments on commit 7e4284e

Please sign in to comment.