diff --git a/Make.versions b/Make.versions index 9465808487..9d52198a35 100644 --- a/Make.versions +++ b/Make.versions @@ -142,4 +142,7 @@ SUPPORTED_API_VERSIONS_MACCATALYST=$(DOTNET_TFM)-$(MACCATALYST_NUGET_OS_VERSION) # Add older versions here! -# (work on adding older versions is in progress) +SUPPORTED_API_VERSIONS_IOS+=$(DOTNET_TFM)-17.0 +SUPPORTED_API_VERSIONS_TVOS+=$(DOTNET_TFM)-17.0 +SUPPORTED_API_VERSIONS_MACOS+=$(DOTNET_TFM)-14.0 +SUPPORTED_API_VERSIONS_MACCATALYST+=$(DOTNET_TFM)-17.0 diff --git a/docs/multi-target-framework.md b/docs/multi-target-framework.md index 328e01ceef..052eb6edc4 100644 --- a/docs/multi-target-framework.md +++ b/docs/multi-target-framework.md @@ -122,39 +122,39 @@ WorkloadManifest.targets: + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) And '$(TargetPlatformVersion)' != '' And $([MSBuild]::VersionEquals($(TargetPlatformVersion), '16.0'))" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) And '$(TargetPlatformVersion)' != '' And $([MSBuild]::VersionEquals($(TargetPlatformVersion), '16.4'))" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) And '$(TargetPlatformVersion)' != '' And $([MSBuild]::VersionEquals($(TargetPlatformVersion), '17.0'))" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) And '$(TargetPlatformVersion)' != '' And $([MSBuild]::VersionEquals($(TargetPlatformVersion), '18.0'))" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0')) And '$(TargetPlatformVersion)' == ''" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0')) And '$(TargetPlatformVersion)' == ''" /> + Condition="'$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '7.0'))" /> + Condition="'$(UsingAppleNETSdk)' != 'true'" /> ``` -Note 1: Every sdk we load sets the property `_AppleSdkLoaded=true`, this makes +Note 1: Every sdk we load sets the property `UsingAppleNETSdk=true`, this makes it easy to avoid loading multiple sdks. Note 2: One complication here is that TargetPlatformVersion might not be set diff --git a/dotnet/Makefile b/dotnet/Makefile index 3cd1152f83..36eaa46573 100644 --- a/dotnet/Makefile +++ b/dotnet/Makefile @@ -176,7 +176,7 @@ $(foreach platform,$(DOTNET_PLATFORMS),$(eval $(call SupportedTargetPlatforms,$( define WorkloadTargets Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.json: Makefile $(TOP)/Make.config.inc $(GIT_DIRECTORY)/HEAD $(GIT_DIRECTORY)/index Makefile generate-workloadmanifest-json.csharp | Workloads/Microsoft.NET.Sdk.$(1) $$(Q) rm -f $$@.tmp - $$(Q_GEN) ./generate-workloadmanifest-json.csharp "$(1)" "$(3)" "$(5)" "$$(DOTNET_$(4)_RUNTIME_IDENTIFIERS)" "$$@.tmp" "$$(DOTNET_WINDOWS_PLATFORMS)" "$(DOTNET_TFM)_$$($(4)_NUGET_OS_VERSION)" + $$(Q_GEN) ./generate-workloadmanifest-json.csharp "$(1)" "$(3)" "$(5)" "$$(DOTNET_$(4)_RUNTIME_IDENTIFIERS)" "$$@.tmp" "$$(DOTNET_WINDOWS_PLATFORMS)" "$(DOTNET_TFM)_$$($(4)_NUGET_OS_VERSION)" "$(SUPPORTED_API_VERSIONS_$(4))" $(TOP)/eng/Versions.props $$(Q) mv $$@.tmp $$@ Workloads/Microsoft.NET.Sdk.$(1)/WorkloadManifest.targets: Makefile $(TOP)/Make.config.inc $(GIT_DIRECTORY)/HEAD $(GIT_DIRECTORY)/index Makefile generate-workloadmanifest-targets.csharp | Workloads/Microsoft.NET.Sdk.$(1) diff --git a/dotnet/generate-workloadmanifest-json.csharp b/dotnet/generate-workloadmanifest-json.csharp index 373958103a..c00901bac8 100755 --- a/dotnet/generate-workloadmanifest-json.csharp +++ b/dotnet/generate-workloadmanifest-json.csharp @@ -6,7 +6,7 @@ using System.IO; using System.Xml; var args = Args; -var expectedArgumentCount = 7; +var expectedArgumentCount = 9; if (args.Length != expectedArgumentCount) { Console.WriteLine ($"Need {expectedArgumentCount} arguments, got {args.Length}"); Environment.Exit (1); @@ -22,10 +22,25 @@ var outputPath = args [argumentIndex++]; var windowsPlatforms = args [argumentIndex++].Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var hasWindows = Array.IndexOf (windowsPlatforms, platform) >= 0; var currentApiVersion = args [argumentIndex++]; +var supportedApiVersions = args [argumentIndex++].Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); +var versionsPropsPath = args [argumentIndex++]; var platformLowerCase = platform.ToLowerInvariant (); -var tfm = currentApiVersion; +var allApiVersions = new List (supportedApiVersions); +allApiVersions = allApiVersions.Select (v => v.Replace ('-', '_')).ToList (); + +var versionsPropsTable = File.ReadAllLines (versionsPropsPath). + Where (v => v.Count (f => f == '>') > 1). + Select (v => { + var split = v.Trim ().Split (new char [] { '<', '>', '/'}, StringSplitOptions.RemoveEmptyEntries); + var name = split [0]; + var value = split [1]; + return new Tuple (name, value); + }). + ToDictionary (v => v.Item1, v => v.Item2, StringComparer.OrdinalIgnoreCase); + +var failed = false; using (TextWriter writer = new StreamWriter (outputPath)) { writer.WriteLine ($"{{"); writer.WriteLine ($" \"version\": \"{version}\","); @@ -39,9 +54,9 @@ using (TextWriter writer = new StreamWriter (outputPath)) { writer.WriteLine ($" \"Microsoft.{platform}.Windows.Sdk.Aliased.{tfm}\","); writer.WriteLine ($" \"Microsoft.{platform}.Windows.Sdk.Aliased.net8\","); } - writer.WriteLine ($" \"Microsoft.{platform}.Ref.{tfm}\","); + writer.WriteLine ($" \"Microsoft.{platform}.Ref.{currentApiVersion}\","); foreach (var rid in runtimeIdentifiers) { - writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}.{tfm}\","); + writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}.{currentApiVersion}\","); } writer.WriteLine ($" \"Microsoft.{platform}.Templates.net9\""); writer.WriteLine ($" ],"); @@ -62,6 +77,7 @@ using (TextWriter writer = new StreamWriter (outputPath)) { writer.WriteLine ($" \"version\": \"{version}\","); writer.WriteLine ($" }},"); writer.WriteLine ($" \"Microsoft.{platform}.Sdk.net8\": {{"); + writer.WriteLine ($" \"kind\": \"sdk\","); writer.WriteLine ($" \"version\": \"{net8Version}\","); writer.WriteLine ($" \"alias-to\": {{"); @@ -88,12 +104,12 @@ using (TextWriter writer = new StreamWriter (outputPath)) { writer.WriteLine ($" }}"); writer.WriteLine ($" }},"); } - writer.WriteLine ($" \"Microsoft.{platform}.Ref.{tfm}\": {{"); + writer.WriteLine ($" \"Microsoft.{platform}.Ref.{currentApiVersion}\": {{"); writer.WriteLine ($" \"kind\": \"framework\","); writer.WriteLine ($" \"version\": \"{version}\""); writer.WriteLine ($" }},"); foreach (var rid in runtimeIdentifiers) { - writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}.{tfm}\": {{"); + writer.WriteLine ($" \"Microsoft.{platform}.Runtime.{rid}.{currentApiVersion}\": {{"); writer.WriteLine ($" \"kind\": \"framework\","); writer.WriteLine ($" \"version\": \"{version}\""); writer.WriteLine ($" }},"); @@ -109,4 +125,6 @@ using (TextWriter writer = new StreamWriter (outputPath)) { writer.WriteLine ($"}}"); } +if (failed) + Environment.Exit (1); Environment.Exit (0); diff --git a/dotnet/generate-workloadmanifest-targets.csharp b/dotnet/generate-workloadmanifest-targets.csharp index 896aa9e84f..ae1f05f27a 100755 --- a/dotnet/generate-workloadmanifest-targets.csharp +++ b/dotnet/generate-workloadmanifest-targets.csharp @@ -20,46 +20,53 @@ var windowsPlatforms = args [argumentIndex++].Split (new char [] { ' ' }, String var hasWindows = Array.IndexOf (windowsPlatforms, platform) >= 0; var currentApiVersion = args [argumentIndex++]; var olderApiVersions = args [argumentIndex++]; -var defaultApiVersion = args [argumentIndex++]; +var supportedApiVersions = args [argumentIndex++]; var platformLowerCase = platform.ToLowerInvariant (); var tfm = currentApiVersion; var supportedTFMs = new List (); -supportedTFMs.Add (currentApiVersion); supportedTFMs.AddRange (olderApiVersions.Split (' ')); +supportedTFMs.AddRange (supportedApiVersions.Split (' ').Select (v => v.Replace ('-', '_'))); +supportedTFMs.Sort (); var supportedTFVs = new List (); using (var writer = new StreamWriter (outputPath)) { writer.WriteLine ($""); - writer.WriteLine ($" "); foreach (var tfm in supportedTFMs) { var tfv = tfm.Replace ("net", ""); var sep = tfv.IndexOfAny (new char [] { '-', '_' }); - if (sep >= 0) + var tpv = ""; + if (sep >= 0) { + tpv = tfv.Substring (sep + 1); tfv = tfv.Substring (0, sep); + } supportedTFVs.Add (tfv); var workloadVersion = tfm; if (tfv [0] == '7') workloadVersion = tfm.Replace (".0", ""); - writer.WriteLine ($" "); - } - if (hasWindows) { - writer.WriteLine (); - foreach (var tfm in supportedTFMs) { - var tfv = tfm.Replace ("net", ""); - var sep = tfv.IndexOfAny (new char [] { '-', '_' }); - if (sep >= 0) - tfv = tfv.Substring (0, tfv.IndexOfAny (new char [] { '-', '_' })); - var workloadVersion = tfm; - if (tfv [0] == '7') - workloadVersion = tfm.Replace (".0", ""); - writer.WriteLine ($" "); + if (tfm == currentApiVersion) { + writer.WriteLine ($" "); + writer.WriteLine ($" "); + } else if (tpv.Length > 0) { + writer.WriteLine ($" "); + writer.WriteLine ($" "); + } else { + writer.WriteLine ($" "); + writer.WriteLine ($" "); } + + if (hasWindows) { + writer.WriteLine ($" "); + } + + writer.WriteLine ($" "); + writer.WriteLine (); } - writer.WriteLine (); + var earliestSupportedTFV = supportedTFVs.Select (v => Version.Parse (v)).OrderBy (v => v).First (); + writer.WriteLine ($" "); writer.WriteLine ($" "); writer.WriteLine ($" "); writer.WriteLine (); diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 50adafa379..ced06e2dce 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -47,6 +47,23 @@ https://github.com/xamarin/xamarin-macios 2cb9d6666fb84a59e149049f20fee18de0902129 + + + https://github.com/xamarin/xamarin-macios + 492e53f5b423c6e9cbdb48f3d57c92a1f97b5005 + + + https://github.com/xamarin/xamarin-macios + 492e53f5b423c6e9cbdb48f3d57c92a1f97b5005 + + + https://github.com/xamarin/xamarin-macios + 492e53f5b423c6e9cbdb48f3d57c92a1f97b5005 + + + https://github.com/xamarin/xamarin-macios + 492e53f5b423c6e9cbdb48f3d57c92a1f97b5005 + https://github.com/dotnet/runtime cf47d9ff6827a3e1d6f2acbf925cd618418f20dd diff --git a/tests/dotnet/MultiTargetingLibrary/AppDelegate.cs b/tests/dotnet/MultiTargetingLibrary/AppDelegate.cs index e6bb47853e..7f18721410 100644 --- a/tests/dotnet/MultiTargetingLibrary/AppDelegate.cs +++ b/tests/dotnet/MultiTargetingLibrary/AppDelegate.cs @@ -7,5 +7,10 @@ namespace MySimpleApp { { return 42; } + + public static Type GetNSObjectType () + { + return typeof (Foundation.NSObject); + } } } diff --git a/tests/dotnet/UnitTests/PackTest.cs b/tests/dotnet/UnitTests/PackTest.cs index 057e677814..ebc33c771f 100644 --- a/tests/dotnet/UnitTests/PackTest.cs +++ b/tests/dotnet/UnitTests/PackTest.cs @@ -176,7 +176,6 @@ namespace Xamarin.Tests { [TestCase (ApplePlatform.iOS)] [TestCase (ApplePlatform.TVOS)] [TestCase (ApplePlatform.MacOSX)] - [Ignore ("Multi-targeting support has been temporarily reverted/postponed")] public void MultiTargetLibraryProject (ApplePlatform platform) { Configuration.IgnoreIfIgnoredPlatform (platform); diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index ca09e8c894..2d50ac57d9 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1517,7 +1517,6 @@ namespace Xamarin.Tests { [TestCase (ApplePlatform.iOS)] [TestCase (ApplePlatform.TVOS)] [TestCase (ApplePlatform.MacOSX)] - [Ignore ("Multi-targeting support has been temporarily reverted/postponed")] public void MultiTargetLibrary (ApplePlatform platform) { Configuration.IgnoreIfIgnoredPlatform (platform); @@ -1620,6 +1619,7 @@ namespace Xamarin.Tests { return supportedApiVersions .Where (v => v.StartsWith (Configuration.DotNetTfm + "-", StringComparison.Ordinal)) .Select (v => v.Substring (Configuration.DotNetTfm.Length + 1)) + .OrderBy (v => v) .ToArray (); } diff --git a/tests/dotnet/UnitTests/TestBaseClass.cs b/tests/dotnet/UnitTests/TestBaseClass.cs index e4ecb7b5e1..0b300666ca 100644 --- a/tests/dotnet/UnitTests/TestBaseClass.cs +++ b/tests/dotnet/UnitTests/TestBaseClass.cs @@ -441,8 +441,12 @@ namespace Xamarin.Tests { var failures = new List (); for (var i = 0; i < expectedMessages.Length; i++) { - if (actualMessages [i].Message != expectedMessages [i]) { - failures.Add ($"\tUnexpected {type} message #{i}:\n\t\tExpected: {expectedMessages [i]}\n\t\tActual: {actualMessages [i].Message?.TrimEnd ()}"); + var actual = actualMessages [i].Message ?? string.Empty; + var expected = expectedMessages [i]; + if (actual != expected) { + actual = actual.Replace ("\n", "\\n").Replace ("\r", "\\r"); + expected = expected.Replace ("\n", "\\n").Replace ("\r", "\\r"); + failures.Add ($"\tUnexpected {type} message #{i}:\n\t\tExpected: {expected}\n\t\tActual: {actual}"); } } if (!failures.Any ())