Skip to content

Restore fixes lost by nightly-fix-finder - #13559

Merged
jonathanpeppers merged 8 commits into
mainfrom
jonathanpeppers-restore-lost-fix-finder-fixes
Nov 16, 2026
Merged

jonathanpeppers merged 8 commits into
mainfrom
jonathanpeppers-restore-lost-fix-finder-fixes

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

The nightly-fix-finder workflow found these fixes, but ./build.sh Prepare failed in the sandbox, so it opened no PR. This PR makes the fixes again by hand.

Testing:

  • New on-device test JavaAnnotation_LongValueOutsideIntRange_UsesJavaLongLiteral. A Java peer has a runtime annotation with long.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.Tests with filter TrimmableTypeMap: 102 passed, 8 skipped.
  • Xamarin.Android.Build.Tasks.csproj builds.

jonathanpeppers and others added 7 commits November 13, 2026 12:12
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]>
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]>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 L suffix to generated long literals, preventing compilation failures for values outside the int range.
  • Adds an on-device regression test with a runtime annotation and preservation rules.
  • Removes the unused assembly resolver, its factory method, and disabled ColorSymbol code.
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]>
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 16, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) November 16, 2026 20:24

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jonathanpeppers
jonathanpeppers merged commit 185f6b4 into main Nov 16, 2026
38 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-restore-lost-fix-finder-fixes branch November 16, 2026 21:11
jonathanpeppers added a commit that referenced this pull request Nov 16, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants