Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactoring navigation #906

Merged
merged 16 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions samples/Playground/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.3.0" />
<PackageVersion Include="Uno.Material" Version="2.3.0" />
<PackageVersion Include="Uno.Material.WinUI" Version="2.3.0" />
<PackageVersion Include="Uno.Toolkit.UI" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.Toolkit.UI.Material" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.UI" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.RemoteControl" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Skia.Gtk" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Skia.Tizen" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Skia.Wpf" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.WebAssembly" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.Toolkit.UI" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.Toolkit.UI.Material" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.Toolkit.WinUI.Material" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.UI" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19" />
<PackageVersion Include="Uno.UI.RemoteControl" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Skia.Gtk" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Skia.Tizen" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Skia.Wpf" Version="4.6.19" />
<PackageVersion Include="Uno.UI.WebAssembly" Version="4.6.19" />
<PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="3.3.1" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="3.3.1" />
<PackageVersion Include="Uno.WinUI" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.WinUI" Version="4.6.19" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,11 @@
</PropertyGroup>

<Import Project="Uno.CrossTargeting.props" />

<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).UI" />
<InternalsVisibleTo Include="$(AssemblyName).WinUI" />
<InternalsVisibleTo Include="$(AssemblyName).Tests" />
<InternalsVisibleTo Include="TestHarnessApp" />
</ItemGroup>
</Project>
18 changes: 9 additions & 9 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@
<PackageVersion Include="Uno.Extensions.Logging.OSLog" Version="1.3.0" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.3.0" />
<PackageVersion Include="Uno.Roslyn" Version="1.3.0-dev.12" />
<PackageVersion Include="Uno.Toolkit.UI" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="2.4.0-dev.85" />
<PackageVersion Include="Uno.UI" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.0-dev.947"/>
<PackageVersion Include="Uno.UI.MSAL" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.UI.Runtime.WebAssembly" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.WinUI" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.WinUI.MSAL" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.WinUI.Runtime.WebAssembly" Version="4.6.0-dev.947" />
<PackageVersion Include="Uno.Toolkit.UI" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.Toolkit.WinUI" Version="2.4.0-dev.114" />
<PackageVersion Include="Uno.UI" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19"/>
<PackageVersion Include="Uno.UI.MSAL" Version="4.6.19" />
<PackageVersion Include="Uno.UI.Runtime.WebAssembly" Version="4.6.19" />
<PackageVersion Include="Uno.WinUI" Version="4.6.19" />
<PackageVersion Include="Uno.WinUI.MSAL" Version="4.6.19" />
<PackageVersion Include="Uno.WinUI.Runtime.WebAssembly" Version="4.6.19" />
<PackageVersion Include="coverlet.collector" Version="3.1.2" />
<PackageVersion Include="xunit" Version="2.4.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,4 @@
<ItemGroup>
<ProjectReference Include="Uno.Extensions.Authentication.MSAL.WinUI.Wasm.csproj" ReferenceOutputAssembly="false" LinkLibraryDependencies="false" CopyLocal="false" SkipGetTargetFrameworkProperties="true" GlobalPropertiesToRemove="TargetFramework" />
</ItemGroup>

<ItemGroup>
<SourceGeneratorInput Remove="buildTransitive\Uno.Extensions.Authentication.MSAL.WinUI.props" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
<PackageReference Include="System.Threading.Tasks.Extensions" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).UI" />
<InternalsVisibleTo Include="$(AssemblyName).WinUI" />
<InternalsVisibleTo Include="$(AssemblyName).Msal.UI" />
<InternalsVisibleTo Include="$(AssemblyName).Msal.WinUI" />
<InternalsVisibleTo Include="$(AssemblyName).Oidc.UI" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<CompilerVisibleProperty Include="UnoExtensionsGeneration_DisableModuleInitializerAttribute" />
</ItemGroup>

<Target Name="_InjectUnoExtensionsCoreGenerators" BeforeTargets="BeforeCompile;_UnoSourceGenerator">
<Target Name="_InjectUnoExtensionsCoreGenerators" BeforeTargets="BeforeCompile;MarkupCompilePass1">
<ItemGroup>
<Analyzer
Include="$(MSBuildThisFileDirectory)..\bin\Uno.Extensions.Core.Generators\$(Configuration)\netstandard2.0\Uno.Extensions.Core.Generators.dll"
Expand Down
26 changes: 0 additions & 26 deletions src/Uno.Extensions.Navigation.Tests/BaseNavigationTests.cs

This file was deleted.

5 changes: 5 additions & 0 deletions src/Uno.Extensions.Navigation.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
global using System.Collections.Generic;
global using System.Threading.Tasks;
global using FluentAssertions;
global using Microsoft.VisualStudio.TestTools.UnitTesting;
global using Moq;

This file was deleted.

33 changes: 0 additions & 33 deletions src/Uno.Extensions.Navigation.Tests/NavigationServiceTests.cs

This file was deleted.

35 changes: 35 additions & 0 deletions src/Uno.Extensions.Navigation.Tests/NavigatorExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

namespace Uno.Extensions.Navigation.Tests;

[TestClass]
public class NavigatorExtensionsTests
{
[TestMethod]
public async Task RedirectForNavigationDataTest()
{
var mockNavigator = new Mock<INavigator>();
mockNavigator
.Setup(n => n.NavigateAsync(It.IsAny<NavigationRequest>()))
.Returns(Task.FromResult<NavigationResponse?>(new NavigationResponse(Success:true)));

var resolver = new Mock<IRouteResolver>();

var request = new NavigationRequest(this, new Route(Data: new Dictionary<string, object>() { { "", new object() } } ));


// There's no matching routemap, so no redirect (ie returns null)
var response = mockNavigator.Object.RedirectForNavigationData(resolver.Object, request);
response.Should().BeNull();


resolver
.Setup(r => r.FindByData(typeof(object), It.IsAny<INavigator>()))
.Returns(new RouteInfo("home"));

// When there's a matching route, Navigate method on Navigator should be called
response = mockNavigator.Object.RedirectForNavigationData(resolver.Object, request);
response.Should().NotBeNull();
var result = await response!;
result!.Success.Should().BeTrue();
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Uno.Extensions.Navigation\Uno.Extensions.Navigation.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Moq" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>obj/g</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="MSTest.TestAdapter" />
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Moq" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Uno.Extensions.Navigation\Uno.Extensions.Navigation.csproj" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions src/Uno.Extensions.Navigation.UI/NavigationRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@ public static class NavigationRequestExtensions

return default;
}

public static NavigationRequest AsInternal(this NavigationRequest request)
{
return request with { Route = request.Route.AsInternal() };
}

public static NavigationRequest IncludeDependentRoutes(this NavigationRequest request, IRouteResolver resolver)
{
var rm = resolver.FindByPath(request.Route.Base);
while (rm?.DependsOnRoute is not null)
{
request = request with { Route = (request.Route with { Base = rm.DependsOnRoute.Path, Path = null }).Append(request.Route) };
rm = rm.DependsOnRoute;
}
return request;
}
}
Loading