Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

  • Understand the issue: When [Register("CustomView")] is used without a package prefix, the build fails because XmlImporter doesn't auto-generate a package name
  • Review PR [tests] add test for package-less [Register("CustomView"] android#10717 and issue Register Attribute breaks build android#10653
  • Analyze the code flow in java-interop
  • Implement fix in XmlImporter.cs to auto-generate a package name when package is empty/missing
  • Add GetPackageName(string ns, string assemblyName) overload to JavaNativeTypeManager for reuse
  • Refactor existing GetPackageName overloads to use the new method
  • Add test for the new behavior
  • Run tests to validate the fix
  • Add SetUp/TearDown to XmlImporterTests to save/restore PackageNamingPolicy

Summary

This PR fixes the issue where using [Register("CustomView")] without a package prefix would cause the build to fail in .NET 10. The fix auto-generates a package name from the partial assembly qualified name when the package attribute is empty or missing in the XML.

Changes

  • Added JavaNativeTypeManager.GetPackageName(string ns, string assemblyName) public method that centralizes package name generation logic
  • Refactored existing GetPackageName(Type) and GetPackageName(TypeDefinition, IMetadataResolver) to use the new method
  • Updated XmlImporter.GeneratePackageFromAssemblyQualifiedName to use the new method instead of duplicating crc64 logic
  • Added SetUp/TearDown methods to XmlImporterTests to properly save and restore PackageNamingPolicy
Original prompt

Review the PR:
@dotnet/android/pull/10717
And issue:
@dotnet/android/issues/10653

I think we need to do something in java-interop when the package is blank in these XML files -- to get back the previous behavior from .NET 9.

Did .NET 9 auto-generate a package name?


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 23, 2026 20:25
When a user uses [Register("CustomView")] without a package prefix, the
XmlImporter now auto-generates a crc64 package name from the partial
assembly qualified name. This restores the previous .NET 9 behavior where
Java types with empty package names could still be built.

Fixes dotnet/android#10653

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix java-interop behavior for blank package in XML files Auto-generate crc64 package name when package is empty in XmlImporter Jan 23, 2026
Copilot AI requested a review from jonathanpeppers January 23, 2026 20:32
…ing crc64 logic

Added new GetPackageName(string ns, string assemblyName) overload to
JavaNativeTypeManager and refactored existing overloads to use it.
XmlImporter now uses this new method instead of duplicating the logic.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a build failure in .NET 10 when using [Register("CustomView")] without a package prefix. The fix auto-generates a CRC64-based package name from the assembly-qualified type name when the package attribute is empty or missing in XML type definitions.

Changes:

  • Added a new public GetPackageName(string ns, string assemblyName) method to JavaNativeTypeManager to centralize package name generation logic
  • Refactored existing package name generation methods to use the new centralized method, reducing code duplication
  • Enhanced XmlImporter to auto-generate package names when they're missing or empty

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
XmlImporterTests.cs Comprehensive test suite covering package name generation for empty, missing, and explicit package scenarios, including edge cases like nested types and types without namespaces
JavaNativeTypeManager.cs Adds new public method for package name generation and refactors existing overloads to use it, reducing code duplication while maintaining backward compatibility
XmlImporter.cs Implements auto-generation of package names when missing/empty by parsing assembly-qualified names and delegating to JavaNativeTypeManager

…ingPolicy

Following the pattern used in JavaNativeTypeManagerTests, save and restore
the PackageNamingPolicy to prevent test interference if other tests modify
this static property.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI requested a review from jonathanpeppers January 24, 2026 23:39
@jonathanpeppers jonathanpeppers marked this pull request as ready for review January 26, 2026 21:52
@jonathanpeppers jonathanpeppers merged commit b7965d4 into main Jan 26, 2026
1 of 2 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-java-interop-blank-package branch January 26, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants