Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop] fix .NET 6 linker warnings
Context: dotnet/android#5652 If you build a .NET 6 Android app: dotnet new android dotnet build -c Release -bl -p:SuppressTrimAnalysisWarnings=false You get warnings like: external\Java.Interop\src\Java.Interop\Java.Interop\JniRuntime.JniMarshalMemberBuilder.cs(53,4): warning IL2026: Java.Interop.JniRuntime.SetMarshalMemberBuilder(JniRuntime.CreationOptions): Using method 'System.Reflection.Assembly.GetType(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types might be removed. Adding this is not sufficient to fix the warning: [DynamicDependency (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, "Java.Interop.MarshalMemberBuilder", "Java.Interop.Export")] You also need to suppress `IL2026`: [UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "DynamicDependency should preserve the constructor.")] Then, because `Java.Interop.Export.dll` is not always included in apps, we also need to suppress: [UnconditionalSuppressMessage ("Trimming", "IL2035", Justification = "Java.Interop.Export.dll is not always present.")]
- Loading branch information