Skip to content

Commit 9a2181b

Browse files
committed
Clean up
1 parent af10763 commit 9a2181b

File tree

7 files changed

+19
-21
lines changed

7 files changed

+19
-21
lines changed

src/Components/Endpoints/src/Assets/LinkPreload.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,35 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
5-
6-
// Licensed to the .NET Foundation under one or more agreements.
7-
// The .NET Foundation licenses this file to you under the MIT license.
8-
9-
104
using Microsoft.AspNetCore.Components.Endpoints;
115
using Microsoft.AspNetCore.Components.Rendering;
126

137
namespace Microsoft.AspNetCore.Components;
148

15-
public class LinkPreload : IComponent
9+
/// <summary>
10+
/// Represents link elements for preloading assets.
11+
/// </summary>
12+
public sealed class LinkPreload : IComponent
1613
{
1714
private RenderHandle renderHandle;
1815
private List<PreloadAsset>? assets;
1916

2017
[Inject]
21-
internal ResourcePreloadService Service { get; set; }
18+
internal ResourcePreloadService? Service { get; set; }
2219

23-
public void Attach(RenderHandle renderHandle)
20+
void IComponent.Attach(RenderHandle renderHandle)
2421
{
2522
this.renderHandle = renderHandle;
2623
}
2724

28-
public Task SetParametersAsync(ParameterView parameters)
25+
Task IComponent.SetParametersAsync(ParameterView parameters)
2926
{
30-
Service.SetPreloadHook(PreloadGroup);
27+
Service?.SetPreloadingHandler(PreloadAssets);
3128
renderHandle.Render(RenderPreloadAssets);
3229
return Task.CompletedTask;
3330
}
3431

35-
private void PreloadGroup(List<PreloadAsset> assets)
32+
private void PreloadAssets(List<PreloadAsset> assets)
3633
{
3734
if (this.assets != null)
3835
{

src/Components/Endpoints/src/Builder/ResourceCollectionConvention.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Microsoft.AspNetCore.Components;
55
using Microsoft.AspNetCore.Components.Endpoints;
66
using Microsoft.AspNetCore.Components.Web;
7-
using Microsoft.AspNetCore.Routing;
87

98
namespace Microsoft.AspNetCore.Builder;
109

src/Components/Endpoints/src/Builder/ResourcePreloadCollection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Components.Endpoints;
57

68
internal class ResourcePreloadCollection
@@ -94,7 +96,7 @@ private static PreloadAsset CreateAsset(string url, IEnumerable<ResourceAssetPro
9496
return resourceAsset;
9597
}
9698

97-
public bool TryGetAssets(string group, out List<PreloadAsset> assets)
99+
public bool TryGetAssets(string group, [MaybeNullWhen(false)] out List<PreloadAsset> assets)
98100
=> _storage.TryGetValue(group, out assets);
99101
}
100102

src/Components/Endpoints/src/Builder/ResourcePreloadService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ internal class ResourcePreloadService
77
{
88
private Action<List<PreloadAsset>>? handler;
99

10-
public void SetPreloadHook(Action<List<PreloadAsset>> handler)
10+
public void SetPreloadingHandler(Action<List<PreloadAsset>> handler)
1111
=> this.handler = handler;
1212

1313
public void Preload(List<PreloadAsset> assets)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#nullable enable
2+
Microsoft.AspNetCore.Components.LinkPreload
3+
Microsoft.AspNetCore.Components.LinkPreload.LinkPreload() -> void
24
Microsoft.Extensions.DependencyInjection.RazorComponentsRazorComponentBuilderExtensions
35
static Microsoft.Extensions.DependencyInjection.RazorComponentsRazorComponentBuilderExtensions.RegisterPersistentService<TPersistentService>(this Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder! builder, Microsoft.AspNetCore.Components.IComponentRenderMode! renderMode) -> Microsoft.Extensions.DependencyInjection.IRazorComponentsBuilder!

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Microsoft.Extensions.DependencyInjection;
1313
using Microsoft.Extensions.Hosting;
1414
using Microsoft.Extensions.Options;
15-
using Microsoft.Extensions.Primitives;
1615

1716
namespace Microsoft.AspNetCore.Components.Endpoints;
1817

src/Components/Endpoints/src/Rendering/SSRRenderModeBoundary.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Diagnostics;
66
using System.Diagnostics.CodeAnalysis;
77
using System.Globalization;
8-
using System.Net.Http;
98
using Microsoft.AspNetCore.Builder;
109
using Microsoft.AspNetCore.Components.Rendering;
1110
using Microsoft.AspNetCore.Components.Web;
@@ -29,7 +28,7 @@ internal class SSRRenderModeBoundary : IComponent
2928
private RenderHandle _renderHandle;
3029
private IReadOnlyDictionary<string, object?>? _latestParameters;
3130
private ComponentMarkerKey? _markerKey;
32-
private HttpContext _httpContext;
31+
private readonly HttpContext _httpContext;
3332

3433
public IComponentRenderMode RenderMode { get; }
3534

@@ -109,10 +108,10 @@ public Task SetParametersAsync(ParameterView parameters)
109108

110109
ValidateParameters(_latestParameters);
111110

112-
// Preload WebAssembly assets when using WebAssembly (not Auto) mode
113111
if (RenderMode is InteractiveWebAssemblyRenderMode)
114112
{
115-
AppendWebAssemblyPreloadAssets();
113+
// Preload WebAssembly assets when using WebAssembly (not Auto) mode
114+
PreloadWebAssemblyAssets();
116115
}
117116

118117
if (_prerender)
@@ -123,7 +122,7 @@ public Task SetParametersAsync(ParameterView parameters)
123122
return Task.CompletedTask;
124123
}
125124

126-
private void AppendWebAssemblyPreloadAssets()
125+
private void PreloadWebAssemblyAssets()
127126
{
128127
var preloads = _httpContext.GetEndpoint()?.Metadata.GetMetadata<ResourcePreloadCollection>();
129128
if (preloads != null && preloads.TryGetAssets("webassembly", out var preloadAssets))

0 commit comments

Comments
 (0)