From cfc9bf11990c614a38e9ea2b3fde3a90a18676a9 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Wed, 8 May 2024 00:53:13 +0200 Subject: [PATCH] Wire up conventions through MapStaticAssetEndpoints, use fallback otherwise --- ...omponentEndpointConventionBuilderHelper.cs | 7 ++++ .../RazorComponentEndpointDataSource.cs | 5 +-- ...RazorComponentEndpointDataSourceFactory.cs | 2 +- ...azorComponentsEndpointConventionBuilder.cs | 8 ++++- .../Endpoints/src/PublicAPI.Unshipped.txt | 1 + .../Endpoints/test/HotReloadServiceTests.cs | 16 ++++++++- .../RazorComponentEndpointDataSourceTest.cs | 16 ++++++++- .../Server/Startup.cs | 7 +--- .../WebAssemblyComponentsEndpointOptions.cs | 1 + ...entsEndpointConventionBuilderExtensions.cs | 34 +++++++++++++++++++ ...setsEndpointConventionBuilderExtensions.cs | 6 ++-- .../Server/src/PublicAPI.Unshipped.txt | 1 - ...ssemblyRazorComponentsBuilderExtensions.cs | 28 ++++++--------- .../RazorComponentEndpointsStartup.cs | 2 +- .../RemoteAuthenticationStartup.cs | 1 - src/StaticAssets/src/PublicAPI.Unshipped.txt | 5 +++ .../src/StaticAssetEndpointDataSource.cs | 15 ++++++-- 17 files changed, 117 insertions(+), 38 deletions(-) diff --git a/src/Components/Endpoints/src/Builder/ComponentEndpointConventionBuilderHelper.cs b/src/Components/Endpoints/src/Builder/ComponentEndpointConventionBuilderHelper.cs index 6b0001f949e0b..e718b481060a3 100644 --- a/src/Components/Endpoints/src/Builder/ComponentEndpointConventionBuilderHelper.cs +++ b/src/Components/Endpoints/src/Builder/ComponentEndpointConventionBuilderHelper.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Routing; namespace Microsoft.AspNetCore.Components.Endpoints.Infrastructure; @@ -19,5 +20,11 @@ public static void AddRenderMode(RazorComponentsEndpointConventionBuilder builde { builder.AddRenderMode(renderMode); } + + /// + /// This method is not recommended for use outside of the Blazor framework. + /// + /// + public static IEndpointRouteBuilder GetEndpointRouteBuilder(RazorComponentsEndpointConventionBuilder builder) => builder.EndpointRouteBuilder; } diff --git a/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs b/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs index 06d3113f36e30..d7ce3ca90bc91 100644 --- a/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs +++ b/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSource.cs @@ -39,12 +39,12 @@ internal class RazorComponentEndpointDataSource<[DynamicallyAccessedMembers(Comp public RazorComponentEndpointDataSource( ComponentApplicationBuilder builder, IEnumerable renderModeEndpointProviders, - IApplicationBuilder applicationBuilder, + IEndpointRouteBuilder endpointRouteBuilder, RazorComponentEndpointFactory factory, HotReloadService? hotReloadService = null) { _builder = builder; - _applicationBuilder = applicationBuilder; + _applicationBuilder = endpointRouteBuilder.CreateApplicationBuilder(); _renderModeEndpointProviders = renderModeEndpointProviders.ToArray(); _factory = factory; _hotReloadService = hotReloadService; @@ -52,6 +52,7 @@ internal class RazorComponentEndpointDataSource<[DynamicallyAccessedMembers(Comp DefaultBuilder = new RazorComponentsEndpointConventionBuilder( _lock, builder, + endpointRouteBuilder, _options, _conventions, _finallyConventions); diff --git a/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSourceFactory.cs b/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSourceFactory.cs index 3dcee668151a2..462fc50a2268c 100644 --- a/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSourceFactory.cs +++ b/src/Components/Endpoints/src/Builder/RazorComponentEndpointDataSourceFactory.cs @@ -31,6 +31,6 @@ internal class RazorComponentEndpointDataSourceFactory var builder = ComponentApplicationBuilder.GetBuilder() ?? DefaultRazorComponentApplication.Instance.GetBuilder(); - return new RazorComponentEndpointDataSource(builder, _providers, endpoints.CreateApplicationBuilder(), _factory, _hotReloadService); + return new RazorComponentEndpointDataSource(builder, _providers, endpoints, _factory, _hotReloadService); } } diff --git a/src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilder.cs b/src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilder.cs index 0f01bf70091a0..54e7e35b2ea39 100644 --- a/src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilder.cs +++ b/src/Components/Endpoints/src/Builder/RazorComponentsEndpointConventionBuilder.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Discovery; using Microsoft.AspNetCore.Components.Endpoints; +using Microsoft.AspNetCore.Routing; namespace Microsoft.AspNetCore.Builder; @@ -14,6 +15,7 @@ public sealed class RazorComponentsEndpointConventionBuilder : IEndpointConventi { private readonly object _lock; private readonly ComponentApplicationBuilder _builder; + private readonly IEndpointRouteBuilder _endpointRouteBuilder; private readonly RazorComponentDataSourceOptions _options; private readonly List> _conventions; private readonly List> _finallyConventions; @@ -21,12 +23,14 @@ public sealed class RazorComponentsEndpointConventionBuilder : IEndpointConventi internal RazorComponentsEndpointConventionBuilder( object @lock, ComponentApplicationBuilder builder, + IEndpointRouteBuilder endpointRouteBuilder, RazorComponentDataSourceOptions options, List> conventions, List> finallyConventions) { _lock = @lock; _builder = builder; + _endpointRouteBuilder = endpointRouteBuilder; _options = options; _conventions = conventions; _finallyConventions = finallyConventions; @@ -37,6 +41,8 @@ public sealed class RazorComponentsEndpointConventionBuilder : IEndpointConventi /// internal ComponentApplicationBuilder ApplicationBuilder => _builder; + internal IEndpointRouteBuilder EndpointRouteBuilder => _endpointRouteBuilder; + /// public void Add(Action convention) { @@ -64,6 +70,6 @@ public void Finally(Action finallyConvention) internal void AddRenderMode(IComponentRenderMode renderMode) { _options.ConfiguredRenderModes.Add(renderMode); - } + } } diff --git a/src/Components/Endpoints/src/PublicAPI.Unshipped.txt b/src/Components/Endpoints/src/PublicAPI.Unshipped.txt index 8bed29bca3ae7..ede23967402c0 100644 --- a/src/Components/Endpoints/src/PublicAPI.Unshipped.txt +++ b/src/Components/Endpoints/src/PublicAPI.Unshipped.txt @@ -1,3 +1,4 @@ #nullable enable Microsoft.AspNetCore.Components.Routing.RazorComponentsEndpointHttpContextExtensions +static Microsoft.AspNetCore.Components.Endpoints.Infrastructure.ComponentEndpointConventionBuilderHelper.GetEndpointRouteBuilder(Microsoft.AspNetCore.Builder.RazorComponentsEndpointConventionBuilder! builder) -> Microsoft.AspNetCore.Routing.IEndpointRouteBuilder! static Microsoft.AspNetCore.Components.Routing.RazorComponentsEndpointHttpContextExtensions.AcceptsInteractiveRouting(this Microsoft.AspNetCore.Http.HttpContext! context) -> bool diff --git a/src/Components/Endpoints/test/HotReloadServiceTests.cs b/src/Components/Endpoints/test/HotReloadServiceTests.cs index a492c36e39b02..08c83562a5810 100644 --- a/src/Components/Endpoints/test/HotReloadServiceTests.cs +++ b/src/Components/Endpoints/test/HotReloadServiceTests.cs @@ -220,7 +220,7 @@ private IServiceProvider CreateServices(params Type[] types) var result = new RazorComponentEndpointDataSource( builder, new[] { new MockEndpointProvider() }, - new ApplicationBuilder(services), + new TestEndpointRouteBuilder(services), new RazorComponentEndpointFactory(), new HotReloadService() { MetadataUpdateSupported = true }); @@ -256,4 +256,18 @@ public override IEnumerable GetEndpointBuilders(IComponent public override bool Supports(IComponentRenderMode renderMode) => true; } + + private class TestEndpointRouteBuilder : IEndpointRouteBuilder + { + private IServiceProvider _serviceProvider; + private List _dataSources = new(); + + public TestEndpointRouteBuilder(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider; + + public IServiceProvider ServiceProvider => _serviceProvider; + + public ICollection DataSources => _dataSources; + + public IApplicationBuilder CreateApplicationBuilder() => new ApplicationBuilder(_serviceProvider); + } } diff --git a/src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs b/src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs index 6135cd456ffdd..0468425dbc5f3 100644 --- a/src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs +++ b/src/Components/Endpoints/test/RazorComponentEndpointDataSourceTest.cs @@ -228,7 +228,7 @@ private IServiceProvider CreateServices(params Type[] types) var result = new RazorComponentEndpointDataSource( builder ?? DefaultRazorComponentApplication.Instance.GetBuilder(), services?.GetService>() ?? Enumerable.Empty(), - new ApplicationBuilder(services ?? new ServiceCollection().BuildServiceProvider()), + new TestEndpointRouteBuilder(services ?? new ServiceCollection().BuildServiceProvider()), new RazorComponentEndpointFactory(), new HotReloadService() { MetadataUpdateSupported = true }); @@ -277,6 +277,20 @@ public override IEnumerable GetEndpointBuilders(IComponent public override bool Supports(IComponentRenderMode renderMode) => renderMode is InteractiveWebAssemblyRenderMode or InteractiveAutoRenderMode; } + + private class TestEndpointRouteBuilder : IEndpointRouteBuilder + { + private IServiceProvider _serviceProvider; + private List _dataSources = new(); + + public TestEndpointRouteBuilder(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider; + + public IServiceProvider ServiceProvider => _serviceProvider; + + public ICollection DataSources => _dataSources; + + public IApplicationBuilder CreateApplicationBuilder() => new ApplicationBuilder(_serviceProvider); + } } public class App : IComponent diff --git a/src/Components/WebAssembly/Samples/HostedBlazorWebassemblyApp/Server/Startup.cs b/src/Components/WebAssembly/Samples/HostedBlazorWebassemblyApp/Server/Startup.cs index 5d866e9577d92..8af3e63b66223 100644 --- a/src/Components/WebAssembly/Samples/HostedBlazorWebassemblyApp/Server/Startup.cs +++ b/src/Components/WebAssembly/Samples/HostedBlazorWebassemblyApp/Server/Startup.cs @@ -50,18 +50,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseHttpsRedirection(); - //app.UseBlazorFrameworkFiles(); - app.UseRouting(); - //app.UseStaticFiles(); - app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); - endpoints.MapStaticAssetEndpoints() - .AddBlazorWebAssemblyConventions(); + endpoints.MapStaticAssetEndpoints(); endpoints.MapFallbackToPage("/_Host"); }); } diff --git a/src/Components/WebAssembly/Server/src/Builder/WebAssemblyComponentsEndpointOptions.cs b/src/Components/WebAssembly/Server/src/Builder/WebAssemblyComponentsEndpointOptions.cs index 2f359b28a98a4..2f04c1d073a24 100644 --- a/src/Components/WebAssembly/Server/src/Builder/WebAssemblyComponentsEndpointOptions.cs +++ b/src/Components/WebAssembly/Server/src/Builder/WebAssemblyComponentsEndpointOptions.cs @@ -32,4 +32,5 @@ public sealed class WebAssemblyComponentsEndpointOptions /// public string? StaticAssetsManifestName { get; set; } + internal bool ConventionsApplied { get; set; } } diff --git a/src/Components/WebAssembly/Server/src/Builder/WebAssemblyRazorComponentsEndpointConventionBuilderExtensions.cs b/src/Components/WebAssembly/Server/src/Builder/WebAssemblyRazorComponentsEndpointConventionBuilderExtensions.cs index 81f050969d586..876dd7026a58a 100644 --- a/src/Components/WebAssembly/Server/src/Builder/WebAssemblyRazorComponentsEndpointConventionBuilderExtensions.cs +++ b/src/Components/WebAssembly/Server/src/Builder/WebAssemblyRazorComponentsEndpointConventionBuilderExtensions.cs @@ -5,6 +5,10 @@ using Microsoft.AspNetCore.Components.Endpoints.Infrastructure; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Server; +using Microsoft.AspNetCore.Routing; +using Microsoft.AspNetCore.StaticAssets; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using System.Linq; namespace Microsoft.AspNetCore.Builder; @@ -45,6 +49,36 @@ public static class WebAssemblyRazorComponentsEndpointConventionBuilderExtension } ComponentEndpointConventionBuilderHelper.AddRenderMode(builder, new WebAssemblyRenderModeWithOptions(options)); + + var endpointBuilder = ComponentEndpointConventionBuilderHelper.GetEndpointRouteBuilder(builder); + var environment = endpointBuilder.ServiceProvider.GetRequiredService(); + + // If the static assets data source for the given manifest name is already added, then just wire-up the Blazor WebAssembly conventions. + // MapStaticWebAssetEndpoints is idempotent and will not add the data source if it already exists. + var staticAssetsManifestName = options.StaticAssetsManifestName ?? $"{environment.ApplicationName}.staticwebassets.endpoints.json"; + if (HasStaticAssetDataSource(endpointBuilder, staticAssetsManifestName)) + { + options.ConventionsApplied = true; + endpointBuilder.MapStaticAssetEndpoints(staticAssetsManifestName) + .AddBlazorWebAssemblyConventions(); + + return builder; + } + return builder; } + + private static bool HasStaticAssetDataSource(IEndpointRouteBuilder endpointRouteBuilder, string? staticAssetsManifestName) + { + foreach (var ds in endpointRouteBuilder.DataSources) + { + if (ds is StaticAssetsEndpointDataSource staticAssetsDataSource && + string.Equals(staticAssetsDataSource.ManifestName, staticAssetsManifestName, StringComparison.Ordinal)) + { + return true; + } + } + + return false; + } } diff --git a/src/Components/WebAssembly/Server/src/ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderExtensions.cs b/src/Components/WebAssembly/Server/src/ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderExtensions.cs index 948fb32f4156e..cc71e69fed7bc 100644 --- a/src/Components/WebAssembly/Server/src/ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderExtensions.cs +++ b/src/Components/WebAssembly/Server/src/ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderExtensions.cs @@ -24,12 +24,12 @@ public static class ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderEx /// Configures additional static web asset extensions logic for Blazor WebAssembly. /// /// - public static void AddBlazorWebAssemblyConventions(this StaticAssetsEndpointConventionBuilder builder) + internal static void AddBlazorWebAssemblyConventions(this StaticAssetsEndpointConventionBuilder builder) { builder.Add(endpoint => { - if (endpoint is RouteEndpointBuilder { RoutePattern.RawText: { } pattern } && pattern.StartsWith("/_framework/", StringComparison.Ordinal) && - !pattern.StartsWith("/_framework/blazor.server.js", StringComparison.Ordinal) && !pattern.StartsWith("/_framework/blazor.web.js", StringComparison.Ordinal)) + if (endpoint is RouteEndpointBuilder { RoutePattern.RawText: { } pattern } && pattern.Contains("/_framework/", StringComparison.Ordinal) && + !pattern.Contains("/_framework/blazor.server.js", StringComparison.Ordinal) && !pattern.Contains("/_framework/blazor.web.js", StringComparison.Ordinal)) { WrapEndpoint(endpoint); } diff --git a/src/Components/WebAssembly/Server/src/PublicAPI.Unshipped.txt b/src/Components/WebAssembly/Server/src/PublicAPI.Unshipped.txt index 49afe40b0b42a..92ef424434351 100644 --- a/src/Components/WebAssembly/Server/src/PublicAPI.Unshipped.txt +++ b/src/Components/WebAssembly/Server/src/PublicAPI.Unshipped.txt @@ -4,4 +4,3 @@ Microsoft.AspNetCore.Components.WebAssembly.Server.WebAssemblyComponentsEndpoint Microsoft.AspNetCore.Components.WebAssembly.Server.WebAssemblyComponentsEndpointOptions.ServeMultithreadingHeaders.set -> void Microsoft.AspNetCore.Components.WebAssembly.Server.WebAssemblyComponentsEndpointOptions.StaticAssetsManifestName.get -> string? Microsoft.AspNetCore.Components.WebAssembly.Server.WebAssemblyComponentsEndpointOptions.StaticAssetsManifestName.set -> void -static Microsoft.AspNetCore.Components.WebAssembly.Server.ComponentsWebAssemblyStaticAssetsEndpointConventionBuilderExtensions.AddBlazorWebAssemblyConventions(this Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder! builder) -> void diff --git a/src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs b/src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs index be03f70d47f38..391f2bff6638c 100644 --- a/src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs +++ b/src/Components/WebAssembly/Server/src/WebAssemblyRazorComponentsBuilderExtensions.cs @@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Endpoints.Infrastructure; using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.WebAssembly.Server; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -37,25 +36,18 @@ public override IEnumerable GetEndpointBuilders(IComponent { if (renderMode is not WebAssemblyRenderModeWithOptions wasmWithOptions) { - if (renderMode is InteractiveWebAssemblyRenderMode) - { - throw new InvalidOperationException("Invalid render mode. Use AddInteractiveWebAssemblyRenderMode(Action) to configure the WebAssembly render mode."); - } - - return Array.Empty(); + return renderMode is InteractiveWebAssemblyRenderMode + ? throw new InvalidOperationException("Invalid render mode. Use AddInteractiveWebAssemblyRenderMode(Action) to configure the WebAssembly render mode.") + : (IEnumerable)Array.Empty(); } - - if (applicationBuilder.Properties.TryGetValue("__EndpointRouteBuilder", out var value) && value is IEndpointRouteBuilder endpointRouteBuilder) + if (wasmWithOptions is { EndpointOptions.ConventionsApplied: true }) { - // Map static asset endpoints is idempotent, if it was already called with a given manifest name, it will return the existing builder. - endpointRouteBuilder.MapStaticAssetEndpoints(wasmWithOptions.EndpointOptions?.StaticAssetsManifestName) - .AddBlazorWebAssemblyConventions(); - return []; // No need to add additional endpoints to the DS, they are already added } else { - endpointRouteBuilder = new EndpointRouteBuilder(services, applicationBuilder); + // In case the app didn't call MapStaticAssetEndpoints, use the 8.0 approach to map the assets. + var endpointRouteBuilder = new EndpointRouteBuilder(services, applicationBuilder); var pathPrefix = wasmWithOptions.EndpointOptions?.PathPrefix; applicationBuilder.UseBlazorFrameworkFiles(pathPrefix ?? default); @@ -69,12 +61,14 @@ public override IEnumerable GetEndpointBuilders(IComponent return app(context); }); - return ((EndpointRouteBuilder)endpointRouteBuilder).GetEndpoints(); + return endpointRouteBuilder.GetEndpoints(); } } public override bool Supports(IComponentRenderMode renderMode) - => renderMode is InteractiveWebAssemblyRenderMode or InteractiveAutoRenderMode; + { + return renderMode is InteractiveWebAssemblyRenderMode or InteractiveAutoRenderMode; + } private class EndpointRouteBuilder : IEndpointRouteBuilder { @@ -88,7 +82,7 @@ public EndpointRouteBuilder(IServiceProvider serviceProvider, IApplicationBuilde public IServiceProvider ServiceProvider { get; } - public ICollection DataSources { get; } = new List() { }; + public ICollection DataSources { get; } = []; public IApplicationBuilder CreateApplicationBuilder() { diff --git a/src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs b/src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs index 70149ac5b48dc..81191b2aa1169 100644 --- a/src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs +++ b/src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs @@ -9,6 +9,7 @@ using Components.TestServer.RazorComponents.Pages.Forms; using Components.TestServer.Services; using Microsoft.AspNetCore.Components.Server.Circuits; +using Microsoft.AspNetCore.Components.WebAssembly.Server; using Microsoft.AspNetCore.Mvc; namespace TestServer; @@ -64,7 +65,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseExceptionHandler("/Error", createScopeForErrors: true); } - app.UseStaticFiles(); app.UseRouting(); UseFakeAuthState(app); app.UseAntiforgery(); diff --git a/src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs b/src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs index b76a66719aef3..1435e36c69fc0 100644 --- a/src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs +++ b/src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs @@ -23,7 +23,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.Map("/subdir", app => { - app.UseStaticFiles(); app.UseRouting(); app.UseAntiforgery(); app.UseEndpoints(endpoints => diff --git a/src/StaticAssets/src/PublicAPI.Unshipped.txt b/src/StaticAssets/src/PublicAPI.Unshipped.txt index f7c1481e70b26..ef657cafb254a 100644 --- a/src/StaticAssets/src/PublicAPI.Unshipped.txt +++ b/src/StaticAssets/src/PublicAPI.Unshipped.txt @@ -2,4 +2,9 @@ Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder.Add(System.Action! convention) -> void Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder.Finally(System.Action! convention) -> void +Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointDataSource +Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointDataSource.DefaultBuilder.get -> Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder! +Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointDataSource.ManifestName.get -> string! +override Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointDataSource.Endpoints.get -> System.Collections.Generic.IReadOnlyList! +override Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointDataSource.GetChangeToken() -> Microsoft.Extensions.Primitives.IChangeToken! static Microsoft.AspNetCore.Builder.StaticAssetsEndpointRouteBuilderExtensions.MapStaticAssetEndpoints(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder! endpoints, string? staticAssetsManifestName = null) -> Microsoft.AspNetCore.StaticAssets.StaticAssetsEndpointConventionBuilder! \ No newline at end of file diff --git a/src/StaticAssets/src/StaticAssetEndpointDataSource.cs b/src/StaticAssets/src/StaticAssetEndpointDataSource.cs index 419a92153ff45..0a4ff425844e4 100644 --- a/src/StaticAssets/src/StaticAssetEndpointDataSource.cs +++ b/src/StaticAssets/src/StaticAssetEndpointDataSource.cs @@ -9,8 +9,11 @@ namespace Microsoft.AspNetCore.StaticAssets; +/// +/// An for static assets. +/// [DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] -internal class StaticAssetsEndpointDataSource : EndpointDataSource +public class StaticAssetsEndpointDataSource : EndpointDataSource { private readonly object _lock = new(); private readonly StaticResourcesManifest _manifest; @@ -22,7 +25,7 @@ internal class StaticAssetsEndpointDataSource : EndpointDataSource private CancellationTokenSource _cancellationTokenSource; private CancellationChangeToken _changeToken; - public StaticAssetsEndpointDataSource(StaticResourcesManifest manifest, StaticAssetEndpointFactory endpointFactory, string manifestName) + internal StaticAssetsEndpointDataSource(StaticResourcesManifest manifest, StaticAssetEndpointFactory endpointFactory, string manifestName) { _manifest = manifest; _manifestName = manifestName; @@ -36,10 +39,15 @@ public StaticAssetsEndpointDataSource(StaticResourcesManifest manifest, StaticAs _finallyConventions); } - internal string ManifestName => _manifestName; + /// + /// Gets the manifest name associated with this static asset endpoint data source. + /// + public string ManifestName => _manifestName; + /// public StaticAssetsEndpointConventionBuilder DefaultBuilder { get; internal set; } + /// public override IReadOnlyList Endpoints { get @@ -92,6 +100,7 @@ private void UpdateEndpoints() } } + /// public override IChangeToken GetChangeToken() { Initialize();