Rename OnInit and OnInitAsync to long form

OnInit -> OnInitialized
OnInitAsync -> OnInitializedAsync
This commit is contained in:
Ryan Nowak 2019-07-01 16:07:43 -07:00
parent 3c0fb1a3f8
commit 9287301208
24 changed files with 37 additions and 39 deletions

View File

@ -38,7 +38,7 @@ else
@code { @code {
WeatherForecast[] forecasts; WeatherForecast[] forecasts;
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("weatherforecast"); forecasts = await Http.GetJsonAsync<WeatherForecast[]>("weatherforecast");
} }

View File

@ -37,7 +37,7 @@ else
@code { @code {
WeatherForecast[] forecasts; WeatherForecast[] forecasts;
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json"); forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
} }

View File

@ -31,7 +31,7 @@
string largeOrgChartJson; string largeOrgChartJson;
int numPeopleDeserialized; int numPeopleDeserialized;
protected override void OnInit() protected override void OnInitialized()
{ {
smallOrgChartJson = JsonSerializer.Serialize(smallOrgChart); smallOrgChartJson = JsonSerializer.Serialize(smallOrgChart);
largeOrgChartJson = JsonSerializer.Serialize(largeOrgChart); largeOrgChartJson = JsonSerializer.Serialize(largeOrgChart);

View File

@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Components
[Microsoft.AspNetCore.Components.ParameterAttribute] [Microsoft.AspNetCore.Components.ParameterAttribute]
public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } }
protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { } protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { }
protected override void OnInit() { } protected override void OnInitialized() { }
void System.IDisposable.Dispose() { } void System.IDisposable.Dispose() { }
} }
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Components.Forms
public partial class DataAnnotationsValidator : Microsoft.AspNetCore.Components.ComponentBase public partial class DataAnnotationsValidator : Microsoft.AspNetCore.Components.ComponentBase
{ {
public DataAnnotationsValidator() { } public DataAnnotationsValidator() { }
protected override void OnInit() { } protected override void OnInitialized() { }
} }
public partial class EditForm : Microsoft.AspNetCore.Components.ComponentBase public partial class EditForm : Microsoft.AspNetCore.Components.ComponentBase

View File

@ -88,8 +88,8 @@ namespace Microsoft.AspNetCore.Components
System.Threading.Tasks.Task Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(Microsoft.AspNetCore.Components.EventCallbackWorkItem callback, object arg) { throw null; } System.Threading.Tasks.Task Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(Microsoft.AspNetCore.Components.EventCallbackWorkItem callback, object arg) { throw null; }
protected virtual void OnAfterRender() { } protected virtual void OnAfterRender() { }
protected virtual System.Threading.Tasks.Task OnAfterRenderAsync() { throw null; } protected virtual System.Threading.Tasks.Task OnAfterRenderAsync() { throw null; }
protected virtual void OnInit() { } protected virtual void OnInitialized() { }
protected virtual System.Threading.Tasks.Task OnInitAsync() { throw null; } protected virtual System.Threading.Tasks.Task OnInitializedAsync() { throw null; }
protected virtual void OnParametersSet() { } protected virtual void OnParametersSet() { }
protected virtual System.Threading.Tasks.Task OnParametersSetAsync() { throw null; } protected virtual System.Threading.Tasks.Task OnParametersSetAsync() { throw null; }
public virtual System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; } public virtual System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }

View File

