Skip to content

Commit

Permalink
chore: fix incompatible setter for netstandard
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Sep 2, 2023
1 parent 5ac71a0 commit dcda09c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Prism.Ioc;
using Prism.Regions;
using Prism.Regions.Xaml;
using Xamarin.Forms;

namespace Prism.Behaviors
Expand Down
21 changes: 6 additions & 15 deletions src/Forms/Prism.Forms/Navigation/PageNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ protected async virtual Task<INavigationResult> GoBackInternal(INavigationParame
var canNavigate = await PageUtilities.CanNavigateAsync(page, segmentParameters);
if (!canNavigate)
{
return new NavigationResult
{
Exception = new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page)
};
return new NavigationResult(new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page));
}

bool useModalForDoPop = UseModalGoBack(page, useModalNavigation);
Expand All @@ -122,17 +119,14 @@ protected async virtual Task<INavigationResult> GoBackInternal(INavigationParame
}
catch (Exception ex)
{
return new NavigationResult { Exception = ex };
return new NavigationResult(ex);
}
finally
{
NavigationSource = PageNavigationSource.Device;
}

return new NavigationResult
{
Exception = GetGoBackException(page, _applicationProvider.MainPage)
};
return new NavigationResult(GetGoBackException(page, _applicationProvider.MainPage));
}

private static Exception GetGoBackException(Page currentPage, Page mainPage)
Expand Down Expand Up @@ -209,10 +203,7 @@ protected async virtual Task<INavigationResult> GoBackToRootInternal(INavigation
var canNavigate = await PageUtilities.CanNavigateAsync(page, parameters);
if (!canNavigate)
{
return new NavigationResult
{
Exception = new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page)
};
return new NavigationResult(new NavigationException(NavigationException.IConfirmNavigationReturnedFalse, page));
}

List<Page> pagesToDestroy = page.Navigation.NavigationStack.ToList(); // get all pages to destroy
Expand All @@ -234,7 +225,7 @@ protected async virtual Task<INavigationResult> GoBackToRootInternal(INavigation
}
catch (Exception ex)
{
return new NavigationResult { Exception = ex };
return new NavigationResult(ex);
}
}

Expand Down Expand Up @@ -361,7 +352,7 @@ protected async virtual Task<INavigationResult> NavigateInternal(Uri uri, INavig
}
catch (Exception ex)
{
return new NavigationResult { Exception = ex };
return new NavigationResult(ex);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static async Task<INavigationResult> SelectTabAsync(this INavigationServi
}
catch (Exception ex)
{
return new NavigationResult { Exception = ex };
return new NavigationResult(ex);
}

return new NavigationResult();
Expand Down
10 changes: 2 additions & 8 deletions src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,7 @@ internal static bool UseReverseNavigation(Page currentPage, Type nextPageType)

private INavigationResult Notify(NavigationRequestType type, INavigationParameters parameters, Exception exception = null)
{
var result = new NavigationResult
{
Exception = exception
};
var result = new NavigationResult(exception);
_eventAggregator.GetEvent<NavigationRequestEvent>().Publish(new NavigationRequestContext
{
Parameters = parameters,
Expand All @@ -1158,10 +1155,7 @@ private INavigationResult Notify(NavigationRequestType type, INavigationParamete

private INavigationResult Notify(Uri uri, INavigationParameters parameters, Exception exception = null)
{
var result = new NavigationResult
{
Exception = exception
};
var result = new NavigationResult(exception);

var temp = Regex.Replace(uri.ToString(), RemovePageInstruction, RemovePageRelativePath);

Expand Down
15 changes: 12 additions & 3 deletions src/Prism.Core/Navigation/NavigationResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Prism.Navigation;
/// <summary>
/// Default implementation for the <see cref="INavigationResult"/>
/// </summary>
public record NavigationResult : INavigationResult
public class NavigationResult : INavigationResult
{
private readonly bool? _success;

Expand All @@ -27,6 +27,15 @@ public NavigationResult(bool success)
_success = success;
}

/// <summary>
/// Initializes a new NavigationResult with an <see cref="Exception"/>
/// </summary>
/// <param name="ex">The <see cref="Exception"/> encountered as part of the navigation.</param>
public NavigationResult(Exception ex)
{
Exception = ex;
}

/// <summary>
/// Initializes a new NavigationResult
/// </summary>
Expand Down Expand Up @@ -58,8 +67,8 @@ Exception is NavigationException navigationException
&& navigationException.Message == NavigationException.IConfirmNavigationReturnedFalse;

/// <inheritdoc />
public Exception? Exception { get; init; }
public Exception? Exception { get; }

/// <inheritdoc />
public NavigationContext? Context { get; init; }
public NavigationContext? Context { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void Execute_GoBackTypeDefault_NavigationParameters_HasKnownNavigationPar
{
parameters = navParameters;
})
.ReturnsAsync(new NavigationResult { Exception = new Exception() });
.ReturnsAsync(new NavigationResult(new Exception()));

var registry = container.Resolve<NavigationRegistry>();
var page = registry.CreateView(container, "PageMock") as Page;
Expand Down Expand Up @@ -125,7 +125,7 @@ public void Execute_GoBackTypeToRoot_NavigationParameters_DoNotHaveKnownNavigati
{
parameters = navParameters;
})
.ReturnsAsync(new NavigationResult { Exception = new Exception() });
.ReturnsAsync(new NavigationResult(new Exception()));

var registry = container.Resolve<NavigationRegistry>();
var page = registry.CreateView(container, "PageMock") as Page;
Expand Down Expand Up @@ -159,7 +159,7 @@ public void Execute_GoBackTypeDefault_CommandParameter_IncludedInNavigationParam
{
parameters = navParameters;
})
.ReturnsAsync(new NavigationResult { Exception = new Exception() });
.ReturnsAsync(new NavigationResult(new Exception()));

var registry = container.Resolve<NavigationRegistry>();
var page = registry.CreateView(container, "PageMock") as Page;
Expand Down Expand Up @@ -192,7 +192,7 @@ public void Execute_GoBackTypeToRoot_CommandParameter_IncludedInNavigationParame
{
parameters = navParameters;
})
.ReturnsAsync(new NavigationResult { Exception = new Exception() });
.ReturnsAsync(new NavigationResult(new Exception()));

var registry = container.Resolve<NavigationRegistry>();
var page = registry.CreateView(container, "PageMock") as Page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void Execute_NavigationParameters_HasKnownNavigationParameters(bool anima
{
parameters = navParameters;
})
.ReturnsAsync(new NavigationResult { Exception = new Exception() });
.ReturnsAsync(new NavigationResult(new Exception()));

var registry = container.Resolve<NavigationRegistry>();
var page = registry.CreateView(container, "PageMock") as Page;
Expand Down

0 comments on commit dcda09c

Please sign in to comment.