From 0ddf0a925646fa2cd4df518c469df86e8e4d4a7f Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 12 May 2023 15:48:58 -0500 Subject: [PATCH 1/8] [ios] fix memory leak in Image Context: https://github.com/dotnet/maui/issues/14664#issuecomment-1540510216 `Image` has two different "cycles" on iOS: * `ImageHandler` -> `MauiImageView` -> `ImageHandler` * via the `WindowChanged` event * `ImageHandler` -> `ImageSourcePartLoader` -> `ImageHandler` * via `Handler`, `Func`, and `Action` This causes any `MauiImageView` to live forever. To solve these issues: * Get rid of the `MauiImageView.WindowChanged` event, and use a `WeakReference` to the handler instead. * `ImageSourcePartLoader` now only has a `WeakReference` to the handler. * This requires a new `ISetImageHandler` interface to be used by several handler types involving images. Hopefully the changes here are using `[Obsolete]` correctly to make things backwards compatible & less breaking changes. Unsure yet if this fully solves #14664, but at least one part of it. --- .../DeviceTests/Elements/Image/ImageTests.cs | 40 +++++++++++++++++++ .../Handlers/Button/ButtonHandler.Android.cs | 2 +- .../Handlers/Button/ButtonHandler.Standard.cs | 2 +- .../Handlers/Button/ButtonHandler.Tizen.cs | 2 +- .../Handlers/Button/ButtonHandler.Windows.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.cs | 4 +- .../src/Handlers/Button/ButtonHandler.iOS.cs | 2 +- .../src/Handlers/Image/ISetImageHandler.cs | 20 ++++++++++ .../Handlers/Image/ImageHandler.Android.cs | 2 +- .../Handlers/Image/ImageHandler.Standard.cs | 2 +- .../src/Handlers/Image/ImageHandler.Tizen.cs | 2 +- .../Handlers/Image/ImageHandler.Windows.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.cs | 4 +- .../src/Handlers/Image/ImageHandler.iOS.cs | 17 ++------ .../ImageButton/ImageButtonHandler.Android.cs | 2 +- .../ImageButtonHandler.Standard.cs | 2 +- .../ImageButton/ImageButtonHandler.Tizen.cs | 2 +- .../ImageButton/ImageButtonHandler.Windows.cs | 2 +- .../ImageButton/ImageButtonHandler.cs | 4 +- .../ImageButton/ImageButtonHandler.iOS.cs | 2 +- .../SwipeItemMenuItemHandler.Android.cs | 4 +- .../SwipeItemMenuItemHandler.Standard.cs | 2 +- .../SwipeItemMenuItemHandler.Tizen.cs | 2 +- .../SwipeItemMenuItemHandler.cs | 5 ++- .../SwipeItemMenuItemHandler.iOS.cs | 2 +- .../src/Platform/ImageSourcePartLoader.cs | 35 +++++++--------- src/Core/src/Platform/iOS/MauiImageView.cs | 22 ++++++++-- .../net-android/PublicAPI.Unshipped.txt | 3 ++ .../PublicAPI/net-ios/PublicAPI.Shipped.txt | 1 - .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 4 ++ .../net-maccatalyst/PublicAPI.Shipped.txt | 1 - .../net-maccatalyst/PublicAPI.Unshipped.txt | 4 ++ .../net-tizen/PublicAPI.Unshipped.txt | 3 ++ .../net-windows/PublicAPI.Unshipped.txt | 3 ++ .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 3 ++ .../netstandard/PublicAPI.Unshipped.txt | 3 ++ .../netstandard2.0/PublicAPI.Unshipped.txt | 3 ++ 37 files changed, 152 insertions(+), 65 deletions(-) create mode 100644 src/Core/src/Handlers/Image/ISetImageHandler.cs diff --git a/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.cs b/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.cs index cc2865011bab..6a6fbed620be 100644 --- a/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.cs +++ b/src/Controls/tests/DeviceTests/Elements/Image/ImageTests.cs @@ -47,5 +47,45 @@ await InvokeOnMainThreadAsync(async () => await handler.ToPlatform().AssertContainsColor(Colors.Red, MauiContext); }); } + + [Fact("Image Does Not Leak")] + public async Task DoesNotLeak() + { + SetupBuilder(); + WeakReference platformViewReference = null; + WeakReference handlerReference = null; + + await InvokeOnMainThreadAsync(async () => + { + var layout = new VerticalStackLayout(); + var image = new Image + { + Background = Colors.Black, + Source = "red.png", + }; + layout.Add(image); + + var handler = CreateHandler(layout); + handlerReference = new WeakReference(image.Handler); + platformViewReference = new WeakReference(image.Handler.PlatformView); + await image.Wait(); + }); + + Assert.NotNull(handlerReference); + Assert.NotNull(platformViewReference); + + // Several GCs required on iOS + for (int i = 0; i < 5; i++) + { + if (!handlerReference.IsAlive && !platformViewReference.IsAlive) + break; + await Task.Yield(); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + + Assert.False(handlerReference.IsAlive, "Handler should not be alive!"); + Assert.False(platformViewReference.IsAlive, "PlatformView should not be alive!"); + } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Android.cs b/src/Core/src/Handlers/Button/ButtonHandler.Android.cs index ed4841f663a9..f39dbcb06b65 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Android.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Android.cs @@ -121,7 +121,7 @@ public static Task MapImageSourceAsync(IButtonHandler handler, IImage image) return handler.ImageSourceLoader.UpdateImageSourceAsync(); } - void OnSetImageSource(Drawable? obj) + void ISetImageHandler.SetImageSource(Drawable? obj) { PlatformView.Icon = obj; } diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs b/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs index f1c5272f60c3..56f29984bf9a 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs @@ -16,6 +16,6 @@ public static void MapFont(IButtonHandler handler, ITextStyle button) { } public static void MapPadding(IButtonHandler handler, IButton button) { } public static void MapImageSource(IButtonHandler handler, IImage image) { } - void OnSetImageSource(object? obj) { } + void ISetImageHandler.SetImageSource(object? obj) { } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs index 8d99800a0833..17643315aa0c 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs @@ -110,7 +110,7 @@ void OnButtonPressed(object? sender, EventArgs e) VirtualView?.Pressed(); } - void OnSetImageSource(MauiImageSource? image) + void ISetImageHandler.SetImageSource(MauiImageSource? image) { if (image == null) return; diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs b/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs index 3960db04d1ea..6d5e93093f8f 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs @@ -90,7 +90,7 @@ public static void MapImageSource(IButtonHandler handler, IImage image) => .UpdateImageSourceAsync() .FireAndForget(handler); - void OnSetImageSource(ImageSource? platformImageSource) + void ISetImageHandler.SetImageSource(ImageSource? platformImageSource) { PlatformView.UpdateImageSource(platformImageSource); } diff --git a/src/Core/src/Handlers/Button/ButtonHandler.cs b/src/Core/src/Handlers/Button/ButtonHandler.cs index 5ace76263034..27f9264187c2 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.cs @@ -12,11 +12,11 @@ namespace Microsoft.Maui.Handlers { - public partial class ButtonHandler : IButtonHandler + public partial class ButtonHandler : IButtonHandler, ISetImageHandler { ImageSourcePartLoader? _imageSourcePartLoader; public ImageSourcePartLoader ImageSourceLoader => - _imageSourcePartLoader ??= new ImageSourcePartLoader(this, () => (VirtualView as IImageButton), OnSetImageSource); + _imageSourcePartLoader ??= new ImageSourcePartLoader(this); public static IPropertyMapper ImageButtonMapper = new PropertyMapper() { diff --git a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs index 72c793c52546..844f0007edab 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs @@ -129,7 +129,7 @@ public static void MapFormatting(IButtonHandler handler, IText button) handler.PlatformView?.UpdateCharacterSpacing(button); } - void OnSetImageSource(UIImage? image) + void ISetImageHandler.SetImageSource(UIImage? image) { if (image != null) { diff --git a/src/Core/src/Handlers/Image/ISetImageHandler.cs b/src/Core/src/Handlers/Image/ISetImageHandler.cs new file mode 100644 index 000000000000..f306453010a7 --- /dev/null +++ b/src/Core/src/Handlers/Image/ISetImageHandler.cs @@ -0,0 +1,20 @@ +#if __IOS__ || MACCATALYST +using PlatformImage = UIKit.UIImage; +#elif MONOANDROID +using PlatformImage = Android.Graphics.Drawables.Drawable; +#elif WINDOWS +using PlatformImage = Microsoft.UI.Xaml.Media.ImageSource; +#elif TIZEN +using PlatformImage = Microsoft.Maui.Platform.MauiImageSource; +#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID && !TIZEN) +using PlatformImage = System.Object; +#endif + +namespace Microsoft.Maui +{ + public interface ISetImageHandler : IElementHandler + { + void SetImageSource(PlatformImage? obj); + } +} + diff --git a/src/Core/src/Handlers/Image/ImageHandler.Android.cs b/src/Core/src/Handlers/Image/ImageHandler.Android.cs index e10e19f3b864..05987acb3d89 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Android.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Android.cs @@ -50,7 +50,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void OnSetImageSource(Drawable? obj) => + void ISetImageHandler.SetImageSource(Drawable? obj) => PlatformView.SetImageDrawable(obj); public override void PlatformArrange(Graphics.Rect frame) diff --git a/src/Core/src/Handlers/Image/ImageHandler.Standard.cs b/src/Core/src/Handlers/Image/ImageHandler.Standard.cs index aa53e8b303b6..b37b43151f9a 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Standard.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Standard.cs @@ -8,6 +8,6 @@ public partial class ImageHandler : ViewHandler public static void MapAspect(IImageHandler handler, IImage image) { } public static void MapIsAnimationPlaying(IImageHandler handler, IImage image) { } public static void MapSource(IImageHandler handler, IImage image) { } - void OnSetImageSource(object? obj) => throw new NotImplementedException(); + void ISetImageHandler.SetImageSource(object? obj) => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs index 3ad22785be1d..25d5fdb5acc1 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs @@ -37,7 +37,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void OnSetImageSource(MauiImageSource? obj) + void ISetImageHandler.SetImageSource(MauiImageSource? obj) { if (obj == null) return; diff --git a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs index 3d65a70822a0..2685b8073f9f 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs @@ -38,7 +38,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void OnSetImageSource(ImageSource? obj) => + void ISetImageHandler.SetImageSource(ImageSource? obj) => PlatformView.Source = obj; } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Image/ImageHandler.cs b/src/Core/src/Handlers/Image/ImageHandler.cs index e53d97de7eea..fd7ed9f46c75 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.cs @@ -14,7 +14,7 @@ namespace Microsoft.Maui.Handlers { - public partial class ImageHandler : IImageHandler + public partial class ImageHandler : IImageHandler, ISetImageHandler { public static IPropertyMapper Mapper = new PropertyMapper(ViewHandler.ViewMapper) { @@ -32,7 +32,7 @@ public partial class ImageHandler : IImageHandler ImageSourcePartLoader? _imageSourcePartLoader; public ImageSourcePartLoader SourceLoader => - _imageSourcePartLoader ??= new ImageSourcePartLoader(this, () => VirtualView, OnSetImageSource); + _imageSourcePartLoader ??= new ImageSourcePartLoader(this); public ImageHandler() : base(Mapper) { diff --git a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs index 5159b75814fa..6fe9555df1d4 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs @@ -9,23 +9,12 @@ namespace Microsoft.Maui.Handlers { public partial class ImageHandler : ViewHandler { - protected override UIImageView CreatePlatformView() => new MauiImageView(); - - protected override void ConnectHandler(UIImageView platformView) - { - base.ConnectHandler(platformView); - - if (PlatformView is MauiImageView imageView) - imageView.WindowChanged += OnWindowChanged; - } + protected override UIImageView CreatePlatformView() => new MauiImageView(this); protected override void DisconnectHandler(UIImageView platformView) { base.DisconnectHandler(platformView); - if (platformView is MauiImageView imageView) - imageView.WindowChanged -= OnWindowChanged; - SourceLoader.Reset(); } @@ -52,10 +41,10 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void OnSetImageSource(UIImage? obj) => + void ISetImageHandler.SetImageSource(UIImage? obj) => PlatformView.Image = obj; - void OnWindowChanged(object? sender, EventArgs e) + internal void NotifyWindowChanged() { if (SourceLoader.SourceManager.IsResolutionDependent) UpdateValue(nameof(IImage.Source)); diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs index dcaeafe48900..9e1fc956da56 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs @@ -18,7 +18,7 @@ protected override ShapeableImageView CreatePlatformView() return platformView; } - void OnSetImageSource(Drawable? obj) + void ISetImageHandler.SetImageSource(Drawable? obj) { PlatformView.SetImageDrawable(obj); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs index 4ff496bccde6..64bae664bd5b 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs @@ -11,7 +11,7 @@ public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke) { } public static void MapPadding(IImageButtonHandler handler, IImageButton imageButton) { } - void OnSetImageSource(object? obj) + void ISetImageHandler.SetImageSource(object? obj) { throw new NotImplementedException(); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs index b5b7753fd42e..b7b91f5de839 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs @@ -66,7 +66,7 @@ void OnClicked(object? sender, EventArgs e) VirtualView?.Clicked(); } - void OnSetImageSource(MauiImageSource? img) + void ISetImageHandler.SetImageSource(MauiImageSource? img) { if (img == null) return; diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs index e67d5af21d57..33bbfe5568da 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs @@ -90,7 +90,7 @@ public static void MapPadding(IImageButtonHandler handler, IImageButton imageBut (handler.PlatformView as Button)?.UpdatePadding(imageButton); } - void OnSetImageSource(ImageSource? nativeImageSource) + void ISetImageHandler.SetImageSource(ImageSource? nativeImageSource) { PlatformView.UpdateImageSource(nativeImageSource); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs index 174004f75516..3d08b2a901a3 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs @@ -23,7 +23,7 @@ namespace Microsoft.Maui.Handlers { - public partial class ImageButtonHandler : IImageButtonHandler + public partial class ImageButtonHandler : IImageButtonHandler, ISetImageHandler { public static IPropertyMapper ImageMapper = new PropertyMapper(ImageHandler.Mapper); @@ -44,7 +44,7 @@ public partial class ImageButtonHandler : IImageButtonHandler ImageSourcePartLoader? _imageSourcePartLoader; public ImageSourcePartLoader SourceLoader => - _imageSourcePartLoader ??= new ImageSourcePartLoader(this, () => VirtualView, OnSetImageSource); + _imageSourcePartLoader ??= new ImageSourcePartLoader(this); public ImageButtonHandler() : base(Mapper) { diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs index 382391ad4fb4..79470e3ab7ac 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs @@ -15,7 +15,7 @@ protected override UIButton CreatePlatformView() return platformView; } - void OnSetImageSource(UIImage? obj) + void ISetImageHandler.SetImageSource(UIImage? obj) { PlatformView.SetImage(obj?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); PlatformView.HorizontalAlignment = UIControlContentHorizontalAlignment.Fill; diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs index fe9f4f21450f..585aa9e04efa 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs @@ -133,7 +133,7 @@ void UpdateSize() var icons = textView.GetCompoundDrawables(); if (icons.Length > 1 && icons[1] != null) { - OnSetImageSource(icons[1]); + ((ISetImageHandler)this).SetImageSource(icons[1]); } } @@ -143,7 +143,7 @@ void UpdateSize() PlatformView.SetPadding(0, buttonPadding, 0, buttonPadding); } - void OnSetImageSource(Drawable? drawable) + void ISetImageHandler.SetImageSource(Drawable? drawable) { if (drawable != null) { diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs index 75b624caa737..687e5d122ad9 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs @@ -23,7 +23,7 @@ public static void MapBackground(ISwipeItemMenuItemHandler handler, ISwipeItemMe public static void MapVisibility(ISwipeItemMenuItemHandler handler, ISwipeItemMenuItem view) { } - void OnSetImageSource(object? obj) + void ISetImageHandler.SetImageSource(object? obj) { throw new NotImplementedException(); } diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs index 793d26df6a67..f7013ad881c3 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs @@ -58,7 +58,7 @@ public static void MapVisibility(ISwipeItemMenuItemHandler handler, ISwipeItemMe } - void OnSetImageSource(MauiImageSource? obj) + void ISetImageHandler.SetImageSource(MauiImageSource? obj) { if (obj != null) PlatformView.Icon.ResourceUrl = obj.ResourceUrl; diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs index 2ce9d6cd539b..025f039b1647 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs @@ -15,6 +15,9 @@ namespace Microsoft.Maui.Handlers { public partial class SwipeItemMenuItemHandler : ISwipeItemMenuItemHandler +#if !WINDOWS + , ISetImageHandler +#endif { public static IPropertyMapper Mapper = new PropertyMapper(ViewHandler.ElementMapper) @@ -56,7 +59,7 @@ protected SwipeItemMenuItemHandler(IPropertyMapper? mapper, CommandMapper? comma #if !WINDOWS ImageSourcePartLoader? _imageSourcePartLoader; public ImageSourcePartLoader SourceLoader => - _imageSourcePartLoader ??= new ImageSourcePartLoader(this, () => VirtualView, OnSetImageSource); + _imageSourcePartLoader ??= new ImageSourcePartLoader(this); public static void MapSource(ISwipeItemMenuItemHandler handler, ISwipeItemMenuItem image) => diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs index e49c2ae9eec5..29aa2998554b 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs @@ -97,7 +97,7 @@ void OnSwipeItemFrameChanged(object? sender, EventArgs e) swipeItemMenuItemHandler.UpdateValue(nameof(ISwipeItemMenuItem.Source)); } - void OnSetImageSource(UIImage? image) + void ISetImageHandler.SetImageSource(UIImage? image) { if (PlatformView == null || PlatformView.Frame == CGRect.Empty) return; diff --git a/src/Core/src/Platform/ImageSourcePartLoader.cs b/src/Core/src/Platform/ImageSourcePartLoader.cs index c8df9d3702e9..841d75f3b9fa 100644 --- a/src/Core/src/Platform/ImageSourcePartLoader.cs +++ b/src/Core/src/Platform/ImageSourcePartLoader.cs @@ -23,29 +23,22 @@ namespace Microsoft.Maui.Platform { public partial class ImageSourcePartLoader { +#if IOS || ANDROID || WINDOWS || TIZEN IImageSourceServiceProvider? _imageSourceServiceProvider; - IImageSourceServiceProvider ImageSourceServiceProvider => - _imageSourceServiceProvider ??= Handler.GetRequiredService(); +#endif - readonly Func _imageSourcePart; - Action? SetImage { get; } - PlatformView? PlatformView => Handler.PlatformView as PlatformView; + readonly WeakReference _handler; internal ImageSourceServiceResultManager SourceManager { get; } = new ImageSourceServiceResultManager(); - IElementHandler Handler { get; } - - public ImageSourcePartLoader( - IElementHandler handler, - Func imageSourcePart, - Action setImage) + [Obsolete("To be removed in a future release")] + public ImageSourcePartLoader(IElementHandler handler, Func imageSourcePart, Action setImage) + : this((ISetImageHandler)handler) { - Handler = handler; - _imageSourcePart = imageSourcePart; - - SetImage = setImage; } + public ImageSourcePartLoader(ISetImageHandler handler) => _handler = new(handler); + public void Reset() { SourceManager.Reset(); @@ -53,18 +46,20 @@ public void Reset() public async Task UpdateImageSourceAsync() { - if (PlatformView is null) + if (!_handler.TryGetTarget(out var handler) || handler.PlatformView is not PlatformView platformView) { return; } var token = this.SourceManager.BeginLoad(); - var imageSource = _imageSourcePart(); + var imageSource = handler.VirtualView as IImageSourcePart; if (imageSource?.Source is not null) { -#if __IOS__ || __ANDROID__ || WINDOWS || TIZEN - var result = await imageSource.UpdateSourceAsync(PlatformView, ImageSourceServiceProvider, SetImage!, token) +#if IOS || ANDROID || WINDOWS || TIZEN + _imageSourceServiceProvider ??= handler.GetRequiredService(); + + var result = await imageSource.UpdateSourceAsync(platformView, _imageSourceServiceProvider, handler.SetImageSource, token) .ConfigureAwait(false); SourceManager.CompleteLoad(result); @@ -74,7 +69,7 @@ public async Task UpdateImageSourceAsync() } else { - SetImage?.Invoke(null); + handler.SetImageSource(null); } } } diff --git a/src/Core/src/Platform/iOS/MauiImageView.cs b/src/Core/src/Platform/iOS/MauiImageView.cs index cd8a70c756bd..46484aa07bad 100644 --- a/src/Core/src/Platform/iOS/MauiImageView.cs +++ b/src/Core/src/Platform/iOS/MauiImageView.cs @@ -7,18 +7,34 @@ namespace Microsoft.Maui.Platform { public class MauiImageView : UIImageView { + WeakReference? _handler; + + public MauiImageView(ImageHandler handler) => _handler = new WeakReference(handler); + + [Obsolete("To be removed in a future release")] public MauiImageView() { } + [Obsolete("To be removed in a future release")] public MauiImageView(CGRect frame) : base(frame) { } - public override void MovedToWindow() => - WindowChanged?.Invoke(this, EventArgs.Empty); + public override void MovedToWindow() + { + if (_handler is not null && _handler.TryGetTarget(out var handler)) + { + handler.NotifyWindowChanged(); + } + } - public event EventHandler? WindowChanged; + [Obsolete("To be removed in a future release")] + public event EventHandler? WindowChanged + { + add { } + remove { } + } } } \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 4528ab650bd9..550987ca014d 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -12,7 +12,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.Platform.ShapeExtensions Microsoft.Maui.PlatformContentViewGroup Microsoft.Maui.PlatformContentViewGroup.PlatformContentViewGroup(Android.Content.Context? context) -> void diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt index 33b506e9c9ff..46734dcc64b6 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Shipped.txt @@ -2048,7 +2048,6 @@ override Microsoft.Maui.Handlers.GraphicsViewHandler.DisconnectHandler(Microsoft override Microsoft.Maui.Handlers.ImageButtonHandler.ConnectHandler(UIKit.UIButton! platformView) -> void override Microsoft.Maui.Handlers.ImageButtonHandler.CreatePlatformView() -> UIKit.UIButton! override Microsoft.Maui.Handlers.ImageButtonHandler.DisconnectHandler(UIKit.UIButton! platformView) -> void -override Microsoft.Maui.Handlers.ImageHandler.ConnectHandler(UIKit.UIImageView! platformView) -> void override Microsoft.Maui.Handlers.ImageHandler.CreatePlatformView() -> UIKit.UIImageView! override Microsoft.Maui.Handlers.ImageHandler.DisconnectHandler(UIKit.UIImageView! platformView) -> void override Microsoft.Maui.Handlers.ImageHandler.NeedsContainer.get -> bool diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 6f5b808a602e..8184b77394ac 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -12,9 +12,13 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.Platform.KeyboardAutoManagerScroll +Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool Microsoft.Maui.Platform.MauiScrollView Microsoft.Maui.Platform.MauiScrollView.MauiScrollView() -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt index c309c73fac4d..99b100cd5bac 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Shipped.txt @@ -2047,7 +2047,6 @@ override Microsoft.Maui.Handlers.GraphicsViewHandler.DisconnectHandler(Microsoft override Microsoft.Maui.Handlers.ImageButtonHandler.ConnectHandler(UIKit.UIButton! platformView) -> void override Microsoft.Maui.Handlers.ImageButtonHandler.CreatePlatformView() -> UIKit.UIButton! override Microsoft.Maui.Handlers.ImageButtonHandler.DisconnectHandler(UIKit.UIButton! platformView) -> void -override Microsoft.Maui.Handlers.ImageHandler.ConnectHandler(UIKit.UIImageView! platformView) -> void override Microsoft.Maui.Handlers.ImageHandler.CreatePlatformView() -> UIKit.UIImageView! override Microsoft.Maui.Handlers.ImageHandler.DisconnectHandler(UIKit.UIImageView! platformView) -> void override Microsoft.Maui.Handlers.ImageHandler.NeedsContainer.get -> bool diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index d5df84b62fe5..f04a1527e5b4 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -12,7 +12,11 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void Microsoft.Maui.Platform.MauiView.CacheMeasureConstraints(double widthConstraint, double heightConstraint) -> void Microsoft.Maui.Platform.MauiView.InvalidateConstraintsCache() -> void Microsoft.Maui.Platform.MauiView.IsMeasureValid(double widthConstraint, double heightConstraint) -> bool diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 2009754326f7..e00edb7df87d 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -11,6 +11,9 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index cfcb47a2871a..96dcc69ed90b 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -3,6 +3,8 @@ Microsoft.Maui.CommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.FocusRequest.FocusRequest() -> void Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void Microsoft.Maui.IWindow.TitleBarDragRectangles.get -> Microsoft.Maui.Graphics.Rect[]? Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.GetCommand(string! key) -> System.Action? @@ -11,6 +13,7 @@ Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.Platform.MauiWebView.MauiWebView(Microsoft.Maui.Handlers.WebViewHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Handlers.ContentViewHandler.DisconnectHandler(Microsoft.Maui.Platform.ContentPanel! platformView) -> void diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index b2d2c7ce9dc6..ed808c473db0 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -9,7 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index fb05d546b19a..ecb59a4c8cb0 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -9,7 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index b2d2c7ce9dc6..ed808c473db0 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -9,7 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void +Microsoft.Maui.ISetImageHandler +Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int From 75d3e60f9e923c99e3af9df85cd94cc73fddeb5e Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 16 May 2023 15:46:45 -0500 Subject: [PATCH 2/8] Update src/Core/src/Platform/ImageSourcePartLoader.cs Co-authored-by: Matthew Leibowitz --- src/Core/src/Platform/ImageSourcePartLoader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/ImageSourcePartLoader.cs b/src/Core/src/Platform/ImageSourcePartLoader.cs index 841d75f3b9fa..94330d62a78a 100644 --- a/src/Core/src/Platform/ImageSourcePartLoader.cs +++ b/src/Core/src/Platform/ImageSourcePartLoader.cs @@ -31,7 +31,7 @@ public partial class ImageSourcePartLoader internal ImageSourceServiceResultManager SourceManager { get; } = new ImageSourceServiceResultManager(); - [Obsolete("To be removed in a future release")] + [Obsolete("Use ImageSourcePartLoader(ISetImageHandler handler) instead.")] public ImageSourcePartLoader(IElementHandler handler, Func imageSourcePart, Action setImage) : this((ISetImageHandler)handler) { From d2478464b2f601d9b383892759324651ec9b25c1 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 16 May 2023 15:49:01 -0500 Subject: [PATCH 3/8] Update MauiImageView.cs --- src/Core/src/Platform/iOS/MauiImageView.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Core/src/Platform/iOS/MauiImageView.cs b/src/Core/src/Platform/iOS/MauiImageView.cs index 46484aa07bad..51897b0424fd 100644 --- a/src/Core/src/Platform/iOS/MauiImageView.cs +++ b/src/Core/src/Platform/iOS/MauiImageView.cs @@ -11,12 +11,12 @@ public class MauiImageView : UIImageView public MauiImageView(ImageHandler handler) => _handler = new WeakReference(handler); - [Obsolete("To be removed in a future release")] + [Obsolete("Use MauiImageView(ImageHandler handler) instead.")] public MauiImageView() { } - [Obsolete("To be removed in a future release")] + [Obsolete("Use MauiImageView(ImageHandler handler) instead.")] public MauiImageView(CGRect frame) : base(frame) { From f057f3bcdcd9a8000a0a86a1f8ff9bb3bb25a123 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 16 May 2023 15:53:17 -0500 Subject: [PATCH 4/8] Update MauiImageView.cs --- src/Core/src/Platform/iOS/MauiImageView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/iOS/MauiImageView.cs b/src/Core/src/Platform/iOS/MauiImageView.cs index 51897b0424fd..418522cde024 100644 --- a/src/Core/src/Platform/iOS/MauiImageView.cs +++ b/src/Core/src/Platform/iOS/MauiImageView.cs @@ -30,7 +30,7 @@ public override void MovedToWindow() } } - [Obsolete("To be removed in a future release")] + [Obsolete("No longer fired on iOS, as it introduces a memory leak.")] public event EventHandler? WindowChanged { add { } From 71249db808f2f43e95da692bb7e25a2fa2f16478 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 16 May 2023 16:02:04 -0500 Subject: [PATCH 5/8] ISetImageHandler -> IImageSourcePartSetter --- src/Core/src/Handlers/Button/ButtonHandler.Android.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.Standard.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.Windows.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.cs | 2 +- src/Core/src/Handlers/Button/ButtonHandler.iOS.cs | 2 +- .../{ISetImageHandler.cs => IImageSourcePartSetter.cs} | 2 +- src/Core/src/Handlers/Image/ImageHandler.Android.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.Standard.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.Tizen.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.Windows.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.cs | 2 +- src/Core/src/Handlers/Image/ImageHandler.iOS.cs | 2 +- .../Handlers/ImageButton/ImageButtonHandler.Android.cs | 2 +- .../Handlers/ImageButton/ImageButtonHandler.Standard.cs | 2 +- .../src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs | 2 +- .../Handlers/ImageButton/ImageButtonHandler.Windows.cs | 2 +- src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs | 2 +- .../src/Handlers/ImageButton/ImageButtonHandler.iOS.cs | 2 +- .../SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs | 4 ++-- .../SwipeItemMenuItemHandler.Standard.cs | 2 +- .../SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs | 2 +- .../SwipeItemMenuItem/SwipeItemMenuItemHandler.cs | 2 +- .../SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs | 2 +- src/Core/src/Platform/ImageSourcePartLoader.cs | 8 ++++---- .../src/PublicAPI/net-android/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | 6 +++--- 33 files changed, 53 insertions(+), 53 deletions(-) rename src/Core/src/Handlers/Image/{ISetImageHandler.cs => IImageSourcePartSetter.cs} (89%) diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Android.cs b/src/Core/src/Handlers/Button/ButtonHandler.Android.cs index f39dbcb06b65..efe6d9197f27 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Android.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Android.cs @@ -121,7 +121,7 @@ public static Task MapImageSourceAsync(IButtonHandler handler, IImage image) return handler.ImageSourceLoader.UpdateImageSourceAsync(); } - void ISetImageHandler.SetImageSource(Drawable? obj) + void IImageSourcePartSetter.SetImageSource(Drawable? obj) { PlatformView.Icon = obj; } diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs b/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs index 56f29984bf9a..a6ea866ecf48 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Standard.cs @@ -16,6 +16,6 @@ public static void MapFont(IButtonHandler handler, ITextStyle button) { } public static void MapPadding(IButtonHandler handler, IButton button) { } public static void MapImageSource(IButtonHandler handler, IImage image) { } - void ISetImageHandler.SetImageSource(object? obj) { } + void IImageSourcePartSetter.SetImageSource(object? obj) { } } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs index 17643315aa0c..361590849843 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Tizen.cs @@ -110,7 +110,7 @@ void OnButtonPressed(object? sender, EventArgs e) VirtualView?.Pressed(); } - void ISetImageHandler.SetImageSource(MauiImageSource? image) + void IImageSourcePartSetter.SetImageSource(MauiImageSource? image) { if (image == null) return; diff --git a/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs b/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs index 6d5e93093f8f..6a40d69d295f 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.Windows.cs @@ -90,7 +90,7 @@ public static void MapImageSource(IButtonHandler handler, IImage image) => .UpdateImageSourceAsync() .FireAndForget(handler); - void ISetImageHandler.SetImageSource(ImageSource? platformImageSource) + void IImageSourcePartSetter.SetImageSource(ImageSource? platformImageSource) { PlatformView.UpdateImageSource(platformImageSource); } diff --git a/src/Core/src/Handlers/Button/ButtonHandler.cs b/src/Core/src/Handlers/Button/ButtonHandler.cs index 27f9264187c2..155567719c27 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.cs @@ -12,7 +12,7 @@ namespace Microsoft.Maui.Handlers { - public partial class ButtonHandler : IButtonHandler, ISetImageHandler + public partial class ButtonHandler : IButtonHandler, IImageSourcePartSetter { ImageSourcePartLoader? _imageSourcePartLoader; public ImageSourcePartLoader ImageSourceLoader => diff --git a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs index 844f0007edab..fad540b53836 100644 --- a/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs +++ b/src/Core/src/Handlers/Button/ButtonHandler.iOS.cs @@ -129,7 +129,7 @@ public static void MapFormatting(IButtonHandler handler, IText button) handler.PlatformView?.UpdateCharacterSpacing(button); } - void ISetImageHandler.SetImageSource(UIImage? image) + void IImageSourcePartSetter.SetImageSource(UIImage? image) { if (image != null) { diff --git a/src/Core/src/Handlers/Image/ISetImageHandler.cs b/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs similarity index 89% rename from src/Core/src/Handlers/Image/ISetImageHandler.cs rename to src/Core/src/Handlers/Image/IImageSourcePartSetter.cs index f306453010a7..f71664bd2f75 100644 --- a/src/Core/src/Handlers/Image/ISetImageHandler.cs +++ b/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs @@ -12,7 +12,7 @@ namespace Microsoft.Maui { - public interface ISetImageHandler : IElementHandler + public interface IImageSourcePartSetter : IElementHandler { void SetImageSource(PlatformImage? obj); } diff --git a/src/Core/src/Handlers/Image/ImageHandler.Android.cs b/src/Core/src/Handlers/Image/ImageHandler.Android.cs index 05987acb3d89..245e43f392d5 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Android.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Android.cs @@ -50,7 +50,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void ISetImageHandler.SetImageSource(Drawable? obj) => + void IImageSourcePartSetter.SetImageSource(Drawable? obj) => PlatformView.SetImageDrawable(obj); public override void PlatformArrange(Graphics.Rect frame) diff --git a/src/Core/src/Handlers/Image/ImageHandler.Standard.cs b/src/Core/src/Handlers/Image/ImageHandler.Standard.cs index b37b43151f9a..55876d4c06cf 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Standard.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Standard.cs @@ -8,6 +8,6 @@ public partial class ImageHandler : ViewHandler public static void MapAspect(IImageHandler handler, IImage image) { } public static void MapIsAnimationPlaying(IImageHandler handler, IImage image) { } public static void MapSource(IImageHandler handler, IImage image) { } - void ISetImageHandler.SetImageSource(object? obj) => throw new NotImplementedException(); + void IImageSourcePartSetter.SetImageSource(object? obj) => throw new NotImplementedException(); } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs index 25d5fdb5acc1..b05c91114059 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Tizen.cs @@ -37,7 +37,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void ISetImageHandler.SetImageSource(MauiImageSource? obj) + void IImageSourcePartSetter.SetImageSource(MauiImageSource? obj) { if (obj == null) return; diff --git a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs index 2685b8073f9f..b10443ae10c4 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.Windows.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.Windows.cs @@ -38,7 +38,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void ISetImageHandler.SetImageSource(ImageSource? obj) => + void IImageSourcePartSetter.SetImageSource(ImageSource? obj) => PlatformView.Source = obj; } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Image/ImageHandler.cs b/src/Core/src/Handlers/Image/ImageHandler.cs index fd7ed9f46c75..65bbfadde8b1 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.cs @@ -14,7 +14,7 @@ namespace Microsoft.Maui.Handlers { - public partial class ImageHandler : IImageHandler, ISetImageHandler + public partial class ImageHandler : IImageHandler, IImageSourcePartSetter { public static IPropertyMapper Mapper = new PropertyMapper(ViewHandler.ViewMapper) { diff --git a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs index 6fe9555df1d4..94bc0d5cecce 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs @@ -41,7 +41,7 @@ public static void MapSource(IImageHandler handler, IImage image) => public static Task MapSourceAsync(IImageHandler handler, IImage image) => handler.SourceLoader.UpdateImageSourceAsync(); - void ISetImageHandler.SetImageSource(UIImage? obj) => + void IImageSourcePartSetter.SetImageSource(UIImage? obj) => PlatformView.Image = obj; internal void NotifyWindowChanged() diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs index 9e1fc956da56..a3bb1ccb4599 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Android.cs @@ -18,7 +18,7 @@ protected override ShapeableImageView CreatePlatformView() return platformView; } - void ISetImageHandler.SetImageSource(Drawable? obj) + void IImageSourcePartSetter.SetImageSource(Drawable? obj) { PlatformView.SetImageDrawable(obj); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs index 64bae664bd5b..bcf16c86eaad 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Standard.cs @@ -11,7 +11,7 @@ public static void MapStrokeThickness(IImageButtonHandler handler, IButtonStroke public static void MapCornerRadius(IImageButtonHandler handler, IButtonStroke buttonStroke) { } public static void MapPadding(IImageButtonHandler handler, IImageButton imageButton) { } - void ISetImageHandler.SetImageSource(object? obj) + void IImageSourcePartSetter.SetImageSource(object? obj) { throw new NotImplementedException(); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs index b7b91f5de839..15739ee0a769 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Tizen.cs @@ -66,7 +66,7 @@ void OnClicked(object? sender, EventArgs e) VirtualView?.Clicked(); } - void ISetImageHandler.SetImageSource(MauiImageSource? img) + void IImageSourcePartSetter.SetImageSource(MauiImageSource? img) { if (img == null) return; diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs index 33bbfe5568da..de00ae969b49 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.Windows.cs @@ -90,7 +90,7 @@ public static void MapPadding(IImageButtonHandler handler, IImageButton imageBut (handler.PlatformView as Button)?.UpdatePadding(imageButton); } - void ISetImageHandler.SetImageSource(ImageSource? nativeImageSource) + void IImageSourcePartSetter.SetImageSource(ImageSource? nativeImageSource) { PlatformView.UpdateImageSource(nativeImageSource); } diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs index 3d08b2a901a3..d32e74de6aad 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.cs @@ -23,7 +23,7 @@ namespace Microsoft.Maui.Handlers { - public partial class ImageButtonHandler : IImageButtonHandler, ISetImageHandler + public partial class ImageButtonHandler : IImageButtonHandler, IImageSourcePartSetter { public static IPropertyMapper ImageMapper = new PropertyMapper(ImageHandler.Mapper); diff --git a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs index 79470e3ab7ac..171634e1089b 100644 --- a/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs +++ b/src/Core/src/Handlers/ImageButton/ImageButtonHandler.iOS.cs @@ -15,7 +15,7 @@ protected override UIButton CreatePlatformView() return platformView; } - void ISetImageHandler.SetImageSource(UIImage? obj) + void IImageSourcePartSetter.SetImageSource(UIImage? obj) { PlatformView.SetImage(obj?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), UIControlState.Normal); PlatformView.HorizontalAlignment = UIControlContentHorizontalAlignment.Fill; diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs index 585aa9e04efa..98e3f498be1f 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Android.cs @@ -133,7 +133,7 @@ void UpdateSize() var icons = textView.GetCompoundDrawables(); if (icons.Length > 1 && icons[1] != null) { - ((ISetImageHandler)this).SetImageSource(icons[1]); + ((IImageSourcePartSetter)this).SetImageSource(icons[1]); } } @@ -143,7 +143,7 @@ void UpdateSize() PlatformView.SetPadding(0, buttonPadding, 0, buttonPadding); } - void ISetImageHandler.SetImageSource(Drawable? drawable) + void IImageSourcePartSetter.SetImageSource(Drawable? drawable) { if (drawable != null) { diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs index 687e5d122ad9..618ceb3a1f47 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Standard.cs @@ -23,7 +23,7 @@ public static void MapBackground(ISwipeItemMenuItemHandler handler, ISwipeItemMe public static void MapVisibility(ISwipeItemMenuItemHandler handler, ISwipeItemMenuItem view) { } - void ISetImageHandler.SetImageSource(object? obj) + void IImageSourcePartSetter.SetImageSource(object? obj) { throw new NotImplementedException(); } diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs index f7013ad881c3..07e846db47c5 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.Tizen.cs @@ -58,7 +58,7 @@ public static void MapVisibility(ISwipeItemMenuItemHandler handler, ISwipeItemMe } - void ISetImageHandler.SetImageSource(MauiImageSource? obj) + void IImageSourcePartSetter.SetImageSource(MauiImageSource? obj) { if (obj != null) PlatformView.Icon.ResourceUrl = obj.ResourceUrl; diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs index 025f039b1647..29d82f59a41b 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.cs @@ -16,7 +16,7 @@ namespace Microsoft.Maui.Handlers { public partial class SwipeItemMenuItemHandler : ISwipeItemMenuItemHandler #if !WINDOWS - , ISetImageHandler + , IImageSourcePartSetter #endif { public static IPropertyMapper Mapper = diff --git a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs index 29aa2998554b..172e4d8afdd4 100644 --- a/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs +++ b/src/Core/src/Handlers/SwipeItemMenuItem/SwipeItemMenuItemHandler.iOS.cs @@ -97,7 +97,7 @@ void OnSwipeItemFrameChanged(object? sender, EventArgs e) swipeItemMenuItemHandler.UpdateValue(nameof(ISwipeItemMenuItem.Source)); } - void ISetImageHandler.SetImageSource(UIImage? image) + void IImageSourcePartSetter.SetImageSource(UIImage? image) { if (PlatformView == null || PlatformView.Frame == CGRect.Empty) return; diff --git a/src/Core/src/Platform/ImageSourcePartLoader.cs b/src/Core/src/Platform/ImageSourcePartLoader.cs index 94330d62a78a..038a5b3e3fff 100644 --- a/src/Core/src/Platform/ImageSourcePartLoader.cs +++ b/src/Core/src/Platform/ImageSourcePartLoader.cs @@ -27,17 +27,17 @@ public partial class ImageSourcePartLoader IImageSourceServiceProvider? _imageSourceServiceProvider; #endif - readonly WeakReference _handler; + readonly WeakReference _handler; internal ImageSourceServiceResultManager SourceManager { get; } = new ImageSourceServiceResultManager(); - [Obsolete("Use ImageSourcePartLoader(ISetImageHandler handler) instead.")] + [Obsolete("Use ImageSourcePartLoader(IImageSourcePartSetter handler) instead.")] public ImageSourcePartLoader(IElementHandler handler, Func imageSourcePart, Action setImage) - : this((ISetImageHandler)handler) + : this((IImageSourcePartSetter)handler) { } - public ImageSourcePartLoader(ISetImageHandler handler) => _handler = new(handler); + public ImageSourcePartLoader(IImageSourcePartSetter handler) => _handler = new(handler); public void Reset() { diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 550987ca014d..3e857b98f9a6 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -12,10 +12,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.ShapeExtensions Microsoft.Maui.PlatformContentViewGroup Microsoft.Maui.PlatformContentViewGroup.PlatformContentViewGroup(Android.Content.Context? context) -> void diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 8184b77394ac..777c094230ab 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -12,11 +12,11 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.KeyboardAutoManagerScroll Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index f04a1527e5b4..00296a0bada2 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -12,10 +12,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void Microsoft.Maui.Platform.MauiView.CacheMeasureConstraints(double widthConstraint, double heightConstraint) -> void Microsoft.Maui.Platform.MauiView.InvalidateConstraintsCache() -> void diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index e00edb7df87d..17ac6c2374fb 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -11,9 +11,9 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 96dcc69ed90b..bb129d181951 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -3,8 +3,8 @@ Microsoft.Maui.CommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.FocusRequest.FocusRequest() -> void Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void Microsoft.Maui.IWindow.TitleBarDragRectangles.get -> Microsoft.Maui.Graphics.Rect[]? Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.GetCommand(string! key) -> System.Action? @@ -13,7 +13,7 @@ Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.MauiWebView.MauiWebView(Microsoft.Maui.Handlers.WebViewHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Handlers.ContentViewHandler.DisconnectHandler(Microsoft.Maui.Platform.ContentPanel! platformView) -> void diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index ed808c473db0..bc68f16e161f 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index ecb59a4c8cb0..a4061224dd98 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index ed808c473db0..bc68f16e161f 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.ISetImageHandler -Microsoft.Maui.ISetImageHandler.SetImageSource(object? obj) -> void +Microsoft.Maui.IImageSourcePartSetter +Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.ISetImageHandler! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int From 3401281605e1f0bec826981282d0335333e42211 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 16 May 2023 16:17:25 -0500 Subject: [PATCH 6/8] IImageHandler.OnWindowChanged() is now public --- src/Core/src/Handlers/Image/IImageHandler.cs | 4 ++++ src/Core/src/Handlers/Image/ImageHandler.iOS.cs | 2 +- src/Core/src/Platform/iOS/MauiImageView.cs | 12 ++++++------ .../src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 4 +++- .../net-maccatalyst/PublicAPI.Unshipped.txt | 4 +++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Core/src/Handlers/Image/IImageHandler.cs b/src/Core/src/Handlers/Image/IImageHandler.cs index 66d0a9503c9b..c04b241b080f 100644 --- a/src/Core/src/Handlers/Image/IImageHandler.cs +++ b/src/Core/src/Handlers/Image/IImageHandler.cs @@ -17,5 +17,9 @@ public partial interface IImageHandler : IViewHandler new IImage VirtualView { get; } ImageSourcePartLoader SourceLoader { get; } new PlatformView PlatformView { get; } + +#if IOS || MACCATALYST + void OnWindowChanged() { } +#endif } } \ No newline at end of file diff --git a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs index 94bc0d5cecce..5063ace6630b 100644 --- a/src/Core/src/Handlers/Image/ImageHandler.iOS.cs +++ b/src/Core/src/Handlers/Image/ImageHandler.iOS.cs @@ -44,7 +44,7 @@ public static Task MapSourceAsync(IImageHandler handler, IImage image) => void IImageSourcePartSetter.SetImageSource(UIImage? obj) => PlatformView.Image = obj; - internal void NotifyWindowChanged() + public void OnWindowChanged() { if (SourceLoader.SourceManager.IsResolutionDependent) UpdateValue(nameof(IImage.Source)); diff --git a/src/Core/src/Platform/iOS/MauiImageView.cs b/src/Core/src/Platform/iOS/MauiImageView.cs index 418522cde024..561dd0de2928 100644 --- a/src/Core/src/Platform/iOS/MauiImageView.cs +++ b/src/Core/src/Platform/iOS/MauiImageView.cs @@ -7,16 +7,16 @@ namespace Microsoft.Maui.Platform { public class MauiImageView : UIImageView { - WeakReference? _handler; + WeakReference? _handler; - public MauiImageView(ImageHandler handler) => _handler = new WeakReference(handler); + public MauiImageView(IImageHandler handler) => _handler = new(handler); - [Obsolete("Use MauiImageView(ImageHandler handler) instead.")] + [Obsolete("Use MauiImageView(IImageHandler handler) instead.")] public MauiImageView() { } - [Obsolete("Use MauiImageView(ImageHandler handler) instead.")] + [Obsolete("Use MauiImageView(IImageHandler handler) instead.")] public MauiImageView(CGRect frame) : base(frame) { @@ -26,11 +26,11 @@ public override void MovedToWindow() { if (_handler is not null && _handler.TryGetTarget(out var handler)) { - handler.NotifyWindowChanged(); + handler.OnWindowChanged(); } } - [Obsolete("No longer fired on iOS, as it introduces a memory leak.")] + [Obsolete("Use IImageHandler.OnWindowChanged() instead.")] public event EventHandler? WindowChanged { add { } diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 777c094230ab..bceadcd9dd37 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -1,6 +1,8 @@ #nullable enable Microsoft.Maui.CommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.IElement? virtualView, string! property, object? args) -> void Microsoft.Maui.FocusRequest.FocusRequest() -> void +Microsoft.Maui.Handlers.IImageHandler.OnWindowChanged() -> void +Microsoft.Maui.Handlers.ImageHandler.OnWindowChanged() -> void Microsoft.Maui.Handlers.SwipeItemButton Microsoft.Maui.Handlers.SwipeItemButton.FrameChanged -> System.EventHandler? Microsoft.Maui.Handlers.SwipeItemButton.SwipeItemButton() -> void @@ -18,7 +20,7 @@ Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.KeyboardAutoManagerScroll -Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void +Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.IImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool Microsoft.Maui.Platform.MauiScrollView Microsoft.Maui.Platform.MauiScrollView.MauiScrollView() -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 00296a0bada2..ea79ce16652b 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -1,6 +1,8 @@ #nullable enable Microsoft.Maui.CommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.IElement? virtualView, string! property, object? args) -> void Microsoft.Maui.FocusRequest.FocusRequest() -> void +Microsoft.Maui.Handlers.IImageHandler.OnWindowChanged() -> void +Microsoft.Maui.Handlers.ImageHandler.OnWindowChanged() -> void Microsoft.Maui.Handlers.SwipeItemButton Microsoft.Maui.Handlers.SwipeItemButton.FrameChanged -> System.EventHandler? Microsoft.Maui.Handlers.SwipeItemButton.SwipeItemButton() -> void @@ -16,7 +18,7 @@ Microsoft.Maui.IImageSourcePartSetter Microsoft.Maui.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void -Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.ImageHandler! handler) -> void +Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.IImageHandler! handler) -> void Microsoft.Maui.Platform.MauiView.CacheMeasureConstraints(double widthConstraint, double heightConstraint) -> void Microsoft.Maui.Platform.MauiView.InvalidateConstraintsCache() -> void Microsoft.Maui.Platform.MauiView.IsMeasureValid(double widthConstraint, double heightConstraint) -> bool From 22f4def3768d562c3ebb01583febb15d12acdd26 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 17 May 2023 11:03:23 -0500 Subject: [PATCH 7/8] Fix IImageSourcePartSetter namespace --- src/Core/src/Handlers/Image/IImageSourcePartSetter.cs | 2 +- src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | 6 +++--- src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | 6 +++--- .../src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | 6 +++--- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs b/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs index f71664bd2f75..ad48288da606 100644 --- a/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs +++ b/src/Core/src/Handlers/Image/IImageSourcePartSetter.cs @@ -10,7 +10,7 @@ using PlatformImage = System.Object; #endif -namespace Microsoft.Maui +namespace Microsoft.Maui.Handlers { public interface IImageSourcePartSetter : IElementHandler { diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 3e857b98f9a6..548fd0fc54d6 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -12,10 +12,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.ShapeExtensions Microsoft.Maui.PlatformContentViewGroup Microsoft.Maui.PlatformContentViewGroup.PlatformContentViewGroup(Android.Content.Context? context) -> void diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index bceadcd9dd37..ff3ef725e6b8 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -14,11 +14,11 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.KeyboardAutoManagerScroll Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.IImageHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index ea79ce16652b..aed971633aba 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -14,10 +14,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.IImageHandler! handler) -> void Microsoft.Maui.Platform.MauiView.CacheMeasureConstraints(double widthConstraint, double heightConstraint) -> void Microsoft.Maui.Platform.MauiView.InvalidateConstraintsCache() -> void diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 17ac6c2374fb..b796cbafaa1c 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -11,9 +11,9 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index bb129d181951..767808ce8c80 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -3,8 +3,8 @@ Microsoft.Maui.CommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler, Microsoft.Maui.FocusRequest.FocusRequest() -> void Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel.AppTheme Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void Microsoft.Maui.IWindow.TitleBarDragRectangles.get -> Microsoft.Maui.Graphics.Rect[]? Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.GetCommand(string! key) -> System.Action? @@ -13,7 +13,7 @@ Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.MauiWebView.MauiWebView(Microsoft.Maui.Handlers.WebViewHandler! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Handlers.ContentViewHandler.DisconnectHandler(Microsoft.Maui.Platform.ContentPanel! platformView) -> void diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index bc68f16e161f..f44a342bccd7 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index a4061224dd98..b7cff3959b8b 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index bc68f16e161f..f44a342bccd7 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -9,10 +9,10 @@ Microsoft.Maui.ICommandMapper.Invoke(Microsoft.Maui.IElementHandler! viewHandler Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void -Microsoft.Maui.IImageSourcePartSetter -Microsoft.Maui.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.Handlers.IImageSourcePartSetter +Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool -Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int From 1480730d2dae0e1082850633fb8220fd6457bc5c Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 17 May 2023 11:03:34 -0500 Subject: [PATCH 8/8] MauiImageView._handler can be readonly --- src/Core/src/Platform/iOS/MauiImageView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/iOS/MauiImageView.cs b/src/Core/src/Platform/iOS/MauiImageView.cs index 561dd0de2928..fc505860bc5d 100644 --- a/src/Core/src/Platform/iOS/MauiImageView.cs +++ b/src/Core/src/Platform/iOS/MauiImageView.cs @@ -7,7 +7,7 @@ namespace Microsoft.Maui.Platform { public class MauiImageView : UIImageView { - WeakReference? _handler; + readonly WeakReference? _handler; public MauiImageView(IImageHandler handler) => _handler = new(handler);