Skip to content

Commit 4118ef0

Browse files
authored
Update dependencies for ReactiveUI 21.0.1 (#253)
* Update dependencies for ReactiveUI 21 * Update to resolve issues, Add test project * Create global.json * Update tests * Fix issues with the different TFM's
1 parent 1f6a70c commit 4118ef0

29 files changed

+609
-292
lines changed

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"msbuild-sdks": {
3+
"Uno.Sdk": "6.2.29"
4+
}
5+
}

src/Directory.Packages.props

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project ToolsVersion="15.0">
2+
<!--
3+
To update the version of Uno, you should instead update the Sdk version in the global.json file.
4+
5+
See https://aka.platform.uno/using-uno-sdk for more information.
6+
See https://aka.platform.uno/using-uno-sdk#implicit-packages for more information regarding the Implicit Packages.
7+
-->
8+
<ItemGroup>
9+
<PackageVersion Include="ReactiveUI.Testing" Version="21.0.1" />
10+
<PackageVersion Include="Splat" Version="16.1.1" />
11+
<PackageVersion Include="Moq" Version="4.20.70" />
12+
<PackageVersion Include="ReactiveUI" Version="21.0.1" />
13+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
14+
<PackageVersion Include="xunit" Version="2.9.3" />
15+
<PackageVersion Include="xunit.runner.console" Version="2.9.3" />
16+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.4" />
17+
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
18+
<PackageVersion Include="FluentAssertions" Version="8.6.0" />
19+
<PackageVersion Include="Microsoft.Reactive.Testing" Version="6.0.2" />
20+
<PackageVersion Include="PublicApiGenerator" Version="11.4.6" />
21+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
22+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
23+
<PackageVersion Include="stylecop.analyzers" Version="1.2.0-beta.556" />
24+
<PackageVersion Include="Roslynator.Analyzers" Version="4.14.0" />
25+
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4948" />
26+
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.7.250606001" />
27+
<PackageVersion Include="Newtonsoft.Json" VersionOverride="13.0.3" Version="13.0.3" />
28+
<PackageVersion Include="NUnit" VersionOverride="4.1.0" Version="4.4.0" />
29+
<PackageVersion Include="NUnit3TestAdapter" VersionOverride="4.5.0" Version="5.1.0" />
30+
</ItemGroup>
31+
</Project>

src/Directory.build.props

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,31 @@
3434
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
3535
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3636
<PackageTags>mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;frp;net;unoplatform</PackageTags>
37-
<UnoTargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-macos;net9.0;net9.0-android;net9.0-ios;net9.0-maccatalyst;net9.0-macos</UnoTargetFrameworks>
37+
<UnoTargetFrameworks>net9.0;net9.0-ios;net9.0-android;net9.0-browserwasm;net9.0-desktop;net9.0-windows10.0.19041.0</UnoTargetFrameworks>
3838

3939
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
4040
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
4141
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">30.0</SupportedOSPlatformVersion>
4242
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
4343
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
4444

45+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
46+
47+
<!--
48+
Adding NoWarn to remove build warnings 26100
49+
NU1507: Warning when there are multiple package sources when using CPM with no source mapping
50+
NETSDK1201: Warning that specifying RID won't create self containing app
51+
PRI257: Ignore default language (en) not being one of the included resources (eg en-us, en-uk)
52+
-->
53+
<NoWarn>$(NoWarn);NU1507;NETSDK1201;PRI257</NoWarn>
4554
</PropertyGroup>
4655

4756
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
4857
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
4958
</PropertyGroup>
50-
51-
<!--<ItemGroup Condition="$(IsTestProject)">
52-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
53-
<PackageReference Include="xunit" Version="2.9.0" />
54-
<PackageReference Include="xunit.runner.console" Version="2.9.0" />
55-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
56-
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
57-
<PackageReference Include="FluentAssertions" Version="6.12.0" />
58-
<PackageReference Include="Microsoft.Reactive.Testing" Version="6.0.1" />
59-
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
60-
<PackageReference Include="coverlet.msbuild" Version="6.0.2" PrivateAssets="All" />
61-
<PackageReference Include="Verify.Xunit" Version="26.4.5" />
62-
</ItemGroup>-->
6359

