Bug 29571 - Custom [Preserve] attribute only works under the Android.Runtime namespace on Android
Summary: Custom [Preserve] attribute only works under the Android.Runtime namespace on...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 5.1
Hardware: PC Mac OS
: Normal minor
Target Milestone: 5.1.5 (C5SR3)
Assignee: Radek Doulik
Depends on:
Reported: 2015-04-30 01:25 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-08-10 14:43 UTC (History)
7 users (show)

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

Test case (40.65 KB, application/zip)
2015-04-30 01:25 UTC, Brendan Zagaeski (Xamarin Team, assistant)

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 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-30 01:25:18 UTC
Created attachment 10970 [details]
Test case

Custom [Preserve] attribute only works under the Android.Runtime namespace on Android

This is the same issue as bug 28389, but now reported against Android rather than iOS (and with a simplified test case).

## Steps to reproduce

Build and run the "AndroidApp1" project from attached test case in the "Debug|Any CPU" configuration (on an x86 or armeabi-v7a device or emulator).

The linker set to "Link all" for all of the build configurations in the test case.

## Results

The app hits an exception because the method "MyClass.Foo()" has been linked away.

## Expected results

Thanks to the fix for bug 29389, the corresponding iOS test case "UnifiedSingleViewIphone1" launches and runs with _no_ exceptions.

## Partial workaround

Change the namespace of `PortableLibrary1.PreserveAttribute` to `Android.Runtime`, so the fully qualified type name will be: `Android.Runtime.PreserveAttribute`.

## Version info

### Devices

Xamarin Android Player 0.3.7 (1), Nexus 4 (KitKat)

### OS X 10.9.5, MacBook Air

Mono 4.0.0 (detached/d136b79)

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/macuser/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /Users/macuser
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
Comment 1 Darrell 2015-05-21 06:56:16 UTC
The partial workaround doesn't appear to work for us within our solution. However the partial workaround does work when i download and run the attached sample. So I am highly confused. There must be some difference between the sample, and our solution, that means the partial workaround works in one scenario and not the other, but I cannot figure out what that difference is :(
Comment 2 Radek Doulik 2015-06-02 15:30:19 UTC
This is now fixed in master by aefb60900ca11e2045e0fde049e254af146c160a
Comment 3 Mohit Kheterpal 2015-07-15 06:28:08 UTC
I am able to reproduce the exception with Stable build of C5SR2 XA and observed that this issue is fixed in C5SR3 XA i.e. mono-android-5.1.4-30.

Hence closing this issue.