Describe the bug
There seem to be 2 issues in the SuspensionHostExtensions class which appeared after upgrading to version 11.5.1. I'll describe them both here since they are quite small. I believe this is because of changes introduced in this commit.
SetupDefaultSuspendResume always throws NullReferenceException. I think this is because this code was added to the method:if (item.AppState == null)
{
throw new NullReferenceException(nameof(item.AppState));
}
As far as I understand, item.AppState is always going to be null at this point, because we're just setting up the suspension host and the app state didn't have a chance to be initialized yet.
ObserveAppState always throws InvalidCastException. This is because this line:return item.WhenAny(x => x.AppState, x => (T)x.Value)
was changed to this:
return item.WhenAny(x => x.AppState, x => (T)x)
So now instead of casting x.Value, it tries to cast x which is of type ObservedChange.
Steps To Reproduce
Expected behavior
Well, I would expect it not to throw any exceptions :)
Environment
I'm having the same problem after updating to 11.5.1.
SetupDefaultSuspendResume throws NullReferenceException on start, and attempting to initialize the AppState to a non-null value before calling SetupDefaultSuspendResume will "workaround" the first bug, but it then throws InvalidCastException, exactly as described by @TolikPylypchuk.
Thanks for confirming. We will have a fix out in a day or so
Most helpful comment
Thanks for confirming. We will have a fix out in a day or so