Skip to content

Restore Change/StartTrackingTouch/StopTrackingTouch events on Slider and RangeSlider#1493

Merged
jonathanpeppers merged 1 commit into
mainfrom
fix/slider-1484-restore-change-events
Jul 2, 2026
Merged

Restore Change/StartTrackingTouch/StopTrackingTouch events on Slider and RangeSlider#1493
jonathanpeppers merged 1 commit into
mainfrom
fix/slider-1484-restore-change-events

Conversation

@sheiksyedm

Copy link
Copy Markdown
Contributor

Problem

PR #1486 fixed the ACW implementor build failure (#1484) by removing the auto-generated addOnChangeListener/addOnSliderTouchListener methods from BaseSlider via remove-node in Metadata.xml and re-adding them as hand-written Additions.

However, the binding generator only produces C# events (Change, StartTrackingTouch, StopTrackingTouch) for methods it sees in the generated API XML. Since those methods were removed from the generated API, the events were no longer emitted — causing a regression in 1.14.0.4:

error CS1061: 'Slider' does not contain a definition for 'Change'

Reported by a user in: #1484 (comment)

Fix

Add the three C# events manually to SliderListenerMethods.cs for both Slider and RangeSlider:

  • Change — wraps AddOnChangeListener/RemoveOnChangeListener
  • StartTrackingTouch — wraps AddOnSliderTouchListener/RemoveOnSliderTouchListener
  • StopTrackingTouch — wraps AddOnSliderTouchListener/RemoveOnSliderTouchListener

Each event uses Java.Interop.EventHelper.AddEventHandler/RemoveEventHandler with the already-generated implementor types (IOnChangeListenerImplementor, IOnSliderTouchListenerImplementor). This is exactly what the generator would have produced had the methods remained in the generated API.

EventArgs type change (improvement)

The old ChangeEventArgs.P0 was Java.Lang.Object (because BaseOnChangeListener<S> used a generic that erased to Object). The new ChangeEventArgs.P0 is the concrete Slider or RangeSlider type — a typed improvement. P1 (float) and P2 (bool) are unchanged.

NuGet version

Xamarin.Google.Android.Material: 1.14.0.41.14.0.5

Fixes #1484

…and RangeSlider

PR #1486 removed the auto-generated addOnChangeListener/addOnSliderTouchListener
methods from BaseSlider via remove-node and re-added them as hand-written Additions.
However, the binding generator only produces C# events for methods it sees in the
API XML — since the methods were removed from the generated API, the Change,
StartTrackingTouch, and StopTrackingTouch events were no longer emitted.

This caused a regression in 1.14.0.4 where Slider.Change (and touch events) were
missing, breaking existing .NET consumers who used the C# event syntax.

Fix: add the three events manually to SliderListenerMethods.cs for both Slider and
RangeSlider, using EventHelper.AddEventHandler/RemoveEventHandler with the already-
generated implementor types (IOnChangeListenerImplementor, IOnSliderTouchListenerImplementor).
This is exactly what the generator would have produced had the methods remained in
the generated API.

The ChangeEventArgs.P0 type changes from Java.Lang.Object (old erased-generic base)
to the concrete Slider/RangeSlider — a source-level improvement alongside the fix.

Bump nugetVersion 1.14.0.4 -> 1.14.0.5.

Fixes #1484
Copilot AI review requested due to automatic review settings July 2, 2026 14:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores the missing C# event surface (Change, StartTrackingTouch, StopTrackingTouch) for Material Slider and RangeSlider after the listener add/remove methods were moved to Additions/ (to avoid the ACW/implementor failures from the erased-generic base interfaces).

Changes:

  • Manually re-introduces the Change, StartTrackingTouch, and StopTrackingTouch events for Slider and RangeSlider using Java.Interop.EventHelper and the generated *Implementor types.
  • Updates PublicAPI.Unshipped.txt to reflect the restored public events.
  • Bumps Xamarin.Google.Android.Material nugetVersion from 1.14.0.4 to 1.14.0.5.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
source/com.google.android.material/material/Additions/SliderListenerMethods.cs Adds manual event wrappers that mirror the generator’s typical event pattern for slider listeners.
source/com.google.android.material/material/PublicAPI/PublicAPI.Unshipped.txt Captures the restored event members in the public API tracking file.
config.json Increments the NuGet revision for Xamarin.Google.Android.Material to ship the fix.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@jonathanpeppers jonathanpeppers merged commit 5b4a6ab into main Jul 2, 2026
4 checks passed
@jonathanpeppers jonathanpeppers deleted the fix/slider-1484-restore-change-events branch July 2, 2026 20:47
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.

Xamarin.Google.Android.Material 1.14.0.3 generates invalid Java implementors for Material slider listener interfaces

3 participants