Skip to content

WI01087620: Add reflection-free protected static API for ZBindingContext net10 compatibility#25

Open
DerekDong666 wants to merge 1 commit into
masterfrom
DD2/WI01087620
Open

WI01087620: Add reflection-free protected static API for ZBindingContext net10 compatibility#25
DerekDong666 wants to merge 1 commit into
masterfrom
DD2/WI01087620

Conversation

@DerekDong666

Copy link
Copy Markdown

Summary

Adds reflection-free \protected static\ helpers on \BindingContext\ so that \ZBindingContext\ (CargoWise) can rewire related \CurrencyManager\ parent subscriptions on .NET 10 without reflecting over internals that changed since .NET Framework.

Context

\ZBindingContext\ is a \BindingContext\ subclass in an external assembly (no \InternalsVisibleTo). It needs to:

  1. Find the parent \CurrencyManager\ driving a \RelatedCurrencyManager\ child
  2. Detach the default \CurrentItemChanged\ subscription the child wired onto its parent
  3. Refresh the child from the parent's current row (when parent is non-empty)
  4. Reset the child to a safe empty placeholder list (when parent is empty), bypassing the \AddNew/\CancelCurrentEdit\ appcompat path that creates real business objects against CargoWise collections
  5. Raise \CurrentItemChanged\ with PushData suppressed, when position becomes -1

Previously these were done via reflection. On .NET 10, _parentManager\ (renamed from \parentManager) and removal of \suspendPushDataInCurrentChanged\ in favour of _state\ flags broke the reflection approach.

Changes

*\RelatedCurrencyManager* — 4 new \internal\ members:

  • \ParentCurrencyManager\ property
  • \DetachParentItemChangedHandler()\
  • \RefreshFromParentCurrent()\
  • \ResetToEmptyList(IList)\ — sets data source, resets position, fires events; no AddNew/Cancel

*\CurrencyManager* — 1 new \internal\ method:

  • \RaiseCurrentItemChangedSuppressingPushData(EventArgs)\ — toggles _state\ flag directly; replaces reflection of the removed \suspendPushDataInCurrentChanged\ field

*\BindingContext* — replaces \RewireRelatedCurrencyManagerParent\ with 5 \protected static\ facade helpers:

  • \GetParentCurrencyManager(BindingManagerBase)\
  • \DetachRelatedManagerFromParentItemChanged(BindingManagerBase)\
  • \RefreshRelatedManagerFromParent(BindingManagerBase)\
  • \ResetRelatedManagerToEmptyList(BindingManagerBase, IList)\
  • \RaiseCurrentItemChangedSuppressingPushData(CurrencyManager, EventArgs)\

*\PublicAPI.Unshipped.txt* — removes old \RewireRelatedCurrencyManagerParent\ entry, registers the 5 new helpers.

Companion change: CargoWise PR #54869

…ext net10 compatibility

ZBindingContext (CargoWise) rewires how related CurrencyManagers subscribe to their parent's
change events, driving children from CurrentChanged with CargoWise-specific policy instead of
the default CurrentItemChanged handler. On .NET Framework it did this by reflecting over
RelatedCurrencyManager internals. On .NET 10 those internals changed (field renamed, flags
refactored) so reflection no longer works.

Add a set of reflection-free protected static helpers on BindingContext so that the subclass
in the external assembly can reach the necessary internal state:

BindingContext:
- GetParentCurrencyManager: returns the CurrencyManager driving a RelatedCurrencyManager child
- DetachRelatedManagerFromParentItemChanged: detaches the default CurrentItemChanged subscription
- RefreshRelatedManagerFromParent: triggers the child to refresh from the parent's current row
- ResetRelatedManagerToEmptyList(IList): resets child to a safe empty placeholder list and
  raises position/current events, bypassing the AddNew/CancelCurrentEdit appcompat path that
  executes AddNew on a real business-object collection when the parent is empty
- RaiseCurrentItemChangedSuppressingPushData: raises CurrentItemChanged with PushData suppressed;
  replaces reflection of the removed suspendPushDataInCurrentChanged field

RelatedCurrencyManager (internal helpers backing the above):
- ParentCurrencyManager property
- DetachParentItemChangedHandler()
- RefreshFromParentCurrent()
- ResetToEmptyList(IList)

CurrencyManager:
- RaiseCurrentItemChangedSuppressingPushData(EventArgs): toggles _state flag directly

Remove the now-superseded RewireParentChangeHandler / RewireRelatedCurrencyManagerParent pair.
Update PublicAPI.Unshipped.txt accordingly.

Companion change in WiseTechGlobal/CargoWise consumes these helpers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant