After migrating from .Net 6 to .Net 8, I see the following warning:
VSTHRD003: Avoid awaiting or returning a Task representing work that was not started within your context as that can lead to deadlocks.
This pertains to AuthenticationStateTask where I do
[CascadingParameter] Task<AuthenticationState> AuthenticationStateTask { get; set; }protected override async Task OnInitializedAsync(){ var authState = await AuthenticationStateTask; ...}The issue is that it seems to be the way Microsoft does it, see eg Expose the authentication state as a cascading parameter.
Is there a better way to do it that doesn't raise the warning? Or is this a special case where the warning should be turned off?