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 {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("weatherforecast");
}

View File

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

View File

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

View File

@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Components
[Microsoft.AspNetCore.Components.ParameterAttribute]
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 OnInit() { }
protected override void OnInitialized() { }
void System.IDisposable.Dispose() { }
}
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Components.Forms
public partial class DataAnnotationsValidator : Microsoft.AspNetCore.Components.ComponentBase
{
public DataAnnotationsValidator() { }
protected override void OnInit() { }
protected override void OnInitialized() { }
}
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; }
protected virtual void OnAfterRender() { }
protected virtual System.Threading.Tasks.Task OnAfterRenderAsync() { throw null; }
protected virtual void OnInit() { }
protected virtual System.Threading.Tasks.Task OnInitAsync() { throw null; }
protected virtual void OnInitialized() { }
protected virtual System.Threading.Tasks.Task OnInitializedAsync() { throw null; }
protected virtual void OnParametersSet() { }
protected virtual System.Threading.Tasks.Task OnParametersSetAsync() { throw null; }
public virtual System.Threading.Tasks.Task SetParametersAsync(Microsoft.AspNetCore.Components.ParameterCollection parameters) { throw null; }

View File

@ -12,7 +12,7 @@
/// </summary>
[Parameter] public RenderFragment ChildContent { get; private set; }
protected override void OnInit()
protected override void OnInitialized()
{
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
/// initial parameters from its parent in the render tree.
/// </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.
/// </summary>
/// <returns>A <see cref="Task"/> representing any asynchronous operation.</returns>
protected virtual Task OnInitAsync()
protected virtual Task OnInitializedAsync()
=> Task.CompletedTask;
/// <summary>
@ -192,8 +192,8 @@ namespace Microsoft.AspNetCore.Components
private async Task RunInitAndSetParametersAsync()
{
OnInit();
var task = OnInitAsync();
OnInitialized();
var task = OnInitializedAsync();
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; }
/// <inheritdoc />
protected override void OnInit()
protected override void OnInitialized()
{
if (CurrentEditContext == null)
{

View File

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

View File

@ -3888,17 +3888,16 @@ namespace Microsoft.AspNetCore.Components.Test
[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))
{
var result = entry.EventAction();
LogResult(result.Result);
}
base.OnInit();
}
protected override async Task OnInitAsync()
protected override async Task OnInitializedAsync()
{
if (TryGetEntry(EventType.OnInitAsyncSync, out var entrySync))
{

View File

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

View File

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

View File

@ -3,7 +3,7 @@
{
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
// will result in a lot of them triggering a re-render simultaneously

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures.Test
{
RedirectUri = "http://localhost/redirect"
}));
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" +
"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; }
protected override void OnInit()
protected override void OnInitialized()
{
UriHelper.NavigateTo(RedirectUri, Force);
}

View File

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

View File

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

View File

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

View File

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