CarouselViewHandler2 InvalidCastException for MauiMediaElement.macios.cs when using CollectionViewHandler2 and CarouselViewHandler2
#2926
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR fixes a typo I made when adding support for
ItemsViewController2<T>inMauiMediaElement.macios.cs.When a developer is using an
ItemsViewController2<T>, we were incorrectly casting it toItemsViewController<T>instead of aItemsViewController2<T>, causing theInvalidCastException.Linked Issues
MediaElementinCollectionViewHandler2andCarouselViewHandler2#2925PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information
The bug was due to a copy/paste error when I created the following two methods side-by-side:
static ItemsViewController<TItemsView> GetInternalControllerForItemsView<TItemsView>(ItemsViewHandler<TItemsView>) where TItemsView : ItemsViewstatic ItemsViewController2<TItemsView> GetInternalControllerForItemsView2<TItemsView>(ItemsViewHandler2<TItemsView>) where TItemsView : ItemsViewThis bug was not caught earlier because the Controller we need from .NET MAUI is a
protected internalproperty, forcing us to use reflection to retrieve it. If the property was public we could rely on C# type-safety.