From 1f54249f1cdcbb15445413ae2f47cf3dc7847db6 Mon Sep 17 00:00:00 2001 From: kronic Date: Thu, 30 Jul 2020 10:02:32 +0300 Subject: [PATCH 1/3] Add pragma warning disable 8600, 8605, 8603, 8613, 8619 --- .../ReactiveObject/Mocks/OaphNameOfTestFixture.cs | 2 ++ src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs | 2 ++ src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs | 8 ++++++++ src/ReactiveUI.Uno/CoreDispatcherScheduler.cs | 2 ++ .../Bindings/Property/PropertyBinderImplementation.cs | 4 ++++ src/ReactiveUI/Expression/Reflection.cs | 2 ++ 6 files changed, 20 insertions(+) diff --git a/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs b/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs index 1f4239622f..d4fdeedd0f 100644 --- a/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs +++ b/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs @@ -20,7 +20,9 @@ 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 8619 _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 8619 } [IgnoreDataMember] diff --git a/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs b/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs index ff8d64ecf5..77e318aa44 100644 --- a/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs +++ b/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs @@ -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 8613 get => _router; +#pragma warning restore 8613 #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); } diff --git a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs index 8947ae2699..e6557f1910 100644 --- a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs +++ b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs @@ -25,6 +25,7 @@ public void NullObservablesDoNotCauseExceptions() fixture.Command1 = null; // these are the overloads of WhenAnyObservable that perform a Merge +#pragma warning disable 8603 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(); @@ -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 8603 } [Fact] @@ -56,7 +58,9 @@ public async Task WhenAnyObservableSmokeTestCombining() var fixture = new TestWhenAnyObsViewModel(); var list = new List(); +#pragma warning disable 8603 fixture.WhenAnyObservable(x => x.Command3, x => x.Command1, (s, i) => s + " : " + i).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add); +#pragma warning restore 8603 Assert.Equal(0, list.Count); @@ -86,7 +90,9 @@ public async Task WhenAnyObservableSmokeTestMerging() var fixture = new TestWhenAnyObsViewModel(); var list = new List(); +#pragma warning disable 8603 fixture.WhenAnyObservable(x => x.Command1, x => x.Command2).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add); +#pragma warning restore 8603 Assert.Equal(0, list.Count); @@ -113,7 +119,9 @@ public async Task WhenAnyObservableSmokeTestMerging() public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore() { var fixture = new TestWhenAnyObsViewModel(); +#pragma warning disable 8603 fixture.WhenAnyObservable(x => x.Changes).Bind(out var output).ObserveOn(ImmediateScheduler.Instance).Subscribe(); +#pragma warning restore 8603 Assert.Equal(0, output.Count); diff --git a/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs index de999eff51..880b1ea52c 100644 --- a/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs +++ b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs @@ -178,7 +178,9 @@ private IDisposable ScheduleSlow(TState state, TimeSpan dueTime, Func(out TValue changeValue, o Expression lastExpression = expressions.Last(); #pragma warning disable CS8601 // Possible null reference assignment. +#pragma warning disable 8605 changeValue = (TValue)GetValueFetcherOrThrow(lastExpression.GetMemberInfo())(current, lastExpression.GetArgumentsArray()); +#pragma warning restore 8605 #pragma warning restore CS8601 // Possible null reference assignment. return true; } From 11cf9ccb6d89a3356af2714bd71dbf42e4f568ef Mon Sep 17 00:00:00 2001 From: kronic Date: Thu, 30 Jul 2020 12:23:17 +0300 Subject: [PATCH 2/3] Add CS prefix, comment --- .../ReactiveObject/Mocks/OaphNameOfTestFixture.cs | 5 ++--- src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs | 4 ++-- src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs | 4 ++-- src/ReactiveUI.Uno/CoreDispatcherScheduler.cs | 4 ++-- .../Bindings/Property/PropertyBinderImplementation.cs | 8 ++++---- src/ReactiveUI/Expression/Reflection.cs | 4 ++-- 6 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs b/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs index d4fdeedd0f..1374125741 100644 --- a/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs +++ b/src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs @@ -19,10 +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 8619 +#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 8619 +#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. } [IgnoreDataMember] diff --git a/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs b/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs index 77e318aa44..87adfc9202 100644 --- a/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs +++ b/src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs @@ -18,9 +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 8613 +#pragma warning disable CS8613 // Nullability of reference types in return type doesn't match implicitly implemented member. get => _router; -#pragma warning restore 8613 +#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); } diff --git a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs index e6557f1910..ddb2481838 100644 --- a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs +++ b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs @@ -119,9 +119,9 @@ public async Task WhenAnyObservableSmokeTestMerging() public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore() { var fixture = new TestWhenAnyObsViewModel(); -#pragma warning disable 8603 +#pragma warning disable CS8603 // Possible null reference return. fixture.WhenAnyObservable(x => x.Changes).Bind(out var output).ObserveOn(ImmediateScheduler.Instance).Subscribe(); -#pragma warning restore 8603 +#pragma warning restore CS8603 // Possible null reference return. Assert.Equal(0, output.Count); diff --git a/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs index 880b1ea52c..6577a7e237 100644 --- a/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs +++ b/src/ReactiveUI.Uno/CoreDispatcherScheduler.cs @@ -178,9 +178,9 @@ private IDisposable ScheduleSlow(TState state, TimeSpan dueTime, Func(out TValue changeValue, o Expression lastExpression = expressions.Last(); #pragma warning disable CS8601 // Possible null reference assignment. -#pragma warning disable 8605 +#pragma warning disable CS8605 // Unboxing a possibly null value. changeValue = (TValue)GetValueFetcherOrThrow(lastExpression.GetMemberInfo())(current, lastExpression.GetArgumentsArray()); -#pragma warning restore 8605 +#pragma warning restore CS8605 // Unboxing a possibly null value. #pragma warning restore CS8601 // Possible null reference assignment. return true; } From 69b598792bb0a187fb67815f29db01e02dda28f5 Mon Sep 17 00:00:00 2001 From: kronic Date: Thu, 30 Jul 2020 12:29:47 +0300 Subject: [PATCH 3/3] Add CS prefix, comment --- .../WhenAny/WhenAnyObservableTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs index ddb2481838..c65cc173de 100644 --- a/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs +++ b/src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs @@ -25,7 +25,7 @@ public void NullObservablesDoNotCauseExceptions() fixture.Command1 = null; // these are the overloads of WhenAnyObservable that perform a Merge -#pragma warning disable 8603 +#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(); @@ -49,7 +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 8603 +#pragma warning restore CS8603 // Possible null reference return. } [Fact] @@ -58,9 +58,9 @@ public async Task WhenAnyObservableSmokeTestCombining() var fixture = new TestWhenAnyObsViewModel(); var list = new List(); -#pragma warning disable 8603 +#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 8603 +#pragma warning restore CS8603 // Possible null reference return. Assert.Equal(0, list.Count); @@ -90,9 +90,9 @@ public async Task WhenAnyObservableSmokeTestMerging() var fixture = new TestWhenAnyObsViewModel(); var list = new List(); -#pragma warning disable 8603 +#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 8603 +#pragma warning restore CS8603 // Possible null reference return. Assert.Equal(0, list.Count);