@ -12,7 +12,7 @@
/// </summary> /// </summary>
[Parameter] public RenderFragment ChildContent { get; private set; } [Parameter] public RenderFragment ChildContent { get; private set; }
protected override void OnInit() protected override void OnInitialized()
{ {
AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged; AuthenticationStateProvider.AuthenticationStateChanged += OnAuthenticationStateChanged;

View File

@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Components
/// Method invoked when the component is ready to start, having received its /// Method invoked when the component is ready to start, having received its
/// initial parameters from its parent in the render tree. /// initial parameters from its parent in the render tree.
/// </summary> /// </summary>
protected virtual void OnInit() protected virtual void OnInitialized()
{ {
} }
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Components
/// want the component to refresh when that operation is completed. /// want the component to refresh when that operation is completed.
/// </summary> /// </summary>
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns> /// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
protected virtual Task OnInitAsync() protected virtual Task OnInitializedAsync()
=> Task.CompletedTask; => Task.CompletedTask;
/// <summary> /// <summary>
@ -192,8 +192,8 @@ namespace Microsoft.AspNetCore.Components
private async Task RunInitAndSetParametersAsync() private async Task RunInitAndSetParametersAsync()
{ {
OnInit(); OnInitialized();
var task = OnInitAsync(); var task = OnInitializedAsync();
if (task.Status != TaskStatus.RanToCompletion && task.Status != TaskStatus.Canceled) if (task.Status != TaskStatus.RanToCompletion && task.Status != TaskStatus.Canceled)
{ {

View File

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Components.Forms
[CascadingParameter] EditContext CurrentEditContext { get; set; } [CascadingParameter] EditContext CurrentEditContext { get; set; }
/// <inheritdoc /> /// <inheritdoc />
protected override void OnInit() protected override void OnInitialized()
{ {
if (CurrentEditContext == null) if (CurrentEditContext == null)
{ {

View File

@ -402,21 +402,21 @@ namespace Microsoft.AspNetCore.Components.Test
builder.CloseElement(); builder.CloseElement();
} }
protected override void OnInit() protected override void OnInitialized()
{ {
if (RunsBaseOnInit) if (RunsBaseOnInit)
{ {
base.OnInit(); base.OnInitialized();
} }
OnInitLogic?.Invoke(this); OnInitLogic?.Invoke(this);
} }
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
if (RunsBaseOnInitAsync) if (RunsBaseOnInitAsync)
{ {
await base.OnInitAsync(); await base.OnInitializedAsync();
} }
if (OnInitAsyncLogic != null) if (OnInitAsyncLogic != null)

View File

@ -3888,17 +3888,16 @@ namespace Microsoft.AspNetCore.Components.Test
[Parameter] public ConcurrentQueue<(int testId, EventType @event)> Log { get; set; } [Parameter] public ConcurrentQueue<(int testId, EventType @event)> Log { get; set; }
protected override void OnInit() protected override void OnInitialized()
{ {
if (TryGetEntry(EventType.OnInit, out var entry)) if (TryGetEntry(EventType.OnInit, out var entry))
{ {
var result = entry.EventAction(); var result = entry.EventAction();
LogResult(result.Result); LogResult(result.Result);
} }
base.OnInit();
} }
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
if (TryGetEntry(EventType.OnInitAsyncSync, out var entrySync)) if (TryGetEntry(EventType.OnInitAsyncSync, out var entrySync))
{ {

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
public void RenderComponentAsync_CanRenderEmptyElement() public void RenderComponentAsync_CanRenderEmptyElement()
{ {
// Arrange // Arrange
var expectedHtml = new[] { "<", "p", ">", "</", "p", ">" }; var expectedHtml = new[] { "<", "p", ">", "</", "p", ">" };
var serviceProvider = new ServiceCollection().AddSingleton(new RenderFragment(rtb => var serviceProvider = new ServiceCollection().AddSingleton(new RenderFragment(rtb =>
{ {
@ -508,7 +508,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
[Parameter] public bool Nested { get; set; } [Parameter] public bool Nested { get; set; }
[Parameter] public int Value { get; set; } [Parameter] public int Value { get; set; }
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
Value = Value * 2; Value = Value * 2;
await Task.Yield(); await Task.Yield();
@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Components.Rendering
[Parameter] [Parameter]
public int Value { get; set; } public int Value { get; set; }
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
Value = Value * 2; Value = Value * 2;
await Task.Delay(Value * 100); await Task.Delay(Value * 100);

View File

@ -23,7 +23,7 @@
<Links /> <Links />
@code { @code {
protected override void OnInit() protected override void OnInitialized()
{ {
// Start at AuthHome, not at any other component in the same app that happens to // Start at AuthHome, not at any other component in the same app that happens to
// register itself for the route "" // register itself for the route ""

View File

@ -3,7 +3,7 @@
{ {
protected bool isAfterDelay; protected bool isAfterDelay;
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
// If there are lots of instances of this component, the following delay // If there are lots of instances of this component, the following delay
// will result in a lot of them triggering a re-render simultaneously // will result in a lot of them triggering a re-render simultaneously

View File

@ -39,7 +39,7 @@
EditContext editContext; EditContext editContext;
string submissionStatus; string submissionStatus;
protected override void OnInit() protected override void OnInitialized()
{ {
editContext = new EditContext(person).AddDataAnnotationsValidation(); editContext = new EditContext(person).AddDataAnnotationsValidation();

View File

@ -53,7 +53,7 @@
KeyCasesTreeNode.Node parsedRootNode; KeyCasesTreeNode.Node parsedRootNode;
RenderContext renderContext = new RenderContext(); RenderContext renderContext = new RenderContext();
protected override void OnInit() protected override void OnInitialized()
{ {
Update(); Update();
} }

View File

@ -46,7 +46,7 @@
[Parameter] Node Data { get; set; } [Parameter] Node Data { get; set; }
[CascadingParameter] KeyCasesComponent.RenderContext RenderContext { get; set; } [CascadingParameter] KeyCasesComponent.RenderContext RenderContext { get; set; }
protected override void OnInit() protected override void OnInitialized()
{ {
firstCreatedOnUpdateCount = RenderContext.UpdateCount; firstCreatedOnUpdateCount = RenderContext.UpdateCount;
} }

View File

@ -8,9 +8,8 @@
@code{ @code{
string UrlLocation; string UrlLocation;
protected override void OnInit() protected override void OnInitialized()
{ {
base.OnInit();
UrlLocation = UriHelper.GetAbsoluteUri(); UrlLocation = UriHelper.GetAbsoluteUri();
UriHelper.OnLocationChanged += (_, __) => UriHelper.OnLocationChanged += (_, __) =>
{ {

View File

@ -9,7 +9,7 @@
int tick; int tick;
private bool _isDisposed; private bool _isDisposed;
protected override void OnInit() protected override void OnInitialized()
{ {
Task.Run(() => InvokeAsync(async () => Task.Run(() => InvokeAsync(async () =>
{ {

View File

@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
[Parameter] public bool Force { get; set; } [Parameter] public bool Force { get; set; }
protected override void OnInit() protected override void OnInitialized()
{ {
UriHelper.NavigateTo(RedirectUri, Force); UriHelper.NavigateTo(RedirectUri, Force);
} }

View File

@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Test
{ {
RedirectUri = "http://localhost/redirect" RedirectUri = "http://localhost/redirect"
})); }));
Assert.Equal("A navigation command was attempted during prerendering after the server already started sending the response. " + Assert.Equal("A navigation command was attempted during prerendering after the server already started sending the response. " +
"Navigation commands can not be issued during server-side prerendering after the response from the server has started. Applications must buffer the" + "Navigation commands can not be issued during server-side prerendering after the response from the server has started. Applications must buffer the" +
"reponse and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.", "reponse and avoid using features like FlushAsync() before all components on the page have been rendered to prevent failed navigation commands.",
@ -274,7 +274,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Test
[Parameter] public bool Force { get; set; } [Parameter] public bool Force { get; set; }
protected override void OnInit() protected override void OnInitialized()
{ {
UriHelper.NavigateTo(RedirectUri, Force); UriHelper.NavigateTo(RedirectUri, Force);
} }

View File

@ -2,7 +2,7 @@
@functions{ @functions{
protected override void OnInit() protected override void OnInitialized()
{ {
Helper.NavigateTo("/navigation-redirect"); Helper.NavigateTo("/navigation-redirect");
} }

View File

@ -2,9 +2,9 @@
@* This is expected to throw and result in a 500 *@ @* This is expected to throw and result in a 500 *@
@code { @code {
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
await base.OnInitAsync(); await base.OnInitializedAsync();
throw new InvalidTimeZoneException("test"); throw new InvalidTimeZoneException("test");
} }
} }

View File

@ -38,7 +38,7 @@ else
@code { @code {
WeatherForecast[] forecasts; WeatherForecast[] forecasts;
protected override async Task OnInitAsync() protected override async Task OnInitializedAsync()
{ {
forecasts = await ForecastService.GetForecastAsync(DateTime.Now); forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
} }

View File

@ -22,7 +22,7 @@
@code { @code {
bool canEditProfile; bool canEditProfile;
protected override void OnInit() protected override void OnInitialized()
{ {
var options = AzureADB2COptions.Get(AzureADB2CDefaults.AuthenticationScheme); var options = AzureADB2COptions.Get(AzureADB2CDefaults.AuthenticationScheme);
canEditProfile = !string.IsNullOrEmpty(options.EditProfilePolicyId); canEditProfile = !string.IsNullOrEmpty(options.EditProfilePolicyId);