You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Address review: reset container on disconnect, make validation hook protected
Two defects found in review of the SetContainerView extensibility point.
1. Disconnecting a handler that still had an active container left both
ContainerView and HasContainer set. ElementHandler.DisconnectHandler()
nulls PlatformView and never touched container state, so a later
reconnect hit the HasContainer equality short-circuit in the setter,
skipped SetupContainer(), and kept serving the stale wrapper that
still held the previous platform view.
The teardown has to run while PlatformView is still reachable: the
generic PlatformView getter throws when null, so calling
RemoveContainer() after the null would throw on Android and Tizen.
Add a private protected virtual ElementHandler.OnDisconnecting() hook
that runs before PlatformView is cleared, and override it in
ViewHandler to flip HasContainer off (which unwinds the container
through the platform's own RemoveContainer()) and clear ContainerView.
RemoveContainer() is therefore invoked under exactly the precondition
it already runs under during normal operation, so every existing
platform override stays on its supported path.
2. ValidateContainerView was private protected, so an external subclass
that shadows ContainerView with its own wrapper type could not enforce
that type and the broad setter could corrupt its strongly typed
getter. Promote it to protected virtual with XML docs, and update the
iOS/MacCatalyst and Tizen overrides accordingly.
The external backend test handler now overrides ValidateContainerView to
require its own wrapper type. Note the override is declared with `object`
because on the neutral TFM the PlatformView alias is System.Object.
New regression tests (5), all verified to fail without the fixes:
DisconnectingWithAnActiveContainerTearsTheContainerDown,
ReconnectingAfterDisconnectWithAnActiveContainerRebuildsTheContainer,
SetContainerViewRejectsAContainerOfTheWrongType,
SetContainerViewRejectionLeavesAnExistingContainerIntact,
SetContainerViewStillAcceptsNullAfterValidationIsOverridden.
Also applies two reviewer nits: scope the SetupContainer/RemoveContainer
remarks to overrides outside this assembly (in-box handlers still use the
private protected setter), and restore `using System;` first in
ViewHandlerOfT.iOS.cs to match the other platform partials.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0 commit comments