Skip to content

Commit a9a5632

Browse files
committed
Add netstandard2.0 to Mac64 platform to support .NET Core
- Build monomac in a submodule - Upgrade test projects to .NET Core 3.1 - Add bundling targets for Mac64 when using .NET Core - Fix issue loading solution in VS 2019 - Allow XamMac projects to load on Windows (still don't compile)
1 parent 737f950 commit a9a5632

23 files changed

+899
-939
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/monomac"]
2+
path = lib/monomac
3+
url = https://github.com/cwensley/monomac.git

build/Common.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
</PropertyGroup>
4545

4646
<ItemGroup>
47-
<Content Include="$(BasePath)LICENSE.txt" PackageCopyToOutput="False" Pack="True" PackagePath="$(PackageLicenseFile)">
47+
<None Include="$(BasePath)LICENSE.txt" PackageCopyToOutput="False" Pack="True" PackagePath="$(PackageLicenseFile)">
4848
<Link>Eto-LICENSE.txt</Link>
49-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
50-
</Content>
49+
</None>
5150
</ItemGroup>
5251

5352

lib/MonoMac64/MonoMac-License.txt

Lines changed: 0 additions & 217 deletions
This file was deleted.

lib/MonoMac64/MonoMac.dll

-5.23 MB
Binary file not shown.

lib/monomac

Submodule monomac added at 3b246bb

src/Eto.Mac/Eto.Mac64.csproj

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net45</TargetFramework>
4+
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
55
<RootNamespace>Eto.Mac</RootNamespace>
66
<DefineConstants>$(DefineConstants);OSX;DESKTOP;MONOMAC;Mac64</DefineConstants>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<DefaultItemExcludes>build\*</DefaultItemExcludes>
9+
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
10+
911
</PropertyGroup>
1012
<PropertyGroup>
1113
<PackageId>Eto.Platform.Mac64</PackageId>
@@ -24,9 +26,6 @@ You can create your own .app bundle to run your app on OS X, without an OS X mac
2426
You do not need to use any of the classes of this assembly (unless customizing the MonoMac functionality of the platform), and should just use the UI controls from the Eto assembly.
2527
</PackageDescription>
2628
</PropertyGroup>
27-
<ItemGroup>
28-
<Reference Include="..\..\lib\MonoMac64\MonoMac.dll" />
29-
</ItemGroup>
3029
<ItemGroup>
3130
<Compile Include="..\Shared\PlatformDetect.cs">
3231
<Link>PlatformDetect.cs</Link>
@@ -47,18 +46,24 @@ You do not need to use any of the classes of this assembly (unless customizing t
4746

4847
<ItemGroup>
4948
<ProjectReference Include="..\Eto\Eto.csproj" />
49+
<ProjectReference Include="..\..\lib\monomac\src\MonoMac.csproj" PrivateAssets="all" Pack="True" />
5050
</ItemGroup>
5151

5252
<ItemGroup>
53-
<Content Include="..\..\lib\MonoMac64\MonoMac-License.txt" Pack="True" PackagePath="MonoMac-License.txt" PackageCopyToOutput="False">
54-
<Link>MonoMac-License.txt</Link>
53+
<Content Include="..\..\lib\monomac\LICENSE.txt" Pack="True" PackagePath="MonoMac-LICENSE.txt" PackageCopyToOutput="False">
54+
<Link>MonoMac-LICENSE.txt</Link>
5555
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
5656
</Content>
57-
<None Include="..\..\lib\MonoMac64\MonoMac.dll" Pack="True" PackagePath="lib\net45" />
5857
<None Include="build\*" Exclude="build\Mac.*" Pack="True" PackagePath="build" />
5958
<None Include="build\Mac.targets" Pack="True" PackagePath="build\$(PackageId).targets" />
6059
<None Include="build\Mac.props" Pack="True" PackagePath="build\$(PackageId).props" />
6160

6261
<None Include="..\..\build\MSBuildTaskHelper.props" Pack="True" PackagePath="build" />
6362
</ItemGroup>
63+
64+
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
65+
<ItemGroup>
66+
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')-&gt;WithMetadataValue('Pack', 'True'))" />
67+
</ItemGroup>
68+
</Target>
6469
</Project>

src/Eto.Mac/Eto.XamMac2.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
<DefineConstants>$(DefineConstants);OSX;DESKTOP;XAMMAC;XAMMAC2;UNIFIED</DefineConstants>
88
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
99
<DefaultItemExcludes>build\*</DefaultItemExcludes>
10-
<LanguageTargets>$(XamarinMacTargetsPath)Xamarin.Mac.CSharp.targets</LanguageTargets>
10+
<LanguageTargets Condition="Exists('$(XamarinMacTargetsPath)Xamarin.Mac.CSharp.targets')">$(XamarinMacTargetsPath)Xamarin.Mac.CSharp.targets</LanguageTargets>
1111
<UseSGen>false</UseSGen>
1212
<AOTMode>None</AOTMode>
1313
<DisableImplicitFrameworkReferences>True</DisableImplicitFrameworkReferences>
14+
<UseXamMacFullFramework Condition="$(TargetFramework) == 'net45'">true</UseXamMacFullFramework>
1415
</PropertyGroup>
1516

1617
<PropertyGroup>
@@ -34,10 +35,6 @@ You do not need to use any of the classes of this assembly (unless customizing t
3435
<PropertyGroup Condition="$(TargetFramework) == 'xamarinmac20'">
3536
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
3637
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
37-
<UseXamMacFullFramework>false</UseXamMacFullFramework>
38-
</PropertyGroup>
39-
<PropertyGroup Condition="$(TargetFramework) == 'net45'">
40-
<UseXamMacFullFramework>true</UseXamMacFullFramework>
4138
</PropertyGroup>
4239

4340
<ItemGroup>

src/Eto.Mac/EtoBundle.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Runtime.InteropServices;
23
#if XAMMAC2
34
using AppKit;
45
using Foundation;
@@ -15,6 +16,19 @@
1516

1617
namespace Eto.Mac
1718
{
19+
static class MarshalDelegates
20+
{
21+
// delegates used for marshalling in .NET Core, as it doesn't support marshalling Func<> or Action<T>
22+
public delegate bool Func_IntPtr_IntPtr_IntPtr_IntPtr_bool(IntPtr arg1, IntPtr arg2, IntPtr arg3, IntPtr arg4);
23+
public delegate void Action_IntPtr_IntPtr_IntPtr(IntPtr arg1, IntPtr arg2, IntPtr arg3);
24+
public delegate bool Func_IntPtr_IntPtr_bool(IntPtr arg1, IntPtr arg2);
25+
public delegate bool Func_IntPtr_IntPtr_IntPtr_bool(IntPtr arg1, IntPtr arg2, IntPtr arg3);
26+
public delegate void Action_IntPtr_IntPtr_CGRect(IntPtr arg1, IntPtr arg2, CGRect arg3);
27+
public delegate void Action_IntPtr_IntPtr(IntPtr arg1, IntPtr arg2);
28+
public delegate NSDragOperation Func_IntPtr_IntPtr_IntPtr_NSDragOperation(IntPtr arg1, IntPtr arg2, IntPtr arg3);
29+
public delegate void Action_IntPtr_IntPtr_CGSize(IntPtr arg1, IntPtr arg2, CGSize arg3);
30+
}
31+
1832
public static class EtoBundle
1933
{
2034

@@ -24,10 +38,11 @@ public static class EtoBundle
2438
public static void Init ()
2539
{
2640
var bundleClass = ObjCExtensions.GetMetaClass ("NSBundle");
27-
bundleClass.AddMethod (selEtoLoadNibNamed, new Func<IntPtr, IntPtr, IntPtr, IntPtr,bool> (EtoLoadNibNamed), "B@:@@");
41+
bundleClass.AddMethod (selEtoLoadNibNamed, EtoLoadNibNamed_Delegate, "B@:@@");
2842
bundleClass.ExchangeMethod (selLoadNibNamed, selEtoLoadNibNamed);
2943
}
30-
44+
45+
static MarshalDelegates.Func_IntPtr_IntPtr_IntPtr_IntPtr_bool EtoLoadNibNamed_Delegate = EtoLoadNibNamed;
3146
static bool EtoLoadNibNamed (IntPtr self, IntPtr sel, IntPtr filePath, IntPtr owner)
3247
{
3348
var str = Messaging.GetNSObject<NSString>(filePath);

0 commit comments

Comments
 (0)