Skip to content

Commit

Permalink
Housekeeping: add pragma warnings disables
Browse files Browse the repository at this point in the history
* Add pragma warning disable 8600, 8605, 8603, 8613, 8619

* Add CS prefix, comment

* Add CS prefix, comment

Co-authored-by: kronic <[email protected]>
  • Loading branch information
kronic and kronic authored Jul 30, 2020
1 parent 31d3961 commit a8ff550
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public class OaphNameOfTestFixture : TestFixture
public OaphNameOfTestFixture()
{
this.WhenAnyValue(x => x.IsOnlyOneWord).Select(x => x ?? string.Empty).Select(x => x.Length >= 3 ? x.Substring(0, 3) : x).ToProperty(this, nameof(FirstThreeLettersOfOneWord), out _firstThreeLettersOfOneWord);

#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
_lastThreeLettersOfOneWord = this.WhenAnyValue(x => x.IsOnlyOneWord).Select(x => x ?? string.Empty).Select(x => x.Length >= 3 ? x.Substring(x.Length - 3, 3) : x).ToProperty(this, nameof(LastThreeLettersOfOneWord));
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.
}

[IgnoreDataMember]
Expand Down
2 changes: 2 additions & 0 deletions src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public class TestScreen : ReactiveObject, IScreen
public RoutingState? Router
{
#pragma warning disable CS8766 // Nullability of reference types in return type doesn't match implicitly implemented member (possibly because of nullability attributes).
#pragma warning disable CS8613 // Nullability of reference types in return type doesn't match implicitly implemented member.
get => _router;
#pragma warning restore CS8613 // Nullability of reference types in return type doesn't match implicitly implemented member.
#pragma warning restore CS8766 // Nullability of reference types in return type doesn't match implicitly implemented member (possibly because of nullability attributes).
set => this.RaiseAndSetIfChanged(ref _router, value);
}
Expand Down
8 changes: 8 additions & 0 deletions src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void NullObservablesDoNotCauseExceptions()
fixture.Command1 = null;

// these are the overloads of WhenAnyObservable that perform a Merge
#pragma warning disable CS8603 // Possible null reference return.
fixture.WhenAnyObservable(x => x.Command1).Subscribe();
fixture.WhenAnyObservable(x => x.Command1, x => x.Command1).Subscribe();
fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
Expand All @@ -48,6 +49,7 @@ public void NullObservablesDoNotCauseExceptions()
fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight) => Unit.Default).Subscribe();
fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight, nine) => Unit.Default).Subscribe();
fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight, nine, ten) => Unit.Default).Subscribe();
#pragma warning restore CS8603 // Possible null reference return.
}

[Fact]
Expand All @@ -56,7 +58,9 @@ public async Task WhenAnyObservableSmokeTestCombining()
var fixture = new TestWhenAnyObsViewModel();

var list = new List<string>();
#pragma warning disable CS8603 // Possible null reference return.
fixture.WhenAnyObservable(x => x.Command3, x => x.Command1, (s, i) => s + " : " + i).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add);
#pragma warning restore CS8603 // Possible null reference return.

Assert.Equal(0, list.Count);

Expand Down Expand Up @@ -86,7 +90,9 @@ public async Task WhenAnyObservableSmokeTestMerging()
var fixture = new TestWhenAnyObsViewModel();

var list = new List<int>();
#pragma warning disable CS8603 // Possible null reference return.
fixture.WhenAnyObservable(x => x.Command1, x => x.Command2).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add);
#pragma warning restore CS8603 // Possible null reference return.

Assert.Equal(0, list.Count);

Expand All @@ -113,7 +119,9 @@ public async Task WhenAnyObservableSmokeTestMerging()
public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore()
{
var fixture = new TestWhenAnyObsViewModel();
#pragma warning disable CS8603 // Possible null reference return.
fixture.WhenAnyObservable(x => x.Changes).Bind(out var output).ObserveOn(ImmediateScheduler.Instance).Subscribe();
#pragma warning restore CS8603 // Possible null reference return.

Assert.Equal(0, output.Count);

Expand Down
2 changes: 2 additions & 0 deletions src/ReactiveUI.Uno/CoreDispatcherScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ private IDisposable ScheduleSlow<TState>(TState state, TimeSpan dueTime, Func<IS
finally
{
t.Stop();
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
action = null;
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,19 @@ bool VmToViewFunc(TVMProp vmValue, out TVProp vValue)
{
var result = vmToViewConverter.TryConvert(vmValue, typeof(TVProp), conversionHint, out object? tmp);

#pragma warning disable CS8605 // Unboxing a possibly null value.
vValue = result ? (TVProp)tmp : default;
#pragma warning restore CS8605 // Unboxing a possibly null value.
return result;
}

bool ViewToVmFunc(TVProp vValue, out TVMProp vmValue)
{
var result = viewToVMConverter.TryConvert(vValue, typeof(TVMProp), conversionHint, out object? tmp);

#pragma warning disable CS8605 // Unboxing a possibly null value.
vmValue = result ? (TVMProp)tmp : default;
#pragma warning restore CS8605 // Unboxing a possibly null value.
return result;
}
#pragma warning restore CS8601 // Possible null reference assignment.
Expand Down
2 changes: 2 additions & 0 deletions src/ReactiveUI/Expression/Reflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ public static bool TryGetValueForPropertyChain<TValue>(out TValue changeValue, o

Expression lastExpression = expressions.Last();
#pragma warning disable CS8601 // Possible null reference assignment.
#pragma warning disable CS8605 // Unboxing a possibly null value.
changeValue = (TValue)GetValueFetcherOrThrow(lastExpression.GetMemberInfo())(current, lastExpression.GetArgumentsArray());
#pragma warning restore CS8605 // Unboxing a possibly null value.
#pragma warning restore CS8601 // Possible null reference assignment.
return true;
}
Expand Down

0 comments on commit a8ff550

Please sign in to comment.