Skip to content

Commit bdc5050

Browse files
committed
Feedback: explicit layout passing is not necessary when rendering with RouteView.
1 parent 90f6f0f commit bdc5050

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

src/Components/Components/src/LayoutAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ public LayoutAttribute([DynamicallyAccessedMembers(Component)] Type layoutType)
3636
/// The type of the layout. The type must implement <see cref="IComponent"/>
3737
/// and must accept a parameter with the name 'Body'.
3838
/// </summary>
39-
[DynamicallyAccessedMembers(Component)]
4039
public Type LayoutType { get; private set; }
4140
}

src/Components/Components/src/Routing/Router.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ static readonly IReadOnlyDictionary<string, object> _emptyParametersDictionary
4242

4343
private bool _onNavigateCalled;
4444

45-
[DynamicallyAccessedMembers(LinkerFlags.Component)]
46-
private Type? _notFoundLayoutType;
47-
4845
[Inject] private NavigationManager NavigationManager { get; set; }
4946

5047
[Inject] private INavigationInterception NavigationInterception { get; set; }
@@ -157,11 +154,7 @@ public async Task SetParametersAsync(ParameterView parameters)
157154
if (routeAttributes.Length == 0)
158155
{
159156
throw new InvalidOperationException($"The type {NotFoundPage.FullName} " +
160-
$"does not have a {typeof(RouteAttribute).FullName} applied to it.");
161-
}
162-
163-
var layoutAttr = NotFoundPage.GetTypeInfo().GetCustomAttribute<LayoutAttribute>();
164-
_notFoundLayoutType = layoutAttr?.LayoutType;
157+
$"does not have a {typeof(RouteAttribu
165158
}
166159

167160
if (!_onNavigateCalled)
@@ -401,10 +394,6 @@ private void RenderNotFound()
401394
builder.OpenComponent<RouteView>(0);
402395
builder.AddAttribute(1, nameof(RouteView.RouteData),
403396
new RouteData(NotFoundPage, _emptyParametersDictionary));
404-
if (_notFoundLayoutType is Type layoutType)
405-
{
406-
builder.AddAttribute(2, nameof(RouteView.DefaultLayout), layoutType);
407-
}
408397
builder.CloseComponent();
409398
}
410399
else if (NotFound != null)

0 commit comments

Comments
 (0)