Skip to content

Blazor API Review: IUriHelper #12397

Closed
Closed
@rynowak

Description

@rynowak

Summary

The URI Helper class is used for navigation as well as understanding the current URI . We want to retain the current functionality here but change the API for more maintainability.

Additionally we want to rename this class to be distinct from the IUrlHelper concept in MVC. The Blazor API doesn't fill the same role (getting current state VS generating URLs). Also the MVC naming is bad.

Action Items

  • Make abstract class instead
  • Rename IUriHelper -> NavigationManager
  • Get rid of public implementations (replace with Hub Method in server)

APIs

namespace Microsoft.AspNetCore.Components
{
    public partial interface IUriHelper
    {
        event System.EventHandler<Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs> OnLocationChanged;
        string GetAbsoluteUri();
        string GetBaseUri();
        void NavigateTo(string uri);
        void NavigateTo(string uri, bool forceLoad);
        System.Uri ToAbsoluteUri(string href);
        string ToBaseRelativePath(string baseUri, string locationAbsolute);
    }
    public abstract partial class UriHelperBase : Microsoft.AspNetCore.Components.IUriHelper
    {
        protected UriHelperBase() { }
        public event System.EventHandler<Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs> OnLocationChanged { add { } remove { } }
        protected virtual void EnsureInitialized() { }
        public string GetAbsoluteUri() { throw null; }
        public virtual string GetBaseUri() { throw null; }
        public virtual void InitializeState(string uriAbsolute, string baseUriAbsolute) { }
        public void NavigateTo(string uri) { }
        public void NavigateTo(string uri, bool forceLoad) { }
        protected abstract void NavigateToCore(string uri, bool forceLoad);
        protected void SetAbsoluteBaseUri(string baseUri) { }
        protected void SetAbsoluteUri(string uri) { }
        public System.Uri ToAbsoluteUri(string href) { throw null; }
        public string ToBaseRelativePath(string baseUri, string locationAbsolute) { throw null; }
        protected void TriggerOnLocationChanged(bool isinterceptedLink) { }
    }
}
namespace Microsoft.AspNetCore.Components.Routing
{
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    public readonly partial struct LocationChangedEventArgs
    {
        private readonly object _dummy;
        private readonly int _dummyPrimitive;
        public LocationChangedEventArgs(string location, bool isNavigationIntercepted) { throw null; }
        public bool IsNavigationIntercepted { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
        public string Location { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
    }
}
namespace Microsoft.AspNetCore.Components.Server.Circuits
{
    public partial class RemoteUriHelper : Microsoft.AspNetCore.Components.UriHelperBase
    {
        public RemoteUriHelper(Microsoft.Extensions.Logging.ILogger<Microsoft.AspNetCore.Components.Server.Circuits.RemoteUriHelper> logger) { }
        public bool HasAttachedJSRuntime { get { throw null; } }
        public override void InitializeState(string uriAbsolute, string baseUriAbsolute) { }
        protected override void NavigateToCore(string uri, bool forceLoad) { }
        [Microsoft.JSInterop.JSInvokableAttribute("NotifyLocationChanged")]
        public static void NotifyLocationChanged(string uriAbsolute, bool isInterceptedLink) { }
    }
}

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions