In your csproj file, add the following:
<Target Name="AddCustomLinkerDescriptor" AfterTargets="_CollectBlazorLinkerDescriptors">
<ItemGroup>
<BlazorLinkerDescriptor Include="CustomLinkerConfig.xml" />
</ItemGroup>
public class MyNetworkClient { | |
public event SomeDelegate OnException; | |
public async Task ConnectAsync(string address) { | |
await this.MakeTheActualConnection(address); | |
this.BeginReceiveLoop(); | |
} | |
// It's async void! But is that bad? | |
// I know that an unhandled exception here is going to bring down the process, but where else do you want |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; |
class TaskResultUtil | |
{ | |
private static ConcurrentDictionary<Type, ITaskResultGetter> _cachedGetters = new ConcurrentDictionary<Type, ITaskResultGetter>(); | |
private interface ITaskResultGetter | |
{ | |
object GetResult(Task task); | |
} | |
private class TaskResultGetter<T> : ITaskResultGetter |
@page "/" | |
<h1>Hello, world!</h1> | |
Welcome to your new app. | |
<EditForm Model="@_editingPerson" OnValidSubmit="@OnValidSubmit" OnInvalidSubmit="@OnInvalidSubmit"> | |
<p> | |
Name: <InputText @bind-Value="_editingPerson.Name" /> | |
<ValidationMessage For="@(() => _editingPerson.Name)" /> |
console.log('Hello, world!'); |
@using StandaloneApp.Util | |
@(Layout<StandaloneApp.Shared.MainLayout>()) | |
<h1>Hello, world!</h1> | |
Welcome to your new app. | |
<button @onclick(DoRequest)>Do request</button> | |
<div><strong>Response: </strong>@responseText</div> | |
@functions { |
public static class EventUtil | |
{ | |
// The repetition in here is because of the four combinations of handlers (sync/async * with/without arg) | |
public static Action AsNonRenderingEventHandler(Action callback) | |
=> new SyncReceiver(callback).Invoke; | |
public static Action<TValue> AsNonRenderingEventHandler<TValue>(Action<TValue> callback) | |
=> new SyncReceiver<TValue>(callback).Invoke; | |
public static Func<Task> AsNonRenderingEventHandler(Func<Task> callback) | |
=> new AsyncReceiver(callback).Invoke; | |
public static Func<TValue, Task> AsNonRenderingEventHandler<TValue>(Func<TValue, Task> callback) |
using Microsoft.AspNetCore.Blazor; | |
public interface ITab | |
{ | |
RenderFragment ChildContent { get; } | |
} |
This document describes options and proposals for #4048.
Principles:
Startup.cs
logic is completely different for the two runtime environments.The Razor Components auth feature set will be mostly the same as for MVC/Pages. We'll get the same long-tail features such as integration with 3rd-party social logins, 2FA, etc. The Razor Components template will support the same four auth options during project creation, and the "Scaffold Identity" feature will be usable on existing Razor Components projects.