-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dotnet trimmer testing #144
Comments
When trimming my application, android's |
Okay yes, I will add the |
Ok but I'm not 100% sure that the |
No, I can't confirm that, I was just assuming it would work. What would be the alternative? |
I've asked for help on discord, here is what I've understood. The So I think the proper way to fix the missing |
Disabling trimming completely until this is resolved. The workarounds no longer work for me. |
…ttribute` Fixes: dotnet#8940 Context: TobiasBuchholz/Plugin.Firebase#144 Using the NuGet package: <PackageReference Include="Plugin.Firebase.CloudMessaging" Version="3.0.0" /> Includes a service: namespace Plugin.Firebase.CloudMessaging.Platforms.Android; [Service(Exported = true)] [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })] public class MyFirebaseMessagingService : FirebaseMessagingService Unfortunately, using `TrimMode=full` completely trims away the above service, which is required for push notifications to work. I could reproduce this problem in a test using the above NuGet package. To fix this, we can modify `MarkJavaObjects` to preserve types with attributes that implement `Java.Interop.IJniNameProviderAttribute`, and the new test now passes.
Until this one ships: I found putting this in your app seems to workaround the issue: [DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(MyFirebaseMessagingService))] Can anyone confirm if it solve the problem for them? Is this only happening when using |
@jonathanpeppers Seems like it's working just fine with DynamicDependency attribute ! |
No, I don't think we can remove It does seem like we could add |
…ttribute` (#9099) Fixes: #8940 Context: TobiasBuchholz/Plugin.Firebase#144 Using the NuGet package: <PackageReference Include="Plugin.Firebase.CloudMessaging" Version="3.0.0" /> Includes a service: namespace Plugin.Firebase.CloudMessaging.Platforms.Android; [Service(Exported = true)] [IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })] public class MyFirebaseMessagingService : FirebaseMessagingService Unfortunately, using `TrimMode=full` completely trims away the above service, which is required for push notifications to work. I could reproduce this problem in a test using the above NuGet package. To fix this, we can modify `MarkJavaObjects` to preserve types with attributes that implement `Java.Interop.IJniNameProviderAttribute`, and the new test now passes. With one exception, `Android.Runtime.RegisterAttribute`, should not be preserved as that would be any Java type bound for C#.
Context: TobiasBuchholz/Plugin.Firebase#144 (comment) Even since .NET 6 (in e604833), we have marked `[Preserve]` as `[Obsolete]`. However, you could still use the attribute *thinking* it might do something, while it actually does nothing. Let's add in .NET 9: * `error: true` so you get a build error * An actual docs link (the best one I could find)
Hi,
When migrating playground/tests to dotnet maui, the
<AndroidLinkMode>Full</AndroidLinkMode>
property has been removed from the release build.I don't know if it's been done on purpose, but I think you could add now the corresponding dotnet trimmer property:
<TrimMode>full</TrimMode>
.Also, are you sure the
Preserve
attributes in the plugin code are still needed?Maybe it's worth testing it again with dotnet trimmer. What do you think?
Thanks!
The text was updated successfully, but these errors were encountered: