Repository navigation
Restore fixes lost by nightly-fix-finder - #13559
Conversation
Annotation values of type long were written without the Java L suffix. Values outside the 32-bit int range were then invalid Java literals and broke compilation of the generated Java callable wrappers. Co-authored-by: Copilot App <[email protected]>
ColorSymbol had an #if false block that duplicated the ISymbol members that SimpleSymbol already implements. The block was never compiled and was not valid C#. Co-authored-by: Copilot App <[email protected]>
…y warning The warning that XAAssemblyResolver logs when it cannot read an assembly with its debugging symbols was a hardcoded string. Move it to Resources.resx as XA4332, log it with LogCodedWarning, and document it. The retry behavior and the exception details warning do not change. Co-authored-by: Copilot App <[email protected]>
…bol retry warning" This reverts commit f47819e.
CustomAttributeTypeProvider reports Int64, not System.Int64. Co-authored-by: Copilot App <[email protected]>
#13069 removed the last caller of MonoAndroidHelper.MakeResolver, which was the only code that created XAAssemblyResolver. Remove both. Co-authored-by: Copilot App <[email protected]>
#12931 moved generated-code coverage for the trimmable typemap to on-device tests. Replace the host-side JavaAnnotationParserTests with an on-device test: a Java peer has a runtime annotation with a long value outside the int range. Without the L suffix fix, javac fails to compile the generated Java callable wrapper. The test also reads the value back through Java reflection. ManagedValueToJavaSource is private again. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the annotation-literal fix and unused-code cleanup.
No open issues 🎉
What changed in this PR
Restores the applicable fixes identified by nightly-fix-finder: correct Java generation for long annotation values and removal of unused code from the Android build tools and binding generator.
Changes:
- Adds the Java
Lsuffix to generatedlongliterals, preventing compilation failures for values outside theintrange. - Adds an on-device regression test with a runtime annotation and preservation rules.
- Removes the unused assembly resolver, its factory method, and disabled
ColorSymbolcode.
| File | Description |
|---|---|
tests/Mono.Android-Tests/Mono.Android-Tests/proguard.cfg |
Preserves runtime annotations and the new annotation type. |
tests/Mono.Android-Tests/Mono.Android-Tests/Java.Interop/TrimmableTypeMapRuntimeCoverageTests.cs |
Tests that a generated annotation retains long.MaxValue. |
tests/Mono.Android-Tests/Mono.Android-Test.Library/java/net/dot/android/test/LongValueAnnotation.java |
Defines the runtime annotation used by the regression test. |
src/Xamarin.Android.Build.Tasks/Utilities/XAAssemblyResolver.cs |
Deletes the unused assembly resolver. |
src/Xamarin.Android.Build.Tasks/Utilities/MonoAndroidHelper.cs |
Removes the unused resolver factory. |
src/Microsoft.Android.Sdk.TrimmableTypeMap/Scanner/JavaAnnotationParser.cs |
Emits Java long literals with the L suffix. |
src/generator/Java.Interop.Tools.Generator.ObjectModel/Symbols/ColorSymbol.cs |
Removes disabled, redundant code. |
Review effort: Balanced
The binding generator emits Equals, GetHashCode, and ToString without override in the invoker for a Java annotation interface. With TreatWarningsAsErrors on CI, CS0114 broke the Mono.Android-Test.Library build and every Mono.Android.NET-Tests lane. Move the Java annotation into the test app with Bind=false, write the C# attribute by hand, and load the annotation class through the peer's class loader. Co-authored-by: Copilot App <[email protected]>
|
@dalexsoto review |
dalexsoto
left a comment
There was a problem hiding this comment.
Reviewed 3d778b80 against main at f9c38dcb (merge-base 4f5df8b8). This was a static, read-only review. I didn't build or run anything.
LGTM. JavaAnnotationParser now writes every boxed long as an invariant <value>L, so boundary values such as long.MinValue are valid Java. JcwJavaSourceGenerator.WriteAnnotations emits that value unchanged at every annotation site, so the suffix is never doubled, and other value types follow the same paths as before. The new LongValueAnnotation test is wired in correctly (Compile Include, Bind="false" and the ProGuard keep rules) and is deterministic. Nothing left in the tree uses XAAssemblyResolver or MonoAndroidHelper.MakeResolver, and the XA4332 add/revert nets to zero against the merge-base. The ColorSymbol change only removes a dead #if false block.
Non-blocking: ManagedValueToJavaSource already had gaps for float (F suffix), char literals and large ulong values. Those could be a follow-up.
Convert the JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral test that #13559 added to TrimmableTypeMapRuntimeCoverageTests.cs to MSTest: [Test] -> [TestMethod] and AssertionException -> AssertFailedException. The merge was textually clean but did not compile. Give mac_build `dependsOn: []`. Without it, mac_build implicitly depends on the opt-in native_mtp_host_tests stage, so a host-test failure or skipTests=true skipped the macOS build when runNativeMtpHostTests=true. Co-authored-by: Copilot App <[email protected]>
The
nightly-fix-finderworkflow found these fixes, but./build.sh Preparefailed in the sandbox, so it opened no PR. This PR makes the fixes again by hand.LocalManifestProvider.cs. Not included, because [Xamarin.Installer.Build.Tasks] Use Android CLI to install SDK packages #13513 deleted the file.JavaAnnotationParserwrotelongannotation values without the JavaLsuffix. For values outside theintrange,javacfails with "integer number too large". The parser now adds the suffix.#if falseblock fromColorSymbol.cs. The block was a copy of members thatSimpleSymbolalready has, and it was not valid C#.XAAssemblyResolverretry warning intoResources.resx. But nothing has calledMonoAndroidHelper.MakeResolversince [Xamarin.Android.Build.Tasks] Remove LLVM codegen and binutils #13069, so this PR removesXAAssemblyResolverandMakeResolverinstead. An earlier commit in this PR added the warning as XA4332, and a later commit reverts it. Squash before merge.Testing:
JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral. A Java peer has a runtime annotation withlong.MaxValue, and the test reads the value back through reflection. Without the fix, the test app does not build (javac: "integer number too large").Mono.Android.NET-Tests, Release, API 36 emulator: 1056 passed, 8 skipped, 0 failed.generator-Tests: 478 passed.Microsoft.Android.Build.Tasks.Testswith filterTrimmableTypeMap: 102 passed, 8 skipped.Xamarin.Android.Build.Tasks.csprojbuilds.