Skip to content

Conversation

@jonpryor
Copy link
Contributor

@jonpryor jonpryor commented Dec 7, 2021

Context: dotnet/android#6549

When attempting to bump xamarin-android to use bc5bcf4, the build
failed because bc5bcf4 added a "duplicate" type
Java.Interop.JavaTypeParametersAttribute:

error CS0433: The type 'JavaTypeParametersAttribute' exists in both
'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.

The plan was to use type forwarders for this type from
Mono.Android.dll to Java.Interop.dll, but in retrospect this
sounds like a potential "forward-incompatible ABI break", as
assemblies built against the newer Mono.Android.dll (with type
forwarders) won't be usable on previous Xamarin.Android SDKs.

Make JavaTypeParametersAttribute conditional on NET, so that it's
only included in .NET 6 builds. .NET SDK for Android will then use
type forwarders, which won't be an issue as there's no previous .NET
release to be forward compatible with.

jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 7, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 7, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 7, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
@jonpryor jonpryor force-pushed the jonp-JavaTypeParametersAttribute-only-in-net6 branch from 30f0c2b to 942df52 Compare December 7, 2021 19:12
Context: dotnet/android#6549

When attempting to bump xamarin-android to use bc5bcf4, the build
failed because bc5bcf4 added a "duplicate" type
`Java.Interop.JavaTypeParametersAttribute`:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.

The plan was to use type forwarders for this type from
`Mono.Android.dll` to `Java.Interop.dll`, but in retrospect this
sounds like a potential "forward-incompatible ABI break" (e56a8c8)
as assemblies built against the newer `Mono.Android.dll` (with type
forwarders) won't be usable on previous Xamarin.Android SDKs.

Make `JavaTypeParametersAttribute` conditional on `NET`, so that it's
only included in .NET 6 builds.  .NET SDK for Android will then use
type forwarders, which won't be an issue as there's no previous .NET
release to be forward compatible with.

Update `tests/generator-Tests` so that `JavaTypeParametersAttribute`
is once again provided for non-`NET` builds.
@jonpryor jonpryor force-pushed the jonp-JavaTypeParametersAttribute-only-in-net6 branch from 942df52 to 20d6bcb Compare December 7, 2021 19:38
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 8, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 8, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
xamarin-android Windows PR builds can't build, because of:

	error CS8032: An instance of analyzer System.Text.Json.SourceGeneration.JsonSourceGenerator cannot be created from C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.0\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.. [C:\a\_work\1\s\external\Java.Interop\build-tools\jnienv-gen\jnienv-gen.csproj]

Ignore the CS8032 warning/error, so that xamarin-android Windows
PR builds can *build*.
@jonpryor jonpryor force-pushed the jonp-JavaTypeParametersAttribute-only-in-net6 branch from a2f5d0d to e66b803 Compare December 8, 2021 18:11
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 8, 2021
Context: dotnet/java-interop#929

See if dotnet/java-interop#929 + type forwarders fixes the build
failure originally observed:

	error CS0433: The type 'JavaTypeParametersAttribute' exists in both
	'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and
	'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'
	[C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
Fixes Windows build failure:

	> C:\Users\cloudtest\android-toolchain\dotnet\dotnet "C:\a\_work\1\s\external\Java.Interop\bin\Release-net6.0\class-parse.dll" "C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.13-8\x64/jmods/java.base.jmod" "-o=obj\\Release-net6.0\/mcw/api.xml"
	  Could not execute because the specified command or file was not found.
	  Possible reasons for this include:
	    * You misspelled a built-in dotnet command.
	    * You intended to execute a .NET program, but dotnet-C:\a\_work\1\s\external\Java.Interop\bin\Release-net6.0\class-parse.dll does not exist.
	    * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

This is because `Java.Base.targets` should have been using
`$(UtilityOutputFullPath)`, not `$(ToolOutputFullPath)`.  Doh!
@jonpryor jonpryor merged commit aac3e9a into dotnet:main Dec 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant