Commit c5a84b8
[Xamarin.Android.Build.Tasks] Fix XA4215 if AssemblyName is the same (#7477)
Fixes: #7473
Context: xamarin/monodroid@4c697e5a6b
Context: https://github.com/dotnet/runtime/blob/27c19c31f574375fd1651207b2dc28d39fe1225c/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.64bit.xml
With the .NET 6+ build system, it is possible for an AnyCPU assembly
to become a *set* of assemblies, one per `$(RuntimeIdentifiers)`
value.
In particular, the linker will now *inline* calls to
`System.IntPtr.get_Size()`, replacing them with the appropriate
architecture-specific value. This means that a single assembly that
uses the `IntPtr.Size` property could become *4* assemblies, one each
for android-arm, android-arm64, android-x86, and android-x64.
Furthermore, each of these assemblies will have a different MVID.
This is "fine", until the assembly contains a `Java.Lang.Object`
subclass that needs a Java Callable Wrapper generated for it, at
which point the `<GenerateJavaStubs/>` task starts emitting XA4214
warnings and XA4215 *errors*:
warning XA4214: The managed type `Microsoft.UI.Xaml.Controls.AnimatedIcon` exists
in multiple assemblies: Uno.UI, Uno.UI, Uno.UI, Uno.UI.
Please refactor the managed type names in these assemblies so that they are not identical.
error XA4215: The Java type `crc64a5a37c43dff01024.GridViewHeaderItem` is generated by more than
one managed type. Please change the [Register] attribute so that the same Java type is not emitted.
**Workaround**: Build with only a single `$(RuntimeIdentifier)`:
dotnet build -p:RuntimeIdentifier=android-arm64 …
Fix this scenario by updating the XA4214 warning and XA4215 error
checks to verify that the module name has changed; if the module name
is the same, then it's not a duplicate type.1 parent 087cf2b commit c5a84b8
File tree
2 files changed
+45
-8
lines changed- src/Xamarin.Android.Build.Tasks
- Tasks
- Tests/Xamarin.Android.Build.Tests/Tasks
2 files changed
+45
-8
lines changedLines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | 203 | | |
205 | 204 | | |
206 | 205 | | |
| |||
251 | 250 | | |
252 | 251 | | |
253 | 252 | | |
254 | | - | |
255 | | - | |
256 | | - | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
257 | 258 | | |
258 | 259 | | |
259 | 260 | | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
512 | 546 | | |
513 | 547 | | |
0 commit comments