Skip to content

Commit 3111032

Browse files
committed
Rework of Blazor startup experience
Fixes: #16874 This is a significant simplication of our startup code model for Blazor wasm with the goal of removing concepts that don't make much sense here. Previously in this area we've tried to be consistent with ASP.NET Core on the server, but it's not helping up much in WASM. We're still leveraging some of the lessons from server-size ASP.NET (hello CreateDefaultBuilder) but consistency is no longer a goal. This change actually makes a bunch of scenarios better (rather than removing features) - it's now possible to access services from the application's DI scope and initialize them before the UI is shown `RunAsync`. This change also adds configuration in a central way. There's nothing in this change that populates configuration in an automatic way, that will come next.
1 parent ba08d60 commit 3111032

39 files changed

+516
-1220
lines changed

src/Components/Blazor/Blazor/ref/Microsoft.AspNetCore.Blazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<Compile Include="Microsoft.AspNetCore.Blazor.netstandard2.1.cs" />
88
<Reference Include="Mono.WebAssembly.Interop" />
99
<Reference Include="Microsoft.AspNetCore.Components.Web" />
10-
<Reference Include="Microsoft.Extensions.Options" />
10+
<Reference Include="Microsoft.Extensions.Configuration" />
1111
</ItemGroup>
1212
</Project>

src/Components/Blazor/Blazor/ref/Microsoft.AspNetCore.Blazor.netstandard2.1.cs

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ public static void NotifyLocationChanged(string uri, bool isInterceptedLink) { }
1212
}
1313
namespace Microsoft.AspNetCore.Blazor.Hosting
1414
{
15-
public static partial class BlazorWebAssemblyHost
15+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
16+
public readonly partial struct RootComponentMapping
1617
{
17-
public static Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder CreateDefaultBuilder() { throw null; }
18+
private readonly object _dummy;
19+
public RootComponentMapping(System.Type componentType, string selector) { throw null; }
20+
public System.Type ComponentType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
21+
public string Selector { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
1822
}
19-
public partial interface IWebAssemblyHost : System.IDisposable
23+
public partial class RootComponentMappingCollection : System.Collections.ObjectModel.Collection<Microsoft.AspNetCore.Blazor.Hosting.RootComponentMapping>
2024
{
21-
System.IServiceProvider Services { get; }
22-
System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
23-
System.Threading.Tasks.Task StopAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
25+
public RootComponentMappingCollection() { }
26+
public void Add(System.Type componentType, string selector) { }
27+
public void AddRange(System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Blazor.Hosting.RootComponentMapping> items) { }
28+
public void Add<TComponent>(string selector) where TComponent : Microsoft.AspNetCore.Components.IComponent { }
2429
}
25-
public partial interface IWebAssemblyHostBuilder
30+
public sealed partial class WebAssemblyHost : System.IAsyncDisposable
2631
{
27-
System.Collections.Generic.IDictionary<object, object> Properties { get; }
28-
Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHost Build();
29-
Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder ConfigureServices(System.Action<Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceCollection> configureDelegate);
30-
Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder UseServiceProviderFactory<TContainerBuilder>(Microsoft.Extensions.DependencyInjection.IServiceProviderFactory<TContainerBuilder> factory);
31-
Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder UseServiceProviderFactory<TContainerBuilder>(System.Func<Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHostBuilderContext, Microsoft.Extensions.DependencyInjection.IServiceProviderFactory<TContainerBuilder>> factory);
32+
internal WebAssemblyHost() { }
33+
public Microsoft.Extensions.Configuration.IConfiguration Configuration { get { throw null; } }
34+
public System.IServiceProvider Services { get { throw null; } }
35+
[System.Diagnostics.DebuggerStepThroughAttribute]
36+
public System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
37+
public System.Threading.Tasks.Task RunAsync() { throw null; }
3238
}
33-
public sealed partial class WebAssemblyHostBuilderContext
39+
public sealed partial class WebAssemblyHostBuilder
3440
{
35-
public WebAssemblyHostBuilderContext(System.Collections.Generic.IDictionary<object, object> properties) { }
36-
public System.Collections.Generic.IDictionary<object, object> Properties { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
37-
}
38-
public static partial class WebAssemblyHostBuilderExtensions
39-
{
40-
public static Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder ConfigureServices(this Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder hostBuilder, System.Action<Microsoft.Extensions.DependencyInjection.IServiceCollection> configureDelegate) { throw null; }
41-
public static Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder UseBlazorStartup(this Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder builder, System.Type startupType) { throw null; }
42-
public static Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder UseBlazorStartup<TStartup>(this Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHostBuilder builder) { throw null; }
43-
}
44-
public static partial class WebAssemblyHostExtensions
45-
{
46-
public static void Run(this Microsoft.AspNetCore.Blazor.Hosting.IWebAssemblyHost host) { }
41+
internal WebAssemblyHostBuilder() { }
42+
public Microsoft.Extensions.Configuration.IConfigurationBuilder Configuration { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
43+
public Microsoft.AspNetCore.Blazor.Hosting.RootComponentMappingCollection RootComponents { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
44+
public Microsoft.Extensions.DependencyInjection.IServiceCollection Services { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
45+
public Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHost Build() { throw null; }
46+
public static Microsoft.AspNetCore.Blazor.Hosting.WebAssemblyHostBuilder CreateDefault(string[] args = null) { throw null; }
4747
}
4848
}
4949
namespace Microsoft.AspNetCore.Blazor.Http
@@ -67,15 +67,3 @@ public static partial class WebAssemblyEventDispatcher
6767
public static System.Threading.Tasks.Task DispatchEvent(Microsoft.AspNetCore.Components.RenderTree.WebEventDescriptor eventDescriptor, string eventArgsJson) { throw null; }
6868
}
6969
}
70-
namespace Microsoft.AspNetCore.Components.Builder
71-
{
72-
public static partial class ComponentsApplicationBuilderExtensions
73-
{
74-
public static void AddComponent<TComponent>(this Microsoft.AspNetCore.Components.Builder.IComponentsApplicationBuilder app, string domElementSelector) where TComponent : Microsoft.AspNetCore.Components.IComponent { }
75-
}
76-
public partial interface IComponentsApplicationBuilder
77-
{
78-
System.IServiceProvider Services { get; }
79-
void AddComponent(System.Type componentType, string domElementSelector);
80-
}
81-
}

src/Components/Blazor/Blazor/src/Builder/ComponentsApplicationBuilderExtensions.cs

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

src/Components/Blazor/Blazor/src/Builder/IComponentsApplicationBuilder.cs

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

src/Components/Blazor/Blazor/src/Hosting/BlazorWebAssemblyHost.cs

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

src/Components/Blazor/Blazor/src/Hosting/ConventionBasedStartup.cs

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

src/Components/Blazor/Blazor/src/Hosting/IBlazorStartup.cs

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

src/Components/Blazor/Blazor/src/Hosting/IWebAssemblyHost.cs

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

src/Components/Blazor/Blazor/src/Hosting/IWebAssemblyHostBuilder.cs

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

src/Components/Blazor/Blazor/src/Hosting/IWebAssemblyServiceFactoryAdapter.cs

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

0 commit comments

Comments
 (0)