Skip to content

Commit

Permalink
OpenTK Deprecation (#5755)
Browse files Browse the repository at this point in the history
Context: #5647

.NET 6 will not include or redistribute `OpenTK-1.0.dll`.  Customers
using OpenTK should use the [Xamarin.Legacy.OpenTK NuGet package][0]:

	<PackageReference Include="Xamarin.Legacy.OpenTK" Version="0.0.1-alpha" />

The version number will change in the future.

In order to give customers who are using `OpenTK-1.0.dll` a chance to
migrate we are deprecating it first, and will raise an `XA4313` warning
if we detect that OpenTK-1.0 is in the `@(Referece)` item group:

	warning XA4313: The built-in 'OpenTK-1.0' reference has been deprecated.
	Remove the 'OpenTK-1.0' reference from your project and add the 'Xamarin.Legacy.OpenTK' NuGet package instead.

The vast majority of changes in this commit are to stop generating the
OpenTK java types into `mono-android.jar`.  From this point on `OpenTK`
will be treated like all other Android Class Libraries, and the
generated Java code will be written into the
`$(IntermediateOutputPath)\lp` directory along with all the other
assembly references.

[0]: https://www.nuget.org/packages/Xamarin.Legacy.OpenTK
  • Loading branch information
dellis1972 authored Apr 26, 2021
1 parent a2156d4 commit f909adb
Show file tree
Hide file tree
Showing 26 changed files with 240 additions and 21 deletions.
1 change: 1 addition & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ or 'Help->Report a Problem' in Visual Studio for Mac.
+ [XA4310](xa4310.md): \`$(AndroidSigningKeyStore)\` file \`{keystore}\` could not be found.
+ XA4311: The application won't contain the paired Wear package because the Wear application package APK is not created yet. If building on the command line, be sure to build the "SignAndroidPackage" target.
+ [XA4312](xa4312.md): Referencing an Android Wear application project from an Android application project is deprecated.
+ [XA4313](xa4313.md): Framework assembly has been deprecated.

## XA5xxx: GCC and toolchain

Expand Down
20 changes: 20 additions & 0 deletions Documentation/guides/messages/xa4313.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Xamarin.Android error/warning XA4313
description: XA4313 error/warning code
ms.date: 03/19/2021
---
# Xamarin.Android error/warning XA4313

The specified Framework assembly has been deprecated.
You need an upgrade to use the specified NuGet Package.

For example, to upgrade `OpenTK-1.0` remove

'<Reference Include="OpenTK-1.0" />'

from your csproj then add

'<PackageReference Include="Xamarin.Legacy.OpenTK" Version="1.0.0" />'

to your project to upgrade.

11 changes: 2 additions & 9 deletions build-tools/scripts/BuildEverything.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: leeroy jenkins leeroy-all opentk-jcw
.PHONY: leeroy jenkins leeroy-all
.PHONY: create-vsix

#
Expand All @@ -24,15 +24,8 @@ ifneq ("$(wildcard $(topdir)/external/monodroid/Makefile)","")
endif
$(MAKE) leeroy $(ZIP_OUTPUT)

leeroy: leeroy-all framework-assemblies opentk-jcw
leeroy: leeroy-all framework-assemblies

leeroy-all:
$(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) /restore $(SOLUTION) /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS)
$(call MSBUILD_BINLOG,leeroy-all,$(_SLN_BUILD)) /restore tools/xabuild/xabuild.csproj /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS)

opentk-jcw:
$(foreach api_level, $(API_LEVELS), \
touch bin/$(CONFIGURATION)/lib/xamarin.android/xbuild-frameworks/MonoAndroid/*/OpenTK-1.0.dll; \
$(call MSBUILD_BINLOG,OpenTK-JCW,$(_SLN_BUILD)) $(MSBUILD_FLAGS) src/OpenTK-1.0/OpenTK.csproj \
/t:GenerateJavaCallableWrappers /p:Configuration=$(CONFIGURATION) $(_MSBUILD_ARGS) \
/p:AndroidApiLevel=$(api_level) /p:AndroidPlatformId=$(word $(api_level), $(ALL_PLATFORM_IDS)) /p:AndroidFrameworkVersion=$(word $(api_level), $(ALL_FRAMEWORKS)) || exit 1; )
5 changes: 0 additions & 5 deletions src/OpenTK-1.0/OpenTK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,5 @@
<Import Project="..\..\build-tools\scripts\MonoAndroidFramework.targets" />
<PropertyGroup>
<DefineConstants>MONODROID;MINIMAL;MOBILE;OPENTK_1;OPENTK_1_0</DefineConstants>
<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' And '$(AndroidApiLevel)' != '' And $(AndroidApiLevel) &gt; 23 ">1.8</JavacSourceVersion>
<JavacSourceVersion Condition=" '$(JavacSourceVersion)' == '' ">1.6</JavacSourceVersion>
<JavaCallableWrapperAbsAssembly>$(JavaCallableWrapperOutputPathAbs)$(AssemblyName).dll</JavaCallableWrapperAbsAssembly>
<JavaCallableWrapperAbsAssembly Condition="!Exists('$(JavaCallableWrapperAbsAssembly)')">$(MSBuildProjectDirectory)\$(IntermediateOutputPath)\$(AssemblyName).dll</JavaCallableWrapperAbsAssembly>
</PropertyGroup>
<Import Project="..\..\build-tools\scripts\JavaCallableWrappers.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public abstract class MobileProfile : Profile {
"Mono.Data.Sqlite",
"Mono.Posix",
"Mono.Security",
"OpenTK",
"OpenTK-1.0",
// Facades assemblies (PCL)
"Microsoft.Win32.Primitives",
"Microsoft.Win32.Registry.AccessControl",
Expand Down
9 changes: 9 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,15 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<value>Referencing the Android Wear application project '{0}' from an Android application project is deprecated and will no longer be supported in a future version of Xamarin.Android. Remove the Android Wear application project reference from the Android application project and distribute the Wear application as a standalone application instead.</value>
<comment>The following are literal names and should not be translated: Android Wear, Android, Wear.
{0} - The referenced Android Wear project.</comment>
</data>
<data name="XA4313" xml:space="preserve">
<value>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</value>
<comment>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</comment>
</data>
<data name="XA5101" xml:space="preserve">
<value>Missing Android NDK toolchains directory '{0}'. Please install the Android NDK.</value>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
12 changes: 12 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ The following are literal names and should not be translated: ABI, 'libs/armeabi
<note>The following are literal names and should not be translated: ABI, NuGet
{0} - The native library file path
{1} - Either the name of the NuGet package or a path to the native library</note>
</trans-unit>
<trans-unit id="XA4313">
<source>The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</source>
<target state="new">The built-in '{0}' reference has been deprecated.
Remove the '{0}' reference from your project and add the '{1}' NuGet package instead.
</target>
<note>The following are literal names and should not be translated:
{0} - The Assembly name which is deprecated
{1} - A Nuget package name.
</note>
</trans-unit>
<trans-unit id="XA_Manifest_AutoGenerated_Header">
<source>
Expand Down
7 changes: 5 additions & 2 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ void Run (DirectoryAssemblyResolver res)
Log.LogDebugMessage ($"Skipping Java Stub Generation for {asm.ItemSpec}");
continue;
}
allTypemapAssemblies.Add (asm.ItemSpec);
userAssemblies.Add (Path.GetFileNameWithoutExtension (asm.ItemSpec), asm.ItemSpec);
if (!allTypemapAssemblies.Contains (asm.ItemSpec))
allTypemapAssemblies.Add (asm.ItemSpec);
string name = Path.GetFileNameWithoutExtension (asm.ItemSpec);
if (!userAssemblies.ContainsKey (name))
userAssemblies.Add (name, asm.ItemSpec);
}

// Step 1 - Find all the JLO types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3986,6 +3986,36 @@ public void XA1018 ()
}
}

[Test]
[Category ("DotNetIgnore")] // OpenTK not even shipped for .net 6.
public void XA4313 ()
{
var proj = new XamarinAndroidApplicationProject () {
References = {
new BuildItem.Reference ("OpenTK-1.0")
},
};
using (var builder = CreateApkBuilder ()) {
builder.ThrowOnBuildFailure = false;
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
string error = builder.LastBuildOutput
.SkipWhile (x => !x.StartsWith ("Build succeeded."))
.FirstOrDefault (x => x.Contains ("warning XA4313"));
Assert.IsNotNull (error, "Build should have failed with XA4313.");
}
}

[Test]
public void OpenTKNugetWorks ()
{
var proj = new XamarinAndroidApplicationProject ();
proj.PackageReferences.Add (KnownPackages.Xamarin_Legacy_OpenTK);
using (var builder = CreateApkBuilder ()) {
builder.ThrowOnBuildFailure = false;
Assert.IsTrue (builder.Build (proj), "Build should have succeeded.");
}
}

static readonly object [] XA1027XA1028Source = new object [] {
new object [] {
/* linkTool */ "r8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ public static class KnownPackages
Version = "2.4.1",
TargetFramework = "MonoAndroid10",
};
public static Package Xamarin_Legacy_OpenTK = new Package {
Id = "Xamarin.Legacy.OpenTK",
Version = "0.0.1-alpha",
TargetFramework = "MonoAndroid10",
};
}
}

Loading

0 comments on commit f909adb

Please sign in to comment.