-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: New up renderer for markup matches (#1160)
* fix: New up renderer for markup matches * revert: Changes for editorconfig * chore: Suppress xUnit1026
- Loading branch information
1 parent
ffd6fa7
commit 76fd92f
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/bunit.testassets/SampleComponents/InvokeAsyncInsideContinueWith.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@if (Task != null) | ||
{ | ||
@if (Task.IsCompleted) | ||
{ | ||
<span>done</span> | ||
} | ||
else | ||
{ | ||
<span>waiting</span> | ||
} | ||
} | ||
@code { | ||
[Parameter] public Task? Task { get; set; } | ||
|
||
private Task? registeredTask; | ||
private Task? delegatedTask; | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
var task = Task; | ||
if (task != registeredTask) | ||
{ | ||
registeredTask = task; | ||
delegatedTask = task == null ? null : DelegateTo(task); | ||
RenderWhenDone(); | ||
} | ||
|
||
base.OnParametersSet(); | ||
} | ||
|
||
private async void RenderWhenDone() | ||
{ | ||
var task = delegatedTask; | ||
if (task != null) | ||
{ | ||
_ = await Task.WhenAny(task).ConfigureAwait(false); | ||
|
||
if (task == delegatedTask) | ||
{ | ||
_ = InvokeAsync(StateHasChanged); | ||
} | ||
} | ||
} | ||
|
||
private static async Task<object?> DelegateTo(Task task) | ||
{ | ||
await task;//.ConfigureAwait(false); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters