From be031736bed2ad1d0bcbc50e64a76e975907f19c Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 7 Mar 2023 07:58:54 +0100 Subject: [PATCH] [net8.0] [tests] Add a .NET 7 test app. (#17385) --- dotnet/generate-workloadmanifest-json.csharp | 2 ++ tests/dotnet/Net7_0SimpleApp/AppDelegate.cs | 17 +++++++++++ .../Net7_0SimpleApp/MacCatalyst/Makefile | 1 + .../MacCatalyst/Net7_0SimpleApp.csproj | 8 +++++ tests/dotnet/Net7_0SimpleApp/Makefile | 2 ++ tests/dotnet/Net7_0SimpleApp/iOS/Makefile | 1 + .../iOS/Net7_0SimpleApp.csproj | 8 +++++ tests/dotnet/Net7_0SimpleApp/macOS/Makefile | 1 + .../macOS/Net7_0SimpleApp.csproj | 8 +++++ tests/dotnet/Net7_0SimpleApp/shared.csproj | 16 ++++++++++ tests/dotnet/Net7_0SimpleApp/shared.mk | 4 +++ tests/dotnet/Net7_0SimpleApp/tvOS/Makefile | 1 + .../tvOS/Net7_0SimpleApp.csproj | 8 +++++ tests/dotnet/UnitTests/ProjectTest.cs | 30 +++++++++++++++++++ 14 files changed, 107 insertions(+) create mode 100644 tests/dotnet/Net7_0SimpleApp/AppDelegate.cs create mode 100644 tests/dotnet/Net7_0SimpleApp/MacCatalyst/Makefile create mode 100644 tests/dotnet/Net7_0SimpleApp/MacCatalyst/Net7_0SimpleApp.csproj create mode 100644 tests/dotnet/Net7_0SimpleApp/Makefile create mode 100644 tests/dotnet/Net7_0SimpleApp/iOS/Makefile create mode 100644 tests/dotnet/Net7_0SimpleApp/iOS/Net7_0SimpleApp.csproj create mode 100644 tests/dotnet/Net7_0SimpleApp/macOS/Makefile create mode 100644 tests/dotnet/Net7_0SimpleApp/macOS/Net7_0SimpleApp.csproj create mode 100644 tests/dotnet/Net7_0SimpleApp/shared.csproj create mode 100644 tests/dotnet/Net7_0SimpleApp/shared.mk create mode 100644 tests/dotnet/Net7_0SimpleApp/tvOS/Makefile create mode 100644 tests/dotnet/Net7_0SimpleApp/tvOS/Net7_0SimpleApp.csproj diff --git a/dotnet/generate-workloadmanifest-json.csharp b/dotnet/generate-workloadmanifest-json.csharp index c471e9ef47..f09a028815 100755 --- a/dotnet/generate-workloadmanifest-json.csharp +++ b/dotnet/generate-workloadmanifest-json.csharp @@ -53,9 +53,11 @@ using (TextWriter writer = new StreamWriter (outputPath)) { if (platform == "macOS") { writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling\","); writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling-net6\","); + writer.WriteLine ($" \"microsoft-net-runtime-mono-tooling-net7\","); } else { writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}\","); writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}-net6\","); + writer.WriteLine ($" \"microsoft-net-runtime-{platformLowerCase}-net7\","); } writer.WriteLine ($" ]"); writer.WriteLine ($" }},"); diff --git a/tests/dotnet/Net7_0SimpleApp/AppDelegate.cs b/tests/dotnet/Net7_0SimpleApp/AppDelegate.cs new file mode 100644 index 0000000000..db62735119 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/AppDelegate.cs @@ -0,0 +1,17 @@ +using System; +using System.Runtime.InteropServices; + +using Foundation; + +namespace MySimpleApp { + public class Program { + static int Main (string [] args) + { + GC.KeepAlive (typeof (NSObject)); // prevent linking away the platform assembly + + Console.WriteLine (Environment.GetEnvironmentVariable ("MAGIC_WORD")); + + return args.Length; + } + } +} diff --git a/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Makefile b/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Makefile new file mode 100644 index 0000000000..110d078f45 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Net7_0SimpleApp.csproj b/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Net7_0SimpleApp.csproj new file mode 100644 index 0000000000..c208f2b18d --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/MacCatalyst/Net7_0SimpleApp.csproj @@ -0,0 +1,8 @@ + + + + net7.0-maccatalyst + 14.0 + + + diff --git a/tests/dotnet/Net7_0SimpleApp/Makefile b/tests/dotnet/Net7_0SimpleApp/Makefile new file mode 100644 index 0000000000..6affa45ff1 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/Makefile @@ -0,0 +1,2 @@ +TOP=../../.. +include $(TOP)/tests/common/shared-dotnet-test.mk diff --git a/tests/dotnet/Net7_0SimpleApp/iOS/Makefile b/tests/dotnet/Net7_0SimpleApp/iOS/Makefile new file mode 100644 index 0000000000..110d078f45 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/iOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/Net7_0SimpleApp/iOS/Net7_0SimpleApp.csproj b/tests/dotnet/Net7_0SimpleApp/iOS/Net7_0SimpleApp.csproj new file mode 100644 index 0000000000..0ea1a9d7ae --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/iOS/Net7_0SimpleApp.csproj @@ -0,0 +1,8 @@ + + + + net7.0-ios + 11.0 + + + diff --git a/tests/dotnet/Net7_0SimpleApp/macOS/Makefile b/tests/dotnet/Net7_0SimpleApp/macOS/Makefile new file mode 100644 index 0000000000..110d078f45 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/macOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/Net7_0SimpleApp/macOS/Net7_0SimpleApp.csproj b/tests/dotnet/Net7_0SimpleApp/macOS/Net7_0SimpleApp.csproj new file mode 100644 index 0000000000..d8f92d86eb --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/macOS/Net7_0SimpleApp.csproj @@ -0,0 +1,8 @@ + + + + net7.0-macos + 10.15 + + + diff --git a/tests/dotnet/Net7_0SimpleApp/shared.csproj b/tests/dotnet/Net7_0SimpleApp/shared.csproj new file mode 100644 index 0000000000..cda1f92953 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/shared.csproj @@ -0,0 +1,16 @@ + + + + Exe + + MySimpleApp + com.xamarin.mysimpleapp + 7.0 + + + + + + + + diff --git a/tests/dotnet/Net7_0SimpleApp/shared.mk b/tests/dotnet/Net7_0SimpleApp/shared.mk new file mode 100644 index 0000000000..1a9dda38e4 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/shared.mk @@ -0,0 +1,4 @@ +TOP=../../../.. +TESTNAME=Net7_0SimpleApp +TEST_TFM=net7.0 +include $(TOP)/tests/common/shared-dotnet.mk diff --git a/tests/dotnet/Net7_0SimpleApp/tvOS/Makefile b/tests/dotnet/Net7_0SimpleApp/tvOS/Makefile new file mode 100644 index 0000000000..110d078f45 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/tvOS/Makefile @@ -0,0 +1 @@ +include ../shared.mk diff --git a/tests/dotnet/Net7_0SimpleApp/tvOS/Net7_0SimpleApp.csproj b/tests/dotnet/Net7_0SimpleApp/tvOS/Net7_0SimpleApp.csproj new file mode 100644 index 0000000000..8dd2182727 --- /dev/null +++ b/tests/dotnet/Net7_0SimpleApp/tvOS/Net7_0SimpleApp.csproj @@ -0,0 +1,8 @@ + + + + net7.0-tvos + 11.0 + + + diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index b346047c5b..5e8e4f8c22 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1000,6 +1000,36 @@ namespace Xamarin.Tests { ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable); } + [Test] + [TestCase (ApplePlatform.iOS, "iossimulator-x64")] + [TestCase (ApplePlatform.iOS, "ios-arm64")] + [TestCase (ApplePlatform.TVOS, "tvossimulator-arm64")] + [TestCase (ApplePlatform.MacOSX, "osx-arm64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")] + public void BuildNet7_0App (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "Net7_0SimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, netVersion: "net7.0"); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + + var result = DotNet.AssertBuild (project_path, properties); + AssertThatLinkerExecuted (result); + var infoPlistPath = GetInfoPListPath (platform, appPath); + Assert.That (infoPlistPath, Does.Exist, "Info.plist"); + var infoPlist = PDictionary.FromFile (infoPlistPath)!; + Assert.AreEqual ("com.xamarin.mysimpleapp", infoPlist.GetString ("CFBundleIdentifier").Value, "CFBundleIdentifier"); + Assert.AreEqual ("MySimpleApp", infoPlist.GetString ("CFBundleDisplayName").Value, "CFBundleDisplayName"); + Assert.AreEqual ("7.0", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion"); + Assert.AreEqual ("7.0", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString"); + + var appExecutable = GetNativeExecutable (platform, appPath); + ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable); + } + [Test] [TestCase (ApplePlatform.iOS, "iossimulator-x64")] // [TestCase (ApplePlatform.TVOS, "tvos-arm64")] // Currently doesn't work because we overwrite the required MtouchExtraArgs in tests/nunit.frameworks.target in this test.