Skip to content

Commit

Permalink
Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.…
Browse files Browse the repository at this point in the history
…NFloat.Internal PackageReference (#14532)

* Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal

This unbreaks Central Package Management via https://github.com/microsoft/MSBuildSdks/tree/main/src/CentralPackageVersions which is being worked on for NuGet, see NuGet/Home#6764

* Add test case

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
  • Loading branch information
akoeplinger and rolfbjarne authored Mar 30, 2022
1 parent 895e556 commit b8c493c
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.DefaultItems.targets
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

<ItemGroup>
<!-- Add a reference to our custom nfloat reference assembly for .NET 6 (but only for .NET 6, once we switch to .NET 7 this can be removed) -->
<PackageReference Include="System.Runtime.InteropServices.NFloat.Internal" Condition="'$(BundledNETCorePlatformsPackageVersion.Substring(0,1))' == '6'" Version="[6.0.1, )" />
<PackageReference Include="System.Runtime.InteropServices.NFloat.Internal" Condition="'$(BundledNETCorePlatformsPackageVersion.Substring(0,1))' == '6'" Version="[6.0.1, )" IsImplicitlyDefined="true" />
</ItemGroup>

<!--
Expand Down
2 changes: 1 addition & 1 deletion tests/common/shared-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NUnitLite" Version="3.12.0" />
<PackageReference Include="NUnitLite" Version="3.12.0" Condition="'$(ExcludeNUnitLiteReference)' != 'true'" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\..\external\Touch.Unit\Touch.Client\dotnet\$(_PlatformName)\Touch.Client-$(_PlatformName).dotnet.csproj" Condition="'$(ExcludeTouchUnitReference)' != 'true'" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions tests/dotnet/CentralPackageVersionsApp/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
<PropertyGroup>
<TargetFramework>net6.0-maccatalyst</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
2 changes: 2 additions & 0 deletions tests/dotnet/CentralPackageVersionsApp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TOP=../../..
include $(TOP)/tests/common/shared-dotnet-test.mk
5 changes: 5 additions & 0 deletions tests/dotnet/CentralPackageVersionsApp/Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project >
<ItemGroup>
<PackageReference Update="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions tests/dotnet/CentralPackageVersionsApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This test can be removed in .NET 7.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
1 change: 1 addition & 0 deletions tests/dotnet/CentralPackageVersionsApp/iOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
<PropertyGroup>
<TargetFramework>net6.0-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
1 change: 1 addition & 0 deletions tests/dotnet/CentralPackageVersionsApp/macOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
25 changes: 25 additions & 0 deletions tests/dotnet/CentralPackageVersionsApp/shared.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This test can be removed in .NET 7 -->
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>

<ApplicationId>com.xamarin.centralpackageversionsapp</ApplicationId>
<ExcludeNUnitLiteReference>true</ExcludeNUnitLiteReference>
<ExcludeTouchUnitReference>true</ExcludeTouchUnitReference>
</PropertyGroup>

<Import Project="../../common/shared-dotnet.csproj" />

<ItemGroup>
<Compile Include="../*.cs" />
</ItemGroup>

<PropertyGroup>
<CentralPackagesFile>$(MSBuildThisFileDirectory)Packages.props</CentralPackagesFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions tests/dotnet/CentralPackageVersionsApp/shared.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TOP=../../../..
include $(TOP)/tests/common/shared-dotnet.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Microsoft.Build.CentralPackageVersions" Version="2.1.3" />
<PropertyGroup>
<TargetFramework>net6.0-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>
1 change: 1 addition & 0 deletions tests/dotnet/CentralPackageVersionsApp/tvOS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../shared.mk
16 changes: 16 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,5 +873,21 @@ public void OlderCSharpLanguage (ApplePlatform platform, string runtimeIdentifie
properties ["ExcludeTouchUnitReference"] = "true";
DotNet.AssertBuild (project_path, properties);
}

// This test can be removed in .NET 7
[TestCase (ApplePlatform.iOS)]
[TestCase (ApplePlatform.TVOS)]
[TestCase (ApplePlatform.MacCatalyst)]
[TestCase (ApplePlatform.MacOSX)]
public void CentralPackageVersionsApp (ApplePlatform platform)
{
var project = "CentralPackageVersionsApp";
Configuration.IgnoreIfIgnoredPlatform (platform);

var project_path = GetProjectPath (project, platform: platform);
Clean (project_path);
var properties = GetDefaultProperties ();
DotNet.AssertBuild (project_path, properties);
}
}
}

3 comments on commit b8c493c

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Tests passed on macOS Mac Catalina (10.15) ✅

Tests passed

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal PackageReference (#14532)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Tests timed out on macOS M1 - Mac Big Sur (11.5) ❌

Pipeline on Agent
Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal PackageReference (#14532)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

5 tests failed, 229 tests passed.

Failed tests

  • Xtro/.NET: BuildFailure
  • mmptest/macOS/Debug: Failed (Execution failed with exit code 16)
  • MTouch tests/NUnit: Failed (Execution failed with exit code 12)
  • Cecil-based tests/NUnit: Failed (Execution failed with exit code 24)
  • Generator tests/.NET: Failed (Execution failed with exit code 1)

Pipeline on Agent XAMMINI-049.Monterey
Set IsImplicitlyDefined="true" on the System.Runtime.InteropServices.NFloat.Internal PackageReference (#14532)

Please sign in to comment.