Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
return max;
}).
ToHashSet ();
var lowestTpvPerMajorDotNet = groupedByMajorDotNetVersion.
Select (gr => {
var min = gr.OrderBy (el => {
var rv = tfmToTpvAndTfv (el);
return float.Parse (rv.Tpv, System.Globalization.CultureInfo.InvariantCulture);
}).First ();
return min;
}).
ToHashSet ();

using (var writer = new StreamWriter (outputPath)) {
writer.WriteLine ($"<Project>");
Expand All @@ -65,7 +74,11 @@
writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '{tfv}'))\">");
writer.WriteLine ($" <Import Project=\"Sdk.props\" Sdk=\"Microsoft.{platform}.Sdk.{workloadVersion}\" /> <!-- this SDK version will validate the TargetPlatformVersion and show an error (in .NET 9+) or a warning (.NET 8) if it's not valid -->");
} else if (tpv.Length > 0) {
writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '{tfv}')) And '$(TargetPlatformVersion)' == '{tpv}'\">");
if (lowestTpvPerMajorDotNet.TryGetValue (tfm, out var lowest) && lowest.Split ('_')[1] == tpv) {
writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '{tfv}')) And ('$(TargetPlatformVersion)' == '{tpv}' Or ('$(TargetPlatformVersion)' == '' And '$(OutputType)' == 'Library' And '$(IsAppExtension)' != 'true'))\">");
} else {
writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '{tfv}')) And '$(TargetPlatformVersion)' == '{tpv}'\">");
}
writer.WriteLine ($" <Import Project=\"Sdk.props\" Sdk=\"Microsoft.{platform}.Sdk.{workloadVersion}\" />");
} else {
writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true' And $([MSBuild]::VersionEquals($(TargetFrameworkVersion), '{tfv}'))\">");
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ test.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Version.De
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_NUGET_REF_NAME=$($(platform)_NUGET_REF_NAME)\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(rid)_NUGET_RUNTIME_NAME=$($(rid)_NUGET_RUNTIME_NAME)\\n))" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),SUPPORTED_API_VERSIONS_$(platform)='$(SUPPORTED_API_VERSIONS_$(platform))'\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_TARGET_PLATFORM_VERSION_LIBRARY=$($(platform)_TARGET_PLATFORM_VERSION_LIBRARY)\\n)" | sed 's/^ //' >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "ENABLE_ADR=$(ENABLE_ADR)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
Expand Down Expand Up @@ -88,6 +89,7 @@ test-system.config: Makefile $(TOP)/Make.config $(TOP)/mk/mono.mk $(TOP)/eng/Ver
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_NUGET_REF_NAME=$($(platform)_NUGET_REF_NAME)\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(foreach rid,$(DOTNET_$(platform)_RUNTIME_IDENTIFIERS),$(rid)_NUGET_RUNTIME_NAME=$($(rid)_NUGET_RUNTIME_NAME)\\n))" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),SUPPORTED_API_VERSIONS_$(platform)='$(SUPPORTED_API_VERSIONS_$(platform))'\\n)" | sed 's/^ //' >> $@
@printf "$(foreach platform,$(DOTNET_PLATFORMS_UPPERCASE),$(platform)_TARGET_PLATFORM_VERSION_LIBRARY=$($(platform)_TARGET_PLATFORM_VERSION_LIBRARY)\\n)" | sed 's/^ //' >> $@
@printf "ENABLE_XAMARIN=$(ENABLE_XAMARIN)\n" >> $@
@printf "ENABLE_ADR=$(ENABLE_ADR)\n" >> $@
@printf "XCODE_IS_STABLE=$(XCODE_IS_STABLE)\n" >> $@
Expand Down
8 changes: 0 additions & 8 deletions tests/dotnet/MyClassLibrary/MacCatalyst/MyClass.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

5 changes: 4 additions & 1 deletion tests/dotnet/MyClassLibrary/MyClass.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;

using Foundation;

namespace MyClassLibrary {
public class MyClass {
public class MyClass : NSObject {
public MyClass ()
{
}
Expand Down
8 changes: 0 additions & 8 deletions tests/dotnet/MyClassLibrary/iOS/MyClass.cs

This file was deleted.

1 change: 1 addition & 0 deletions tests/dotnet/MyClassLibrary/iOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

8 changes: 0 additions & 8 deletions tests/dotnet/MyClassLibrary/macOS/MyClass.cs

This file was deleted.

1 change: 1 addition & 0 deletions tests/dotnet/MyClassLibrary/macOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

6 changes: 6 additions & 0 deletions tests/dotnet/MyClassLibrary/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ItemGroup>
<Compile Include="../*.cs" />
</ItemGroup>
</Project>
8 changes: 0 additions & 8 deletions tests/dotnet/MyClassLibrary/tvOS/MyClass.cs

This file was deleted.

1 change: 1 addition & 0 deletions tests/dotnet/MyClassLibrary/tvOS/MyClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

29 changes: 22 additions & 7 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,33 @@ public void BuildMyCatalystApp (string runtimeIdentifier)
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
}

[TestCase ("iOS")]
[TestCase ("tvOS")]
[TestCase ("macOS")]
[TestCase ("MacCatalyst")]
[TestCase (ApplePlatform.iOS)]
[TestCase (ApplePlatform.TVOS)]
[TestCase (ApplePlatform.MacOSX)]
[TestCase (ApplePlatform.MacCatalyst)]
[Category ("WindowsInclusive")]
public void BuildMyClassLibrary (string platform)
public void BuildMyClassLibrary (ApplePlatform platform)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
var project_path = GetProjectPath ("MyClassLibrary", platform);
var configuration = "Debug";
var project = "MyClassLibrary";
var project_path = GetProjectPath (project, platform: platform);
Clean (project_path);
var result = DotNet.AssertBuild (project_path, verbosity);
var properties = GetDefaultProperties ();
var result = DotNet.AssertBuild (project_path, properties);
Assert.That (result.StandardOutput.ToString (), Does.Not.Contain ("Task \"ILLink\""), "Linker executed unexpectedly.");

var expectedReferenceVersionString = Configuration.GetVariable ($"{platform.AsString ().ToUpperInvariant ()}_TARGET_PLATFORM_VERSION_LIBRARY", "");
Assert.That (expectedReferenceVersionString, Is.Not.EqualTo (""), $"Expected to have a default TPV for libraries");

var dll = Path.Combine (Path.GetDirectoryName (project_path)!, "bin", configuration, $"{Configuration.DotNetTfm}-{platform.AsString ()}", project + ".dll");
Assert.That (dll, Does.Exist, "Exists");
using var ad = AssemblyDefinition.ReadAssembly (dll, new ReaderParameters { ReadingMode = ReadingMode.Deferred });
var r = ad.MainModule.AssemblyReferences.Where (v => v.Name == $"Microsoft.{platform.AsString ()}").First ();
var actualReferenceVersionString = $"{r.Version.Major}.{r.Version.Minor}";
Assert.AreEqual (expectedReferenceVersionString, actualReferenceVersionString, $"Referenced version of Microsoft.{platform.AsString ()}.dll");
Assert.That (r.Version.Build, Is.EqualTo (0), "Build");
Assert.That (r.Version.Revision, Is.EqualTo (0), "Revision");
}

[TestCase ("iOS")]
Expand Down
Loading