Skip to content

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Aug 20, 2021

Fixes: https://developercommunity2.visualstudio.com/t/xamarin-android-bluetooth-the-advertisin/841102
Fixes: #2595

Updates enumification to point to the correct enum. Backwards compatibility is achieved by creating overloads for the existing methods in Additions, and marking them as [Obsolete].

The API "breakage" is because the [Register] attribute has moved from the incorrect methods to the correct methods. As the signature change is an enum, the marshalled type is still an int so moving the [Register] should not cause issues.

ie:

// Current
[Register]
public void DoSomething (BadEnum value) { ... }

// Fixed
[Register]
public void DoSomething (GoodEnum value) { ... }

public void DoSomething (BadEnum value) => DoSomething ((GoodEnum)value);

@jpobst jpobst marked this pull request as ready for review August 24, 2021 18:42
@jpobst jpobst requested a review from jonpryor as a code owner August 24, 2021 18:42
@jonpryor jonpryor merged commit 5f408eb into main Aug 25, 2021
@jonpryor jonpryor deleted the bluetooth-phy branch August 25, 2021 00:42
jonathanpeppers pushed a commit that referenced this pull request Aug 25, 2021
Fixes: https://developercommunity2.visualstudio.com/t/xamarin-android-bluetooth-the-advertisin/841102
Fixes: #2595

Update enumification of various
`Android.Bluetooth.LE.AdvertisingSetParameters.Builder` and
`Android.Bluetooth.BluetoothDevice` methods to use the
`Android.Bluetooth.BluetoothPhy` enum instead of the
`Android.Bluetooth.LE.ScanSettingsPhy` enum, introduced in e33eb53.

Backwards compatibility is achieved by creating overloads for the
existing methods in `Additions`, and marking them as `[Obsolete]`.

The API "breakage" is because the `[Register]` attribute has moved
from the incorrect methods to the correct methods.  As the signature
change is an enum, the marshalled type is still an `int`, so moving
the `[Register]` should not cause issues.

For example:

	// Current
	[Register]
	public void DoSomething (BadEnum value) { ... }

	// Fixed
	[Register]
	public void DoSomething (GoodEnum value) { ... }

	[Obsolete ("Use DoSomething(GoodEnum)")]
	public void DoSomething (BadEnum value) => DoSomething ((GoodEnum)value);

Note: this is only generally save to do when `DoSomething()` is a
*non-`virtual`* method (i.e. Java `final` method).  Fortunately, this
is the case with the methods involved here.
jonpryor pushed a commit to jonpryor/xamarin-android that referenced this pull request Aug 25, 2021
Fixes: https://developercommunity2.visualstudio.com/t/xamarin-android-bluetooth-the-advertisin/841102
Fixes: dotnet#2595

Update enumification of various
`Android.Bluetooth.LE.AdvertisingSetParameters.Builder` and
`Android.Bluetooth.BluetoothDevice` methods to use the
`Android.Bluetooth.BluetoothPhy` enum instead of the
`Android.Bluetooth.LE.ScanSettingsPhy` enum, introduced in e33eb53.

Backwards compatibility is achieved by creating overloads for the
existing methods in `Additions`, and marking them as `[Obsolete]`.

The API "breakage" is because the `[Register]` attribute has moved
from the incorrect methods to the correct methods.  As the signature
change is an enum, the marshalled type is still an `int`, so moving
the `[Register]` should not cause issues.

For example:

	// Current
	[Register]
	public void DoSomething (BadEnum value) { ... }

	// Fixed
	[Register]
	public void DoSomething (GoodEnum value) { ... }

	[Obsolete ("Use DoSomething(GoodEnum)")]
	public void DoSomething (BadEnum value) => DoSomething ((GoodEnum)value);

Note: this is only generally save to do when `DoSomething()` is a
*non-`virtual`* method (i.e. Java `final` method).  Fortunately, this
is the case with the methods involved here.
jonpryor pushed a commit that referenced this pull request Aug 26, 2021
Fixes: https://developercommunity2.visualstudio.com/t/xamarin-android-bluetooth-the-advertisin/841102
Fixes: #2595

Update enumification of various
`Android.Bluetooth.LE.AdvertisingSetParameters.Builder` and
`Android.Bluetooth.BluetoothDevice` methods to use the
`Android.Bluetooth.BluetoothPhy` enum instead of the
`Android.Bluetooth.LE.ScanSettingsPhy` enum, introduced in e33eb53.

Backwards compatibility is achieved by creating overloads for the
existing methods in `Additions`, and marking them as `[Obsolete]`.

The API "breakage" is because the `[Register]` attribute has moved
from the incorrect methods to the correct methods.  As the signature
change is an enum, the marshalled type is still an `int`, so moving
the `[Register]` should not cause issues.

For example:

	// Current
	[Register]
	public void DoSomething (BadEnum value) { ... }

	// Fixed
	[Register]
	public void DoSomething (GoodEnum value) { ... }

	[Obsolete ("Use DoSomething(GoodEnum)")]
	public void DoSomething (BadEnum value) => DoSomething ((GoodEnum)value);

Note: this is only generally save to do when `DoSomething()` is a
*non-`virtual`* method (i.e. Java `final` method).  Fortunately, this
is the case with the methods involved here.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Android.Bluetooth.BluetoothDevice.ConnectGatt has invalid signature
2 participants