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

Blazor API Review: IUriHelper #12397

Closed
3 tasks done
rynowak opened this issue Jul 20, 2019 · 0 comments
Closed
3 tasks done

Blazor API Review: IUriHelper #12397

rynowak opened this issue Jul 20, 2019 · 0 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed

Comments

@rynowak
Copy link
Member

rynowak commented Jul 20, 2019

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) { }
    }
}
@rynowak rynowak added area-blazor Includes: Blazor, Razor Components API Review labels Jul 20, 2019
@rynowak rynowak added this to the 3.0.0-preview8 milestone Jul 20, 2019
@rynowak rynowak self-assigned this Jul 20, 2019
@danroth27 danroth27 mentioned this issue Jul 20, 2019
20 tasks
@rynowak rynowak added Done This issue has been fixed and removed Working labels Aug 2, 2019
@rynowak rynowak closed this as completed Aug 2, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

1 participant