Bug 22962 - In Xamarin.Android, Java's @deprecated annotations aren't mapped to C#'s [Obsolete] attribute
Summary: In Xamarin.Android, Java's @deprecated annotations aren't mapped to C#'s [Obs...
Alias: None
Product: Android
Classification: Xamarin
Component: Bindings ()
Version: 4.18.0
Hardware: PC Windows
: Highest normal
Target Milestone: 5.1
Assignee: dean.ellis
Depends on:
Reported: 2014-09-13 00:48 UTC by Horácio J. C. Filho
Modified: 2015-03-12 17:52 UTC (History)
7 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Horácio J. C. Filho 2014-09-13 00:48:41 UTC
Hi guys, 

I've noticed that Java's @deprecated annotations aren't mapped to C#'s [Obsolete] attributes in Xamarin members (classes, interfaces, methods, properties, events). For example:

In Android, 
android.view.View class's public void setBackgroundDrawable(android.graphics.drawable.Drawable) method is flagged with @deprecated annotation, but in corresponding C# class, there is no System.Obsolete attribute for matching. This occurs in other classes also.

In Java,
public java.lang.String(byte[], int) constructor is deprecated, but it isn't flagged with Obsolete attribute in Xamarin.Android's bind for this class.

We may inadvertently be using obsolete APIs.

Thanks a lot for helping me.
Comment 1 Jonathan Pryor 2014-09-16 12:50:33 UTC
The problem is that our generator doesn't consistently look at the @deprecated information, and thus doesn't generate [Obsolete] when it should.

Dean: See Method.cs!Generate(), and note that it doesn't check the Deprecated property (unlike e.g. GenerateDeclaration()).
Comment 2 dean.ellis 2014-09-17 10:44:34 UTC
Fixed in monodroid/master/9913daff
Comment 3 Ram Chandra 2014-11-26 08:38:16 UTC
I have checked this issue with following builds:

Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.53344
Installed Version: Professional
Xamarin (f06bad7)
Xamarin.Android (d507ba60cc907073c9b40ebc88bab6311b748c20)
Xamarin.iOS (8dc6ec80fb6f7c1ec874ad67ffca859cdad94282)

I have checked the  definition of "setBackgroundDrawable" and few other method which is deprecated in android and observed that they are mapped with C# "Obsolete" attribute.

Screencast: http://www.screencast.com/t/5xy0TuOLA

This issue has been fixed. Hence, I am closing this issue.
Comment 4 Horácio J. C. Filho 2014-11-28 08:30:31 UTC
I'm very happy about this news, thanks a lot for help me. Where I can download Xamarin for Visual Studio Or it is an internal alpha release of Xamarin.Android 5.0?

Thanks a lot :D
Comment 5 Dimitar Dobrev 2014-12-12 17:00:23 UTC
Has a version containing this fix been released? I've got the same problem and I don't know if I have an old version of if I have hit another case of the same bug.
Comment 6 Horácio J. C. Filho 2014-12-12 18:11:51 UTC
@Dimitar This bug was fixed in Xamarin.Android 5.0 but is not public yet. Please look at here http://developer.xamarin.com/releases/android/xamarin.android_5/xamarin.android_5.0/

Comment 7 Dimitar Dobrev 2014-12-12 18:22:05 UTC
Thanks, it's not fatal, I only needed to know whether to file a new bug.