Xamarin-android: Hide Java.Lang.Object members meant only for internal use

Created on 17 Apr 2020  路  6Comments  路  Source: xamarin/xamarin-android

Hi, this is not a very important issue, but something I guess would make a dev's life a bit easier :)

I work with Xamarin.Android so I use mostly objects that are bound from Java libs so they inherit from the Java.Lang.Object class. The _problem_ here is that it has a few public members that are intended for internal Java.Interop use only. For instance public IntPtr Handle or public JniObjectReference PeerReference.

So I'm wondering whether it'd be possible to hide these members as they're making an unwanted noise in IntelliSense and could also possibly lead to some confusion or errors when mistakenly used. The best would of course be to make them internal or something like that or, if that's not possible, the EditorBrowsable(EditorBrowsableState.Never) attribute could be added to remove that noise.

Bindings

All 6 comments

Also it could be worth adding the [DebuggerBrowsable(DebuggerBrowsableState.Never)] attribute if the members cannot be made internal or so to hide the members when debugging.

Unfortunately they cannot be made internal, as they are used by bindings libraries.

I really like your idea to at least hide them from the editor/debugger. I'll look into doing that!

I'm going to move this to the Xamarin.Android repo, as the code for Java.Lang.Object is actually over there.

Release status update

A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this again when a Release version is available that includes the fix.

Fix included in Xamarin.Android 10.3.99.230.

Fix included on Windows in Visual Studio 2019 version 16.7 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

_Release status update_

A new Release version of Xamarin.Android has now been published that includes the fix for this item.

Fix included in Xamarin.Android SDK version 11.0.0.3.

Fix included on Windows in Visual Studio 2019 version 16.7. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

Hi, I just downloaded the latest VS 16.7 and wanted to look at this fix but I found there's a problem with classes that inherit from Java.Lang.Object that override these now hidden properties. For instance Android.App.Activity overrides ThresholdClass so it is then visible in IntelliSense and this fix has no effect :/
I guess the bindings generator will need to be updated too to add these attributes on the overrides.

Good point, I added https://github.com/xamarin/java.interop/issues/688 to address this.

Was this page helpful?
0 / 5 - 0 ratings