Skip to content

Commit def3e5c

Browse files
committed
Feedback - limit public API changes.
1 parent 19d3fe9 commit def3e5c

File tree

9 files changed

+20
-90
lines changed

9 files changed

+20
-90
lines changed

src/Components/Components/src/NavigationManager.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ public event EventHandler<NotFoundEventArgs> OnNotFound
6161
// The URI. Always represented an absolute URI.
6262
private string? _uri;
6363
private bool _isInitialized;
64-
private const string EnableThrowNavigationException = "Microsoft.AspNetCore.Components.Endpoints.HttpNavigationManager.EnableThrowNavigationException";
65-
66-
/// <summary>
67-
/// Gets a value indicating whether navigation exceptions should be thrown during navigation.
68-
/// </summary>
69-
/// <remarks>
70-
/// This property is controlled by the AppContext switch
71-
/// <c>Microsoft.AspNetCore.Components.Endpoints.HttpNavigationManager.EnableThrowNavigationException</c>.
72-
/// When enabled, navigation operations may throw exceptions for debugging or testing purposes.
73-
/// </remarks>
74-
protected static bool ThrowNavigationException =>
75-
AppContext.TryGetSwitch(EnableThrowNavigationException, out var switchValue) && switchValue;
7664

7765
/// <summary>
7866
/// Gets or sets the current base URI. The <see cref="BaseUri" /> is always represented as an absolute URI in string form with trailing slash.

src/Components/Components/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,4 @@ Microsoft.AspNetCore.Components.SupplyParameterFromPersistentComponentStateAttri
1010
Microsoft.AspNetCore.Components.SupplyParameterFromPersistentComponentStateAttribute.SupplyParameterFromPersistentComponentStateAttribute() -> void
1111
Microsoft.Extensions.DependencyInjection.SupplyParameterFromPersistentComponentStateProviderServiceCollectionExtensions
1212
static Microsoft.AspNetCore.Components.Infrastructure.RegisterPersistentComponentStateServiceCollectionExtensions.AddPersistentServiceRegistration<TService>(Microsoft.Extensions.DependencyInjection.IServiceCollection! services, Microsoft.AspNetCore.Components.IComponentRenderMode! componentRenderMode) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
13-
static Microsoft.Extensions.DependencyInjection.SupplyParameterFromPersistentComponentStateProviderServiceCollectionExtensions.AddSupplyValueFromPersistentComponentStateProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
14-
static Microsoft.AspNetCore.Components.NavigationManager.ThrowNavigationException.get -> bool
15-
Microsoft.AspNetCore.Components.Routing.NavigationEventArgs
16-
Microsoft.AspNetCore.Components.Routing.NavigationEventArgs.Uri.get -> string!
17-
Microsoft.AspNetCore.Components.Routing.NavigationEventArgs.NavigationEventArgs(string! uri) -> void
18-
Microsoft.AspNetCore.Components.Routing.IHostEnvironmentNavigationManager.OnNavigateTo -> System.EventHandler<Microsoft.AspNetCore.Components.Routing.NavigationEventArgs!>!
13+
static Microsoft.Extensions.DependencyInjection.SupplyParameterFromPersistentComponentStateProviderServiceCollectionExtensions.AddSupplyValueFromPersistentComponentStateProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!

src/Components/Components/src/Routing/IHostEnvironmentNavigationManager.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,4 @@ public interface IHostEnvironmentNavigationManager
1515
/// <param name="baseUri">The base URI.</param>
1616
/// <param name="uri">The absolute URI.</param>
1717
void Initialize(string baseUri, string uri);
18-
19-
/// <summary>
20-
/// An event that is triggered when SSR navigation occurs.
21-
/// </summary>
22-
/// <remarks>
23-
/// This event allows subscribers to respond to SSR navigation actions, such as updating state or performing side effects.
24-
/// </remarks>
25-
event EventHandler<NavigationEventArgs> OnNavigateTo;
2618
}

src/Components/Components/src/Routing/NavigationEventArgs.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Components/Endpoints/src/DependencyInjection/HttpNavigationManager.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,24 @@ namespace Microsoft.AspNetCore.Components.Endpoints;
77

88
internal sealed class HttpNavigationManager : NavigationManager, IHostEnvironmentNavigationManager
99
{
10-
private EventHandler<NavigationEventArgs>? _onNavigateTo;
11-
public event EventHandler<NavigationEventArgs> OnNavigateTo
12-
{
13-
add => _onNavigateTo += value;
14-
remove => _onNavigateTo -= value;
15-
}
10+
private const string _enableThrowNavigationException = "Microsoft.AspNetCore.Components.Endpoints.HttpNavigationManager.EnableThrowNavigationException";
11+
12+
private static bool _throwNavigationException =>
13+
AppContext.TryGetSwitch(_enableThrowNavigationException, out var switchValue) && switchValue;
1614

1715
void IHostEnvironmentNavigationManager.Initialize(string baseUri, string uri) => Initialize(baseUri, uri);
1816

1917
protected override void NavigateToCore(string uri, NavigationOptions options)
2018
{
2119
var absoluteUriString = ToAbsoluteUri(uri).AbsoluteUri;
22-
if (ThrowNavigationException)
20+
if (_throwNavigationException)
2321
{
2422
throw new NavigationException(absoluteUriString);
2523
}
2624
else
2725
{
28-
_onNavigateTo?.Invoke(this, new NavigationEventArgs(absoluteUriString));
26+
Uri = absoluteUriString;
27+
NotifyLocationChanged(isInterceptedLink: false);
2928
}
3029
}
3130
}

