I managed to get around this using the falseflag. Something like this #pragma warning disable 0219, 0649 static bool falseflag = false; static SplashActivity() { if ( falseflag ) { var preserveSpinner = new Android.Widget.Spinner( Android.App.Application.Context ); var preserveSpinnerProperty = preserveSpinner.SelectedItemPosition; // this is the property I'm trying to get by reflection } } #pragma warning restore 0219, 0649
The thing is... this is kind of unusable. The whole reason I'm using reflection is because I don't know which properties I might need. If it were enough to reference the types, then not so bad, but having to reference the properties that are needed it's just not a solution. The other way is to skip Mono.Android assembly, but then I get +10mb in the apk, might as well turn off linking as the difference isn't much. Somehow it feels like none is a good solution. Isn't there any other way of doing this? Cheers, -- Gonçalo Oliveira On 14 August 2012 10:26, Goncalo Oliveira <gonc...@minkan.net> wrote: > I'm kind of lost here. I've found exactly what's failing and where. I have > some code that's basically trying to do this: > > Type targetType = Target.GetType(); // type is Android.Widget.Spinner > PropertyInfo getterProperty = targetType.GetProperty( getterPath ); > > In release getterProperty is returning null. Seems like the linker is > excluding the property, or at least, that is my understanding. > As you stated, I have no code, so "Preserve" is not available. Also this > is dynamic and target type could be an EditText or something else. How > exactly can I implement the falseflag method here? > > Cheers > > > > On 26 July 2012 03:55, Jonathan Pryor <j...@xamarin.com> wrote: > >> On Jul 24, 2012, at 5:45 AM, Goncalo Oliveira <gonc...@minkan.net> wrote: >> > Let me see if I get this straight. I do have an additional project that >> is referenced by the application. It's basically the data model classes. I >> need to add the "[Android.Runtime.Preserve(AllMembers=true)]" attribute to >> the classes in this assembly in order to avoid the linker to "eat up" its >> references? Either that or the weird falseflag method? >> >> Generally you should start with "Link SDK Assemblies". Using the "Link >> All Assemblies" option is for the insane. >> >> If Link SDK Assemblies fails, it's generally because the linker isn't >> smart enough to preserve SDK members that you're using. Using [Preserve] >> won't help (no source!), so you'd want to use falsflag or linkskip. >> >> - Jon >> >> _______________________________________________ >> Monodroid mailing list >> Monodroid@lists.ximian.com >> >> UNSUBSCRIBE INFORMATION: >> http://lists.ximian.com/mailman/listinfo/monodroid >> > > > > -- > Gonçalo Oliveira >
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid