-
Notifications
You must be signed in to change notification settings - Fork 564
Closed
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.
Description
Android framework version
net9.0-android
Affected platform version
.NET9 RC2
Description
C# Type seems to be trimmed away, causing problems in Release builds.
The problem did not occur in .NET 8
Steps to Reproduce
In my app I am using a Preference screen, with a SwitchPreferenceCompat specified in the XML.
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory>
<SwitchPreferenceCompat app:key="test" app:title="Test"/>
</PreferenceCategory>
</PreferenceScreen>
In my C# code, I want to get a reference to it in order to initialize:
var test = FindPreference("test") as SwitchPreferenceCompat;
test.PreferenceChange += (_, _) => Toast.MakeText(Context, "toggled", ToastLength.Long).Show();
Example project to reproduce: New folder.zip
Did you find any workaround?
I can use a subclass TwoStatePreference or just Preference instead the as SwitchPreferenceCompat case. I assume that the C# type of SwitchPreferenceCompat was trimmed away because no direct properties or methods of it was accessed (only of it's subclasses)
Relevant log output
No response
Metadata
Metadata
Assignees
Labels
Area: App+Library BuildIssues when building Library projects or Application projects.Issues when building Library projects or Application projects.