src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ internal async Task InitializeStandardComponentServicesAsync(
8484
if (navigationManager != null)
8585
{
8686
navigationManager.OnNotFound += SetNotFoundResponse;
87-
if (navigationManager is IHostEnvironmentNavigationManager hostEnvironmentNavigationManager)
88-
{
89-
hostEnvironmentNavigationManager.OnNavigateTo += OnNavigateTo;
90-
}
87+
navigationManager.LocationChanged += OnNavigateTo;
9188
}
9289

9390
var authenticationStateProvider = httpContext.RequestServices.GetService<AuthenticationStateProvider>();
@@ -139,9 +136,9 @@ internal async Task InitializeStandardComponentServicesAsync(
139136
}
140137
}
141138

142-
private void OnNavigateTo(object? sender, NavigationEventArgs args)
139+
private void OnNavigateTo(object? sender, LocationChangedEventArgs args)
143140
{
144-
_httpContext.Response.Redirect(args.Uri);
141+
_httpContext.Response.Redirect(args.Location);
145142
}
146143

147144
private static void InitializeResourceCollection(HttpContext httpContext)

src/Components/Endpoints/test/RazorComponentResultTest.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -510,14 +510,6 @@ class FakeDataProtector : IDataProtector
510510

511511
class FakeNavigationManager : NavigationManager, IHostEnvironmentNavigationManager
512512
{
513-
private EventHandler<NavigationEventArgs> _onNavigateTo;
514-
515-
public event EventHandler<NavigationEventArgs> OnNavigateTo
516-
{
517-
add => _onNavigateTo += value;
518-
remove => _onNavigateTo -= value;
519-
}
520-
521513
public new void Initialize(string baseUri, string uri)
522514
=> base.Initialize(baseUri, uri);
523515

src/Components/Server/src/Circuits/RemoteNavigationManager.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ internal sealed partial class RemoteNavigationManager : NavigationManager, IHost
1717
private readonly ILogger<RemoteNavigationManager> _logger;
1818
private IJSRuntime _jsRuntime;
1919
private bool? _navigationLockStateBeforeJsRuntimeAttached;
20-
private EventHandler<NavigationEventArgs>? _onNavigateTo;
21-
public event EventHandler<NavigationEventArgs> OnNavigateTo
22-
{
23-
add => _onNavigateTo += value;
24-
remove => _onNavigateTo -= value;
25-
}
20+
private const string _enableThrowNavigationException = "Microsoft.AspNetCore.Components.Endpoints.HttpNavigationManager.EnableThrowNavigationException";
21+
private static bool _throwNavigationException =>
22+
AppContext.TryGetSwitch(_enableThrowNavigationException, out var switchValue) && switchValue;
2623

2724
public event EventHandler<Exception>? UnhandledException;
2825

@@ -94,13 +91,14 @@ protected override void NavigateToCore(string uri, NavigationOptions options)
9491
if (_jsRuntime == null)
9592
{
9693
var absoluteUriString = ToAbsoluteUri(uri).AbsoluteUri;
97-
if (ThrowNavigationException)
94+
if (_throwNavigationException)
9895
{
9996
throw new NavigationException(absoluteUriString);
10097
}
10198
else
10299
{
103-
_onNavigateTo?.Invoke(this, new NavigationEventArgs(absoluteUriString));
100+
Uri = absoluteUriString;
101+
NotifyLocationChanged(isInterceptedLink: false);
104102
}
105103
}
106104

@@ -142,13 +140,14 @@ public override void Refresh(bool forceReload = false)
142140
if (_jsRuntime == null)
143141
{
144142
var absoluteUriString = ToAbsoluteUri(Uri).AbsoluteUri;
145-
if (ThrowNavigationException)
143+
if (_throwNavigationException)
146144
{
147145
throw new NavigationException(absoluteUriString);
148146
}
149147
else
150148
{
151-
_onNavigateTo?.Invoke(this, new NavigationEventArgs(absoluteUriString));
149+
Uri = absoluteUriString;
150+
NotifyLocationChanged(isInterceptedLink: false);
152151
}
153152
}
154153

src/Mvc/Mvc.TagHelpers/test/ComponentTagHelperTest.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)
104104

105105
class MockNavigationManager : NavigationManager, IHostEnvironmentNavigationManager
106106
{
107-
private EventHandler<NavigationEventArgs> _onNavigateTo;
108-
109-
public event EventHandler<NavigationEventArgs> OnNavigateTo
110-
{
111-
add => _onNavigateTo += value;
112-
remove => _onNavigateTo -= value;
113-
}
114-
115107
public MockNavigationManager()
116108
{
117109
Initialize("https://localhost:85/subdir/", "https://localhost:85/subdir/path?query=value#hash");

0 commit comments

Comments
 (0)