-
Notifications
You must be signed in to change notification settings - Fork 564
[Mono.Android] Bind Build.getVersion() as Build.GetVersion() #930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60069 Context: https://bugzilla.xamarin.com/attachment.cgi?id=25276 API-26 added an [`android.os.Build.getSerial()`][0] method. Under normal "name mangling" conventions, `generator` binds this as an `Android.OS.Build.Serial` property. [0]: https://developer.android.com/reference/android/os/Build.html#getSerial() There's just one "minor" problem with this: there is *also* an [`android.os.Build.SERIAL`][1] field, since API-9, which `generator` *also* binds as an `Android.OS.Build.Serial` property. [1]: https://developer.android.com/reference/android/os/Build.html#SERIAL Thus, a question: given the Java code: ```java public class Build { public static String SERIAL = "UNKNOWN"; public static String getSerial() {/* ... */ } } ``` What will `generator` do? Answer: the wrong thing: the field is *ignored*, and the `Build.getSerial()` method is used for the `Build.Serial` property. This is problematic. *The managed API has not changed* -- pre-API-26 and post-API-26 both have a string `Build.Serial` property -- but the *behavior* of the method has changed from reading the value of a static field, to invoking a static method. A static method that only exists on devices running API-26 and later. Meaning: 1. Create a new Xamarin.Android app. 2. Set `$(TargetFrameworkVersion)` to v8.0, and `//uses-sdk/@android:minSdkVersion` to 11 within `AndroidManifest.xml`. 3. Within e.g. `MainActivity.OnCreate()`, reference the `Android.OS.Build.Serial` property. 4. Build the app, and run on e.g. an Android 7.1 device. Expected result: it works! Actual result: not so much: Java.Lang.NoSuchMethodError: no static method "Landroid/os/Build;.getSerial()Ljava/lang/String;" @atsushieno has determined that this is the only such behavioral breakage introduced by API-26. His [referenced metadata fixup changes][2] patch lists all the fields which are currently being ignored by the `Mono.Android` build process. [2]: https://bugzilla.xamarin.com/attachment.cgi?id=25276 In the interest of expediency (and getting this merged into d15-4), include *only* the metadata changes that impact `Build.getSerial()`, and force it to be bound as a `Build.GetSerial()` method. This "un-hides" the `Build.Serial` binding of the `Build.SERIAL` field, restoring semantic compatibility. The remaining of the metadata fixup changes should be merged separately.
8b63621 to
006edd6
Compare
jonpryor
added a commit
that referenced
this pull request
Oct 12, 2017
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60069 Context: https://bugzilla.xamarin.com/attachment.cgi?id=25276 API-26 added an [`android.os.Build.getSerial()`][0] method. Under normal "name mangling" conventions, `generator` binds this as an `Android.OS.Build.Serial` property. [0]: https://developer.android.com/reference/android/os/Build.html#getSerial() There's just one "minor" problem with this: there is *also* an [`android.os.Build.SERIAL`][1] field, since API-9, which `generator` *also* binds as an `Android.OS.Build.Serial` property. [1]: https://developer.android.com/reference/android/os/Build.html#SERIAL Thus, a question: given the Java code: ```java public class Build { public static String SERIAL = "UNKNOWN"; public static String getSerial() {/* ... */ } } ``` What will `generator` do? Answer: the wrong thing: the field is *ignored*, and the `Build.getSerial()` method is used for the `Build.Serial` property. This is problematic. *The managed API has not changed* -- pre-API-26 and post-API-26 both have a string `Build.Serial` property -- but the *behavior* of the method has changed from reading the value of a static field, to invoking a static method. A static method that only exists on devices running API-26 and later. Meaning: 1. Create a new Xamarin.Android app. 2. Set `$(TargetFrameworkVersion)` to v8.0, and `//uses-sdk/@android:minSdkVersion` to 11 within `AndroidManifest.xml`. 3. Within e.g. `MainActivity.OnCreate()`, reference the `Android.OS.Build.Serial` property. 4. Build the app, and run on e.g. an Android 7.1 device. Expected result: it works! Actual result: not so much: Java.Lang.NoSuchMethodError: no static method "Landroid/os/Build;.getSerial()Ljava/lang/String;" @atsushieno has determined that this is the only such behavioral breakage introduced by API-26. His [referenced metadata fixup changes][2] patch lists all the fields which are currently being ignored by the `Mono.Android` build process. [2]: https://bugzilla.xamarin.com/attachment.cgi?id=25276 In the interest of expediency (and getting this merged into d15-4), include *only* the metadata changes that impact `Build.getSerial()`, and force it to be bound as a `Build.GetSerial()` method. This "un-hides" the `Build.Serial` binding of the `Build.SERIAL` field, restoring semantic compatibility. The remaining of the metadata fixup changes should be merged separately.
jonpryor
added a commit
that referenced
this pull request
Oct 12, 2017
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60069 Context: https://bugzilla.xamarin.com/attachment.cgi?id=25276 API-26 added an [`android.os.Build.getSerial()`][0] method. Under normal "name mangling" conventions, `generator` binds this as an `Android.OS.Build.Serial` property. [0]: https://developer.android.com/reference/android/os/Build.html#getSerial() There's just one "minor" problem with this: there is *also* an [`android.os.Build.SERIAL`][1] field, since API-9, which `generator` *also* binds as an `Android.OS.Build.Serial` property. [1]: https://developer.android.com/reference/android/os/Build.html#SERIAL Thus, a question: given the Java code: ```java public class Build { public static String SERIAL = "UNKNOWN"; public static String getSerial() {/* ... */ } } ``` What will `generator` do? Answer: the wrong thing: the field is *ignored*, and the `Build.getSerial()` method is used for the `Build.Serial` property. This is problematic. *The managed API has not changed* -- pre-API-26 and post-API-26 both have a string `Build.Serial` property -- but the *behavior* of the method has changed from reading the value of a static field, to invoking a static method. A static method that only exists on devices running API-26 and later. Meaning: 1. Create a new Xamarin.Android app. 2. Set `$(TargetFrameworkVersion)` to v8.0, and `//uses-sdk/@android:minSdkVersion` to 11 within `AndroidManifest.xml`. 3. Within e.g. `MainActivity.OnCreate()`, reference the `Android.OS.Build.Serial` property. 4. Build the app, and run on e.g. an Android 7.1 device. Expected result: it works! Actual result: not so much: Java.Lang.NoSuchMethodError: no static method "Landroid/os/Build;.getSerial()Ljava/lang/String;" @atsushieno has determined that this is the only such behavioral breakage introduced by API-26. His [referenced metadata fixup changes][2] patch lists all the fields which are currently being ignored by the `Mono.Android` build process. [2]: https://bugzilla.xamarin.com/attachment.cgi?id=25276 In the interest of expediency (and getting this merged into d15-4), include *only* the metadata changes that impact `Build.getSerial()`, and force it to be bound as a `Build.GetSerial()` method. This "un-hides" the `Build.Serial` binding of the `Build.SERIAL` field, restoring semantic compatibility. The remaining of the metadata fixup changes should be merged separately.
Redth
pushed a commit
to Redth/xamarin-android
that referenced
this pull request
Oct 30, 2017
) Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60069 Context: https://bugzilla.xamarin.com/attachment.cgi?id=25276 API-26 added an [`android.os.Build.getSerial()`][0] method. Under normal "name mangling" conventions, `generator` binds this as an `Android.OS.Build.Serial` property. [0]: https://developer.android.com/reference/android/os/Build.html#getSerial() There's just one "minor" problem with this: there is *also* an [`android.os.Build.SERIAL`][1] field, since API-9, which `generator` *also* binds as an `Android.OS.Build.Serial` property. [1]: https://developer.android.com/reference/android/os/Build.html#SERIAL Thus, a question: given the Java code: ```java public class Build { public static String SERIAL = "UNKNOWN"; public static String getSerial() {/* ... */ } } ``` What will `generator` do? Answer: the wrong thing: the field is *ignored*, and the `Build.getSerial()` method is used for the `Build.Serial` property. This is problematic. *The managed API has not changed* -- pre-API-26 and post-API-26 both have a string `Build.Serial` property -- but the *behavior* of the method has changed from reading the value of a static field, to invoking a static method. A static method that only exists on devices running API-26 and later. Meaning: 1. Create a new Xamarin.Android app. 2. Set `$(TargetFrameworkVersion)` to v8.0, and `//uses-sdk/@android:minSdkVersion` to 11 within `AndroidManifest.xml`. 3. Within e.g. `MainActivity.OnCreate()`, reference the `Android.OS.Build.Serial` property. 4. Build the app, and run on e.g. an Android 7.1 device. Expected result: it works! Actual result: not so much: Java.Lang.NoSuchMethodError: no static method "Landroid/os/Build;.getSerial()Ljava/lang/String;" @atsushieno has determined that this is the only such behavioral breakage introduced by API-26. His [referenced metadata fixup changes][2] patch lists all the fields which are currently being ignored by the `Mono.Android` build process. [2]: https://bugzilla.xamarin.com/attachment.cgi?id=25276 In the interest of expediency (and getting this merged into d15-4), include *only* the metadata changes that impact `Build.getSerial()`, and force it to be bound as a `Build.GetSerial()` method. This "un-hides" the `Build.Serial` binding of the `Build.SERIAL` field, restoring semantic compatibility. The remaining of the metadata fixup changes should be merged separately.
jonpryor
pushed a commit
that referenced
this pull request
Dec 8, 2019
#3884) Fixes: #1118 Context: https://bugzilla.xamarin.com/show_bug.cgi?id=60069 Context: #930 Our current API check workflow is not able to detect some API breakage or is flagging non-breaking API changes as breaking. Examples of breakages not previously reported: * Changing the values of `[Register]` attributes may be a breaking change but is not flagged by `mono-html-html`. * Adding `abstract` methods to an `abstract` class Examples of acceptable changes which elicit warnings: * Changing a base class in a compatible manner. Instead of using `mono-api-info` + `mono-api-html`, use [Microsoft.DotNet.ApiCompat][0] to perform API compatibility validation, which is what the .NET and Azure teams use. Microsoft.DotNet.ApiCompat reports `[Register]` changes: CannotChangeAttribute : Attribute 'Android.Runtime.RegisterAttribute' on 'Android.Database.Sqlite.SQLiteDatabase.Path.get()' changed from '[RegisterAttribute("getPath", "()Ljava/lang/String;", "")]' in the contract to '[RegisterAttribute("getPath", "()Ljava/lang/String;", "GetGetPathHandler")]' in the implementation. and thus would have caught the `Build.SERIAL` breakage in #930. To override the warnings produced by Microsoft.DotNet.ApiCompat, the message can be copied into an appropriate `tests/api-compatibility/acceptable-breakages-*.txt` file. See `tests/api-compatibility/README.md` for details. [0]: https://github.com/dotnet/arcade/tree/master/src/Microsoft.DotNet.ApiCompat
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60069
Context: https://bugzilla.xamarin.com/attachment.cgi?id=25276
API-26 added an
android.os.Build.getSerial()method. Undernormal "name mangling" conventions,
generatorbinds this as anAndroid.OS.Build.Serialproperty.There's just one "minor" problem with this: there is also an
android.os.Build.SERIALfield, since API-9, whichgeneratoralso binds as an
Android.OS.Build.Serialproperty.Thus, a question: given the Java code:
What will
generatordo?Answer: the wrong thing: the field is ignored, and the
Build.getSerial()method is used for theBuild.Serialproperty.This is problematic. The managed API has not changed -- pre-API-26
and post-API-26 both have a string
Build.Serialproperty --but the behavior of the method has changed from reading the value of
a static field, to invoking a static method.
A static method that only exists on devices running API-26 and later.
Meaning:
$(TargetFrameworkVersion)to v8.0, and//uses-sdk/@android:minSdkVersionto 11 withinAndroidManifest.xml.MainActivity.OnCreate(), reference theAndroid.OS.Build.Serialproperty.Expected result: it works!
Actual result: not so much:
@atsushieno has determined that this is the only such behavioral
breakage introduced by API-26. His
referenced metadata fixup changes patch lists all the fields
which are currently being ignored by the
Mono.Androidbuild process.In the interest of expediency (and getting this merged into d15-4),
include only the metadata changes that impact
Build.getSerial(),and force it to be bound as a
Build.GetSerial()method. This"un-hides" the
Build.Serialbinding of theBuild.SERIALfield,restoring semantic compatibility.
The remaining of the metadata fixup changes should be merged
separately.