using System; namespace Xamarin.Forms { static class WeakReferenceExtensions { internal static bool TryGetTarget(this WeakReference self, out T target) where T : class { if (self == null) throw new ArgumentNullException(nameof(self)); target = (T)self.Target; return target != null; } } }