In C# with nullable types it is possible to implement a 'TryGet' that is smart about null checking, e.g.,
bool TryGetById(int id, [NotNullWhen(returnValue: true)] out MyThing? myThing)
which allows the caller to skip null checking on the out var myThing.
Unfortunately, Async does not allow out parameters, and the pattern of using a Tuple return does not allow for this smart NotNull checking (at least, not so far as I have found). Is there an alternative?
Is there any way to use a 'NotNullWhen' equivalent on an async Tuple return type e.g.,
Task<(bool Ok, [NotNullWhen(returnValue: true)] MyThing? MyThing)> TryGetById(int id)