6460
<ItemGroup Condition="'$(IsTestProject)' != 'true'">
65-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
61+
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
6662
</ItemGroup>
6763

6864
<PropertyGroup>
@@ -76,9 +72,9 @@
7672
</ItemGroup>
7773

7874
<ItemGroup>
79-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.115" PrivateAssets="all" />
80-
<PackageReference Include="stylecop.analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
81-
<PackageReference Include="Roslynator.Analyzers" Version="4.14.0" PrivateAssets="All" />
75+
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
76+
<PackageReference Include="stylecop.analyzers" PrivateAssets="all" />
77+
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="All" />
8278
</ItemGroup>
8379
<ItemGroup>
8480
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
2+
// Licensed to reactiveui and contributors under one or more agreements.
3+
// The reactiveui and contributors licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using FluentAssertions;
7+
using Microsoft.UI.Xaml;
8+
using NUnit.Framework;
9+
10+
namespace ReactiveUI.Uno.Tests.Converters;
11+
12+
/// <summary>
13+
/// BooleanToVisibilityTypeConverterTests.
14+
/// </summary>
15+
[TestFixture]
16+
public class BooleanToVisibilityTypeConverterTests
17+
{
18+
private readonly BooleanToVisibilityTypeConverter _sut = new();
19+
20+
/// <summary>
21+
/// Affinities the is high for bool to visibility.
22+
/// </summary>
23+
[Test]
24+
public void Affinity_is_high_for_bool_to_visibility()
25+
{
26+
_sut.GetAffinityForObjects(typeof(bool), typeof(Visibility)).Should().Be(10);
27+
_sut.GetAffinityForObjects(typeof(Visibility), typeof(bool)).Should().Be(10);
28+
}
29+
30+
/// <summary>
31+
/// Convertses the bool to visibility.
32+
/// </summary>
33+
/// <param name="input">if set to <c>true</c> [input].</param>
34+
/// <param name="expected">The expected.</param>
35+
[TestCase(true, Visibility.Visible)]
36+
[TestCase(false, Visibility.Collapsed)]
37+
public void Converts_bool_to_visibility(bool input, Visibility expected)
38+
{
39+
_sut.TryConvert(input, typeof(Visibility), BooleanToVisibilityHint.None, out var result).Should().BeTrue();
40+
result.Should().Be(expected);
41+
}
42+
43+
/// <summary>
44+
/// Convertses the bool to visibility inverse.
45+
/// </summary>
46+
/// <param name="input">if set to <c>true</c> [input].</param>
47+
/// <param name="expected">The expected.</param>
48+
[TestCase(true, Visibility.Collapsed)]
49+
[TestCase(false, Visibility.Visible)]
50+
public void Converts_bool_to_visibility_inverse(bool input, Visibility expected)
51+
{
52+
_sut.TryConvert(input, typeof(Visibility), BooleanToVisibilityHint.Inverse, out var result).Should().BeTrue();
53+
result.Should().Be(expected);
54+
}
55+
56+
/// <summary>
57+
/// Convertses the visibility to bool.
58+
/// </summary>
59+
/// <param name="input">The input.</param>
60+
/// <param name="expected">if set to <c>true</c> [expected].</param>
61+
[TestCase(Visibility.Visible, true)]
62+
[TestCase(Visibility.Collapsed, false)]
63+
public void Converts_visibility_to_bool(Visibility input, bool expected)
64+
{
65+
_sut.TryConvert(input, typeof(bool), BooleanToVisibilityHint.None, out var result).Should().BeTrue();
66+
result.Should().Be(expected);
67+
}
68+
69+
/// <summary>
70+
/// Convertses the visibility to bool inverse.
71+
/// </summary>
72+
/// <param name="input">The input.</param>
73+
/// <param name="expected">if set to <c>true</c> [expected].</param>
74+
[TestCase(Visibility.Visible, false)]
75+
[TestCase(Visibility.Collapsed, true)]
76+
public void Converts_visibility_to_bool_inverse(Visibility input, bool expected)
77+
{
78+
_sut.TryConvert(input, typeof(bool), BooleanToVisibilityHint.Inverse, out var result).Should().BeTrue();
79+
result.Should().Be(expected);
80+
}
81+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
2+
// Licensed to reactiveui and contributors under one or more agreements.
3+
// The reactiveui and contributors licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using System.Linq.Expressions;
7+
using FluentAssertions;
8+
using Microsoft.UI.Xaml.Controls;
9+
using NUnit.Framework;
10+
11+
namespace ReactiveUI.Uno.Tests;
12+
13+
/// <summary>
14+
/// AutoDataTemplateBindingHookTests.
15+
/// </summary>
16+
[TestFixture]
17+
public class AutoDataTemplateBindingHookTests
18+
{
19+
/// <summary>
20+
/// Executes the hook sets default template when eligible.
21+
/// </summary>
22+
[Test]
23+
public void ExecuteHook_Sets_DefaultTemplate_When_Eligible()
24+
{
25+
var hook = new AutoDataTemplateBindingHook();
26+
ItemsControl ic;
27+
try
28+
{
29+
ic = new ItemsControl();
30+
}
31+
catch (System.Exception ex) when (ex is System.TypeInitializationException || ex is System.NotSupportedException)
32+
{
33+
Assert.Ignore("UI dispatcher not available for Uno/WinUI controls in this environment.");
34+
return;
35+
}
36+
37+
var vmChanges = Array.Empty<IObservedChange<object, object>>();
38+
var expr = (Expression<System.Func<object?>>)(() => ic.ItemsSource);
39+
var viewChanges = new[]
40+
{
41+
new ObservedChange<object, object>(ic, expr, new object())
42+
};
43+
44+
var result = hook.ExecuteHook(null, ic, () => vmChanges, () => viewChanges, BindingDirection.OneWay);
45+
result.Should().BeTrue();
46+
ic.ItemTemplate.Should().NotBeNull();
47+
}
48+
49+
/// <summary>
50+
/// Executes the hook does not override existing template.
51+
/// </summary>
52+
[Test]
53+
public void ExecuteHook_Does_Not_Override_Existing_Template()
54+
{
55+
var hook = new AutoDataTemplateBindingHook();
56+
ItemsControl ic;
57+
try
58+
{
59+
ic = new ItemsControl { ItemTemplate = AutoDataTemplateBindingHook.DefaultItemTemplate.Value };
60+
}
61+
catch (System.Exception ex) when (ex is System.TypeInitializationException || ex is System.NotSupportedException)
62+
{
63+
Assert.Ignore("UI dispatcher not available for Uno/WinUI controls in this environment.");
64+
return;
65+
}
66+
67+
var expr = (Expression<System.Func<object?>>)(() => ic.ItemsSource);
68+
var viewChanges = new[] { new ObservedChange<object, object>(ic, expr, new object()) };
69+
70+
var result = hook.ExecuteHook(null, ic, Array.Empty<IObservedChange<object, object>>, () => viewChanges, BindingDirection.OneWay);
71+
result.Should().BeTrue();
72+
ic.ItemTemplate.Should().NotBeNull();
73+
}
74+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
2+
// Licensed to reactiveui and contributors under one or more agreements.
3+
// The reactiveui and contributors licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using FluentAssertions;
7+
using NUnit.Framework;
8+
9+
namespace ReactiveUI.Uno.Tests.Platform;
10+
11+
/// <summary>
12+
/// Tests for PlatformOperations.
13+
/// </summary>
14+
[TestFixture]
15+
public class PlatformOperationsTests
16+
{
17+
/// <summary>
18+
/// Ensures GetOrientation returns either null or a string value without throwing.
19+
/// </summary>
20+
[Test]
21+
public void GetOrientation_has_valid_string_or_null()
22+
{
23+
var ops = new ReactiveUI.Uno.PlatformOperations();
24+
var orientation = ops.GetOrientation();
25+
26+
// Accept null or any string value
27+
(orientation == null || orientation.GetType() == typeof(string)).Should().BeTrue();
28+
}
29+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<IsTestProject>true</IsTestProject>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="FluentAssertions" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
13+
<PackageReference Include="Newtonsoft.Json" />
14+
<PackageReference Include="NUnit" />
15+
<PackageReference Include="NUnit3TestAdapter" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<ProjectReference Include="..\ReactiveUI.Uno\ReactiveUI.Uno.csproj" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) 2025 ReactiveUI and Contributors. All rights reserved.
2+
// Licensed to reactiveui and contributors under one or more agreements.
3+
// The reactiveui and contributors licenses this file to you under the MIT license.
4+
// See the LICENSE file in the project root for full license information.
5+
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Linq;
9+
using FluentAssertions;
10+
using NUnit.Framework;
11+
using ReactiveUI;
12+
using ReactiveUI.Uno;
13+
14+
namespace ReactiveUI.Uno.Tests;
15+
16+
/// <summary>
17+
/// RegistrationsTests.
18+
/// </summary>
19+
[TestFixture]
20+
public class RegistrationsTests
21+
{
22+
/// <summary>
23+
/// Resets the schedulers.
24+
/// </summary>
25+
[SetUp]
26+
public void ResetSchedulers()
27+
{
28+
// Reset to defaults before each test to avoid cross-test pollution.
29+
RxApp.MainThreadScheduler = null!;
30+
RxApp.TaskpoolScheduler = null!;
31+
}
32+
33+
/// <summary>
34+
/// Registers the registers expected services and configures schedulers.
35+
/// </summary>
36+
[Test]
37+
public void Register_RegistersExpectedServices_And_ConfiguresSchedulers()
38+
{
39+
var registered = new List<Type>();
40+
41+
void Register(Func<object> factory, Type serviceType)
42+
{
43+
// Don't invoke the factory here to avoid loading UI types in headless tests.
44+
registered.Add(serviceType);
45+
}
46+
47+
var sut = new Registrations();
48+
sut.Invoking(x => x.Register(Register)).Should().NotThrow();
49+
50+
// Verify the set of required service interfaces are registered
51+
registered.Should().Contain(typeof(IPlatformOperations));
52+
registered.Should().Contain(typeof(IActivationForViewFetcher));
53+
registered.Should().Contain(typeof(ICreatesObservableForProperty));
54+
registered.Should().Contain(typeof(IPropertyBindingHook));
55+
registered.Should().Contain(typeof(ISuspensionDriver));
56+
57+
// The implementation registers 16 binding converters + 2 hooks/services + 3 core services = 21 total
58+
// (String/byte(short/int/long/float/double/decimal) + nullable versions + BooleanToVisibility)
59+
registered.Count.Should().Be(21);
60+
61+
// Verify schedulers are set to safe defaults for headless environment
62+
RxApp.TaskpoolScheduler.Should().BeSameAs(System.Reactive.Concurrency.TaskPoolScheduler.Default);
63+
RxApp.MainThreadScheduler.Should().BeSameAs(System.Reactive.Concurrency.CurrentThreadScheduler.Instance);
64+
}
65+
66+
/// <summary>
67+
/// Registers the throws on null register function.
68+
/// </summary>
69+
[Test]
70+
public void Register_Throws_On_Null_RegisterFunction()
71+
{
72+
var sut = new Registrations();
73+
Action act = () => sut.Register(null!);
74+
act.Should().Throw<ArgumentNullException>();
75+
}
76+
}

0 commit comments

Comments
 (0)