Skip to content

Commit 085b46b

Browse files
authored
fix for WhenAny WhenAnyValue ToProperty (#2860)
* Update WhenAny WhenAnyValue to use nullable for selector * fix ToProperty Need to add tests * Update ReactiveUI.sln * Update WhenAny / WhenAnyValue Add test * Put packages back to V12 need to fix Splat.DryIoc to complete V12 update * Update DryIoc to V12 pending Splat release
1 parent 259f4aa commit 085b46b

18 files changed

+738
-621
lines changed

src/ReactiveUI.Fody.Helpers/ObservableAsPropertyExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public static class ObservableAsPropertyExtensions
3333
/// </exception>
3434
public static ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(
3535
this IObservable<TRet> item,
36-
TObj? source,
37-
Expression<Func<TObj, TRet?>> property,
36+
TObj source,
37+
Expression<Func<TObj, TRet>> property,
3838
bool deferSubscription = false,
3939
IScheduler? scheduler = null)
4040
where TObj : ReactiveObject
@@ -88,8 +88,8 @@ public static ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(
8888
/// </exception>
8989
public static ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(
9090
this IObservable<TRet> item,
91-
TObj? source,
92-
Expression<Func<TObj, TRet?>> property,
91+
TObj source,
92+
Expression<Func<TObj, TRet>> property,
9393
TRet initialValue,
9494
bool deferSubscription = false,
9595
IScheduler? scheduler = null)

src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.ReactiveUIFody.net5.0.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace ReactiveUI.Fody.Helpers
1414
}
1515
public static class ObservableAsPropertyExtensions
1616
{
17-
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj? source, System.Linq.Expressions.Expression<System.Func<TObj, TRet?>> property, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
17+
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
1818
where TObj : ReactiveUI.ReactiveObject { }
19-
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj? source, System.Linq.Expressions.Expression<System.Func<TObj, TRet?>> property, TRet initialValue, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
19+
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, TRet initialValue, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
2020
where TObj : ReactiveUI.ReactiveObject { }
2121
}
2222
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.All)]

src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.ReactiveUIFody.netcoreapp3.1.approved.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ namespace ReactiveUI.Fody.Helpers
1414
}
1515
public static class ObservableAsPropertyExtensions
1616
{
17-
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj? source, System.Linq.Expressions.Expression<System.Func<TObj, TRet?>> property, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
17+
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
1818
where TObj : ReactiveUI.ReactiveObject { }
19-
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj? source, System.Linq.Expressions.Expression<System.Func<TObj, TRet?>> property, TRet initialValue, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
19+
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> item, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, TRet initialValue, bool deferSubscription = false, System.Reactive.Concurrency.IScheduler? scheduler = null)
2020
where TObj : ReactiveUI.ReactiveObject { }
2121
}
2222
[System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.All)]

src/ReactiveUI.Splat.Tests/ReactiveUI.Splat.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
@@ -10,7 +10,7 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Splat.Autofac" Version="12.*" />
13-
<PackageReference Include="Splat.DryIoc" Version="11.*" />
13+
<PackageReference Include="Splat.DryIoc" Version="12.*" />
1414
<PackageReference Include="Splat.Ninject" Version="12.*" />
1515
</ItemGroup>
1616

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net472.approved.txt

Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net5.0.approved.txt

Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp3.1.approved.txt

Lines changed: 67 additions & 67 deletions
Large diffs are not rendered by default.

src/ReactiveUI.Tests/Mocks/MockBindListView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public MockBindListView()
5555
.Where(i => i != null)
5656
.Cast<MockBindListItemViewModel>()
5757
.Do(_ => ItemList.UnselectAll())
58-
.InvokeCommand(this, v => v.ViewModel!.SelectItem).DisposeWith(d);
58+
.InvokeCommand(this, v => v!.ViewModel!.SelectItem).DisposeWith(d);
5959
});
6060
}
6161

src/ReactiveUI.Tests/ObservableAsPropertyHelper/ObservableAsPropertyHelperTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@ public void ToProperty_NameOf_ValidValuesProduced(string[] testWords, string[] f
456456

457457
fixture.ObservableForProperty(x => x.LastThreeLettersOfOneWord, beforeChange: true).ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var lastThreeChanging).Subscribe();
458458

459-
var changing = new[] { firstThreeChanging, lastThreeChanging };
459+
var changing = new[] { firstThreeChanging!, lastThreeChanging };
460460

461461
fixture.ObservableForProperty(x => x.FirstThreeLettersOfOneWord, beforeChange: false).ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var firstThreeChanged).Subscribe();
462462

463463
fixture.ObservableForProperty(x => x.LastThreeLettersOfOneWord, beforeChange: false).ToObservableChangeSet(ImmediateScheduler.Instance).Bind(out var lastThreeChanged).Subscribe();
464464

465-
var changed = new[] { firstThreeChanged, lastThreeChanged };
465+
var changed = new[] { firstThreeChanged!, lastThreeChanged };
466466

467467
Assert.True(changed.All(x => x.Count == 0));
468468
Assert.True(changing.All(x => x.Count == 0));
@@ -551,11 +551,11 @@ public void NullableTypesTestShouldntNeedDecorators2_ToProperty()
551551
fixture.WhenAnyValue(
552552
x => x.ProjectService.ProjectsNullable,
553553
x => x.AccountService.AccountUsersNullable)
554-
.Where(tuple => tuple.Item1.Any() && tuple.Item2.Any())
554+
.Where(tuple => tuple.Item1?.Count > 0 && tuple.Item2?.Count > 0)
555555
.Select(tuple =>
556556
{
557557
var (projects, users) = tuple;
558-
return (int?)users.Values.Count(x => !string.IsNullOrWhiteSpace(x?.LastName));
558+
return users?.Values.Count(x => !string.IsNullOrWhiteSpace(x?.LastName));
559559
})
560560
.ToProperty(fixture, x => x.AccountsFound, out fixture._accountsFound);
561561

src/ReactiveUI.Tests/Resolvers/DependencyResolverTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ private static Dictionary<Type, List<Type>> GetServicesThatShouldBeRegistered(IR
145145

146146
new Registrations().Register((factory, serviceType) =>
147147
{
148-
if (serviceTypeToImplementationTypes.TryGetValue(serviceType, out var implementationTypes) == false)
148+
if (serviceTypeToImplementationTypes.TryGetValue(serviceType!, out var implementationTypes) == false)
149149
{
150150
implementationTypes = new List<Type>();
151-
serviceTypeToImplementationTypes.Add(serviceType, implementationTypes);
151+
serviceTypeToImplementationTypes.Add(serviceType!, implementationTypes);
152152
}
153153

154-
implementationTypes.Add(factory().GetType());
154+
implementationTypes.Add(factory()!.GetType());
155155
});
156156

157157
new PlatformRegistrations().Register((factory, serviceType) =>

0 commit comments

Comments
 (0)