diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs
index 4e41331c3a..e3f50499f1 100644
--- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs
+++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.Designer.cs
@@ -1795,16 +1795,6 @@ namespace Xamarin.Localization.MSBuild {
}
}
- ///
- /// Looks up a localized string similar to Can't create a binding resource package unless there are native references in the binding project.
- /// .
- ///
- public static string E7068 {
- get {
- return ResourceManager.GetString("E7068", resourceCulture);
- }
- }
-
///
/// Looks up a localized string similar to Xamarin.iOS 14+ does not support watchOS 1 apps. Please migrate your project to watchOS 2+..
///
@@ -2039,6 +2029,33 @@ namespace Xamarin.Localization.MSBuild {
}
}
+ ///
+ /// Looks up a localized string similar to Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected no value at all..
+ ///
+ public static string E7102 {
+ get {
+ return ResourceManager.GetString("E7102", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected 'true' or 'false'..
+ ///
+ public static string E7103 {
+ get {
+ return ResourceManager.GetString("E7103", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Unknown type '{0}' for the entitlement '{1}' specified in the CustomEntitlements item group. Expected 'Remove', 'Boolean', 'String', or 'StringArray'..
+ ///
+ public static string E7104 {
+ get {
+ return ResourceManager.GetString("E7104", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Invalid framework: {0}.
///
diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
index 19470b274b..2b1f5c18ec 100644
--- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx
@@ -1239,10 +1239,7 @@
-
- Can't create a binding resource package unless there are native references in the binding project.
-
-
+
Xamarin.iOS 14+ does not support watchOS 1 apps. Please migrate your project to watchOS 2+.
@@ -1428,4 +1425,29 @@
Unknown property '{0}' with value '{1}'.
+
+
+ Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected no value at all.
+
+ Don't translate: CustomEntitlements (name of option in project file)
+
+
+
+
+ Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected 'true' or 'false'.
+
+ Don't translate:
+ * CustomEntitlements (name of option in project file)
+ * 'true', 'false'
+
+
+
+
+ Unknown type '{0}' for the entitlement '{1}' specified in the CustomEntitlements item group. Expected 'Remove', 'Boolean', 'String', or 'StringArray'.
+
+ Don't translate:
+ * CustomEntitlements (name of option in project file)
+ * 'Remove', 'Boolean', 'String', 'StringArray'
+
+
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.cs.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.cs.resx
index 29f314b367..bc4564d1a3 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.cs.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.cs.resx
@@ -997,10 +997,6 @@
Nastavení: Položka {0} neexistuje.
-
- Pokud ve vazebním projektu neexistují nativní odkazy, nedá se vytvořit balíček prostředků vazby.
-
-
Xamarin.iOS 14+ nepodporuje aplikace watchOS 1. Migrujte projekt na watchOS 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.de.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.de.resx
index 8fee5d692a..e66d6d4724 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.de.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.de.resx
@@ -997,10 +997,6 @@
Festlegen: Eintrag "{0}" ist nicht vorhanden.
-
- Ein Bindungsressourcenpaket kann nur erstellt werden, wenn im Bindungsprojektsystem native Verweise vorhanden sind.
-
-
Xamarin.iOS 14+ unterstützt keine Apps für watchOS 1. Migrieren Sie Ihr Projekt zu watchOS 2 +.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.es.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.es.resx
index 468f9f266c..d86ff0d478 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.es.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.es.resx
@@ -997,10 +997,6 @@
Establecer: la entrada, "{0}", no existe.
-
- No se puede crear un paquete de recursos de enlace, a menos que haya referencias nativas en el proyecto de enlace.
-
-
Xamarin.iOS 14+ no es compatible con las aplicaciones watchOS 1. Migra tu proyecto a watchOS 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.fr.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.fr.resx
index d2f6aab74e..2d77d55a38 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.fr.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.fr.resx
@@ -997,10 +997,6 @@
Set : l'entrée "{0}" n'existe pas
-
- Impossible de créer un paquet de ressources de liaison, sauf s'il existe des références natives dans le projet de liaison.
-
-
Xamarin.iOS 14+ ne prend pas en charge les applications Watchos 1. Effectuez la migration de votre projet vers Watchos 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.it.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.it.resx
index 9fad906e45..d4ed65879f 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.it.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.it.resx
@@ -997,10 +997,6 @@
Impostazione: la voce "{0}" non esiste
-
- Non è possibile creare un pacchetto di risorse di binding a meno che nel progetto di binding non siano presenti riferimenti nativi.
-
-
Xamarin.iOS 14+ non supporta le app watchOS 1. Eseguire la migrazione del progetto a watchOS 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ja.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ja.resx
index ec4eaeccb9..760d2c2d89 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ja.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ja.resx
@@ -997,10 +997,6 @@
設定: エントリ "{0}" が存在しません
-
- バインド プロジェクトにネイティブ参照がある場合を除いて、バインド リソース パッケージは作成できません。
-
-
Xamarin.iOS 14 以降では watchOS 1 アプリがサポートされていません。プロジェクトを watchOS 2 以降に移行してください。
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ko.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ko.resx
index b7cb4f07f2..50edf45640 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ko.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ko.resx
@@ -997,10 +997,6 @@
설정: '{0}' 항목이 없음
-
- 바인딩 프로젝트에 네이티브 참조가 없으면 바인딩 리소스 패키지를 생성할 수 없습니다.
-
-
Xamarin.iOS 14 이상은 watchOS 1 앱을 지원하지 않습니다. 프로젝트를 watchOS 2 이상으로 마이그레이션하세요.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pl.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pl.resx
index 6c4588f4fc..fc041f53c3 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pl.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pl.resx
@@ -997,10 +997,6 @@
Ustawianie: wpis („{0}”) nie istnieje
-
- Nie można utworzyć pakietu zasobów powiązania, chyba że istnieją odwołania natywne w projekcie powiązania.
-
-
Xamarin.iOS 14+ nie obsługuje aplikacji systemu watchOS 1. Dokonaj migracji projektu do systemu watchOS 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pt-BR.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pt-BR.resx
index dc56a81500..7fe0be5554 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pt-BR.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.pt-BR.resx
@@ -997,10 +997,6 @@
Configurar: A Entrada, "{0}", Não Existe
-
- Não é possível criar um pacote de recursos de associação, a menos que haja referências nativas no projeto de associação.
-
-
O Xamarin.iOS 14+ não oferece suporte a aplicativos watchOS 1. Migre seu projeto para watchOS 2.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ru.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ru.resx
index fb13b61676..1b43126bff 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ru.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.ru.resx
@@ -997,10 +997,6 @@
Задание: запись "{0}" не существует.
-
- Создание пакета ресурсов привязки возможно, только если в проекте привязки есть собственные ссылки.
-
-
Xamarin.iOS 14+ не поддерживает приложения watchOS 1. Перенесите свой проект на watchOS 2+.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.tr.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.tr.resx
index f72b71754c..17b1687800 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.tr.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.tr.resx
@@ -997,10 +997,6 @@
Ayarla: "{0}" Girişi Yok
-
- Bağlama projesinde yerel başvurular olmadığı sürece, bağlama kaynak paketi oluşturulamaz.
-
-
Xamarin.iOS 14+ uzantısı watchOS 1 uygulamalarını desteklemiyor. Lütfen projenizi watchOS 2+ sürümüne geçirin.
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hans.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hans.resx
index c50cd872da..4f41af8027 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hans.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hans.resx
@@ -995,10 +995,6 @@
设置: 不存在条目“{0}”
-
-
-
- 除非绑定项目中存在本机引用,否则无法创建绑定资源包。
diff --git a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hant.resx b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hant.resx
index 1116e9e359..32569985f3 100644
--- a/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hant.resx
+++ b/msbuild/Xamarin.Localization.MSBuild/TranslatedAssemblies/MSBStrings.zh-Hant.resx
@@ -997,10 +997,6 @@
設定: 項目 "{0}" 不存在
-
- 除非繫結專案中具有原生參考,否則無法建立繫結資源套件。
-
-
Xamarin.iOS 14+ 不支援 watchOS 1 應用程式。請將您的專案遷移到 watchOS 2+。
diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs
index d2fd1648c6..798cd13527 100644
--- a/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs
+++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs
@@ -59,6 +59,8 @@ namespace Xamarin.MacDev.Tasks
[Required]
public ITaskItem? CompiledEntitlements { get; set; }
+ public ITaskItem[] CustomEntitlements { get; set; } = Array.Empty ();
+
public bool Debug { get; set; }
public string Entitlements { get; set; } = string.Empty;
@@ -250,6 +252,64 @@ namespace Xamarin.MacDev.Tasks
return result;
}
+ void AddCustomEntitlements (PDictionary dict)
+ {
+ if (CustomEntitlements is null)
+ return;
+
+ // Process any custom entitlements from the 'CustomEntitlements' item group. These are applied last, and will override anything else.
+ // Possible values:
+ //
+ //
+ //
+ //
+ //
+ //
+ //
+
+ foreach (var item in CustomEntitlements) {
+ var entitlement = item.ItemSpec;
+ var type = item.GetMetadata ("Type");
+ var value = item.GetMetadata ("Value");
+ switch (type.ToLowerInvariant ()) {
+ case "remove":
+ if (!string.IsNullOrEmpty (value))
+ Log.LogError (MSBStrings.E7102, /* Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected no value at all. */ value, entitlement, type);
+ dict.Remove (entitlement);
+ break;
+ case "boolean":
+ bool booleanValue;
+ if (string.Equals (value, "true", StringComparison.OrdinalIgnoreCase)) {
+ booleanValue = true;
+ } else if (string.Equals (value, "false", StringComparison.OrdinalIgnoreCase)) {
+ booleanValue = false;
+ } else {
+ Log.LogError (MSBStrings.E7103, /* "Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected 'true' or 'false'." */ value, entitlement, type);
+ continue;
+ }
+
+ dict [entitlement] = new PBoolean (booleanValue);
+ break;
+ case "string":
+ dict [entitlement] = new PString (value ?? string.Empty);
+ break;
+ case "stringarray":
+ var arraySeparator = item.GetMetadata ("ArraySeparator");
+ if (string.IsNullOrEmpty (arraySeparator))
+ arraySeparator = ";";
+ var arrayContent = value.Split (new string[] { arraySeparator }, StringSplitOptions.None);
+ var parray = new PArray ();
+ foreach (var element in arrayContent)
+ parray.Add (new PString (element));
+ dict [entitlement] = parray;
+ break;
+ default:
+ Log.LogError (MSBStrings.E7104, /* "Unknown type '{0}' for the entitlement '{1}' specified in the CustomEntitlements item group. Expected 'Remove', 'Boolean', 'String', or 'StringArray'." */ type, entitlement);
+ break;
+ }
+ }
+ }
+
static bool AreEqual (byte[] x, byte[] y)
{
if (x.Length != y.Length)
@@ -356,6 +416,8 @@ namespace Xamarin.MacDev.Tasks
break;
}
+ AddCustomEntitlements (entitlements);
+
return entitlements;
}
diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/CreateBindingResourcePackageBase.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/CreateBindingResourcePackageBase.cs
index 324896664c..6eaf4802eb 100644
--- a/msbuild/Xamarin.MacDev.Tasks/Tasks/CreateBindingResourcePackageBase.cs
+++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/CreateBindingResourcePackageBase.cs
@@ -32,10 +32,9 @@ namespace Xamarin.MacDev.Tasks {
public override bool Execute ()
{
- // LinkWith must be migrated for NoBindingEmbedding styled binding projects
if (NativeReferences.Length == 0) {
- Log.LogError (7068, null, MSBStrings.E7068);
- return false;
+ // Nothing to do here
+ return true;
}
var compress = false;
diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets
index abc2d96e83..b223b541d6 100644
--- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets
+++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets
@@ -645,12 +645,18 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(_RequireCodeSigning)' == 'true' Or '$(CodesignEntitlements)' != ''"
DependsOnTargets="$(_CompileEntitlementsDependsOn)"
Outputs="$(DeviceSpecificIntermediateOutputPath)Entitlements.xcent">
+
+
+
+
+
XgetDecodeTimeStamp;
+ internal unsafe delegate* unmanaged XgetPresentationTimeStamp;
+ internal unsafe delegate* unmanaged XgetDuration;
+ internal unsafe delegate* unmanaged XisDataReady;
+ internal unsafe delegate* unmanaged Xcompare;
+#else
internal BufferGetTimeCallback? XgetDecodeTimeStamp;
internal BufferGetTimeCallback? XgetPresentationTimeStamp;
internal BufferGetTimeCallback? XgetDuration;
internal BufferGetBooleanCallback? XisDataReady;
internal BufferCompareCallback? Xcompare;
+#endif
internal IntPtr cfStringPtr_dataBecameReadyNotification;
+#if NET
+ internal unsafe delegate* unmanaged XgetSize;
+#else
internal BufferGetSizeCallback? XgetSize;
+#endif
}
// A version with no delegates, just native pointers
@@ -124,17 +136,34 @@ namespace CoreMedia {
CMBufferGetBool? isDataReady, CMBufferCompare? compare, NSString dataBecameReadyNotification, CMBufferGetSize? getTotalSize)
{
var bq = new CMBufferQueue (count);
+#if NET
+ CMBufferCallbacks cbacks;
+ unsafe {
+ cbacks = new CMBufferCallbacks () {
+ version = (uint) (getTotalSize is null ? 0 : 1),
+ refcon = GCHandle.ToIntPtr (bq.gch),
+ XgetDecodeTimeStamp = getDecodeTimeStamp is not null ? &GetDecodeTimeStamp : null,
+ XgetPresentationTimeStamp = getPresentationTimeStamp is not null ? &GetPresentationTimeStamp : null,
+ XgetDuration = getDuration is not null ? &GetDuration : null,
+ XisDataReady = isDataReady is not null ? &GetDataReady : null,
+ Xcompare = compare is not null ? &Compare : null,
+ cfStringPtr_dataBecameReadyNotification = dataBecameReadyNotification is null ? IntPtr.Zero : dataBecameReadyNotification.Handle,
+ XgetSize = getTotalSize is not null ? &GetTotalSize : null
+ };
+ }
+#else
var cbacks = new CMBufferCallbacks () {
version = (uint) (getTotalSize is null ? 0 : 1),
refcon = GCHandle.ToIntPtr (bq.gch),
- XgetDecodeTimeStamp = getDecodeTimeStamp is null ? (BufferGetTimeCallback?) null : GetDecodeTimeStamp,
- XgetPresentationTimeStamp = getPresentationTimeStamp is null ? (BufferGetTimeCallback?) null : GetPresentationTimeStamp,
- XgetDuration = getDuration is null ? (BufferGetTimeCallback?) null : GetDuration,
- XisDataReady = isDataReady is null ? (BufferGetBooleanCallback?) null : GetDataReady,
- Xcompare = compare is null ? (BufferCompareCallback?) null : Compare,
+ XgetDecodeTimeStamp = getDecodeTimeStamp is not null ? GetDecodeTimeStamp : null,
+ XgetPresentationTimeStamp = getPresentationTimeStamp is not null ? GetPresentationTimeStamp : null,
+ XgetDuration = getDuration is not null ? GetDuration : null,
+ XisDataReady = isDataReady is not null ? GetDataReady : null,
+ Xcompare = compare is not null ? Compare : null,
cfStringPtr_dataBecameReadyNotification = dataBecameReadyNotification is null ? IntPtr.Zero : dataBecameReadyNotification.Handle,
- XgetSize = getTotalSize is null ? (BufferGetSizeCallback?) null : GetTotalSize
+ XgetSize = getTotalSize is not null ? GetTotalSize : null
};
+#endif
bq.getDecodeTimeStamp = getDecodeTimeStamp;
bq.getPresentationTimeStamp = getPresentationTimeStamp;
@@ -322,8 +351,12 @@ namespace CoreMedia {
return queueObjects [v];
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferGetTimeCallback))]
+#endif
#endif
static CMTime GetDecodeTimeStamp (IntPtr buffer, IntPtr refcon)
{
@@ -333,8 +366,12 @@ namespace CoreMedia {
return queue.getDecodeTimeStamp (queue.Surface (buffer));
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferGetTimeCallback))]
+#endif
#endif
static CMTime GetPresentationTimeStamp (IntPtr buffer, IntPtr refcon)
{
@@ -344,8 +381,12 @@ namespace CoreMedia {
return queue.getPresentationTimeStamp (queue.Surface (buffer));
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferGetTimeCallback))]
+#endif
#endif
static CMTime GetDuration (IntPtr buffer, IntPtr refcon)
{
@@ -355,8 +396,12 @@ namespace CoreMedia {
return queue.getDuration (queue.Surface (buffer));
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferGetBooleanCallback))]
+#endif
#endif
static bool GetDataReady (IntPtr buffer, IntPtr refcon)
{
@@ -366,8 +411,12 @@ namespace CoreMedia {
return queue.isDataReady (queue.Surface (buffer));
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferCompareCallback))]
+#endif
#endif
static int Compare (IntPtr buffer1, IntPtr buffer2, IntPtr refcon)
{
@@ -377,8 +426,12 @@ namespace CoreMedia {
return queue.compare (queue.Surface (buffer1), queue.Surface (buffer2));
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (BufferGetSizeCallback))]
+#endif
#endif
static nint GetTotalSize (IntPtr buffer, IntPtr refcon)
{
diff --git a/src/CoreMedia/CMCustomBlockAllocator.cs b/src/CoreMedia/CMCustomBlockAllocator.cs
index 18994c7c23..ded49438cb 100644
--- a/src/CoreMedia/CMCustomBlockAllocator.cs
+++ b/src/CoreMedia/CMCustomBlockAllocator.cs
@@ -35,8 +35,15 @@ namespace CoreMedia {
gch = GCHandle.Alloc (this);
// kCMBlockBufferCustomBlockSourceVersion = 0 <- this is the only and current value
Cblock.Version = 0;
+#if NET
+ unsafe {
+ Cblock.Allocate = &AllocateCallback;
+ Cblock.Free = &FreeCallback;
+ }
+#else
Cblock.Allocate = static_AllocateCallback;
Cblock.Free = static_FreeCallback;
+#endif
Cblock.RefCon = GCHandle.ToIntPtr (gch);
}
@@ -44,20 +51,31 @@ namespace CoreMedia {
[StructLayout (LayoutKind.Sequential, Pack = 4)] // it's 28 bytes (not 32) on 64 bits iOS
internal struct CMBlockBufferCustomBlockSource {
public uint Version;
+#if NET
+ public unsafe delegate* unmanaged Allocate;
+ public unsafe delegate* unmanaged Free;
+#else
public CMAllocateCallback Allocate;
public CMFreeCallback Free;
+#endif
public IntPtr RefCon;
}
internal CMBlockBufferCustomBlockSource Cblock;
+#if !NET
internal delegate IntPtr CMAllocateCallback (/* void* */ IntPtr refCon, /* size_t */ nuint sizeInBytes);
internal delegate void CMFreeCallback (/* void* */ IntPtr refCon, /* void* */ IntPtr doomedMemoryBlock, /* size_t */ nuint sizeInBytes);
static CMAllocateCallback static_AllocateCallback = AllocateCallback;
static CMFreeCallback static_FreeCallback = FreeCallback;
+#endif
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CMAllocateCallback))]
+#endif
#endif
static IntPtr AllocateCallback (IntPtr refCon, nuint sizeInBytes)
{
@@ -72,8 +90,12 @@ namespace CoreMedia {
return Marshal.AllocHGlobal ((int)sizeInBytes);
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CMFreeCallback))]
+#endif
#endif
static void FreeCallback (IntPtr refCon, IntPtr doomedMemoryBlock, nuint sizeInBytes)
{
diff --git a/src/CoreMedia/CMSampleBuffer.cs b/src/CoreMedia/CMSampleBuffer.cs
index ea535461d4..61b2951cd3 100644
--- a/src/CoreMedia/CMSampleBuffer.cs
+++ b/src/CoreMedia/CMSampleBuffer.cs
@@ -139,14 +139,23 @@ namespace CoreMedia {
[DllImport(Constants.CoreMediaLibrary)]
unsafe static extern CMSampleBufferError CMSampleBufferCallForEachSample (
/* CMSampleBufferRef */ IntPtr sbuf,
+#if NET
+ delegate* unmanaged callback,
+#else
CMSampleBufferCallForEachSampleCallback callback,
+#endif
/* void* */ IntPtr refcon);
-
+#if !NET
delegate CMSampleBufferError CMSampleBufferCallForEachSampleCallback (/* CMSampleBufferRef */ IntPtr
sampleBuffer, int index, /* void* */ IntPtr refcon);
+#endif
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CMSampleBufferCallForEachSampleCallback))]
+#endif
#endif
static CMSampleBufferError ForEachSampleHandler (IntPtr sbuf, int index, IntPtr refCon)
{
@@ -165,7 +174,13 @@ namespace CoreMedia {
GCHandle h = GCHandle.Alloc (Tuple.Create (callback, this));
try {
+#if NET
+ unsafe {
+ return CMSampleBufferCallForEachSample (Handle, &ForEachSampleHandler, (IntPtr) h);
+ }
+#else
return CMSampleBufferCallForEachSample (Handle, ForEachSampleHandler, (IntPtr) h);
+#endif
} finally {
h.Free ();
}
@@ -586,18 +601,32 @@ namespace CoreMedia {
// however there was already a similar call that we did not bound (not sure why)
// and can provide the same feature (since iOS 4 not 8.0)
[DllImport(Constants.CoreMediaLibrary)]
+#if NET
+ extern unsafe static /* OSStatus */ CMSampleBufferError CMSampleBufferSetInvalidateCallback (
+#else
extern static /* OSStatus */ CMSampleBufferError CMSampleBufferSetInvalidateCallback (
+#endif
/* CMSampleBufferRef */ IntPtr sbuf,
+#if NET
+ delegate* unmanaged invalidateCallback,
+#else
/* CMSampleBufferInvalidateCallback */ CMSampleBufferInvalidateCallback? invalidateCallback,
+#endif
/* uint64_t */ ulong invalidateRefCon);
+#if !NET
delegate void CMSampleBufferInvalidateCallback (/* CMSampleBufferRef */ IntPtr sbuf,
/* uint64_t */ ulong invalidateRefCon);
static CMSampleBufferInvalidateCallback invalidate_handler = InvalidateHandler;
+#endif
+#if NET
+ [UnmanagedCallersOnly]
+#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CMSampleBufferInvalidateCallback))]
+#endif
#endif
static void InvalidateHandler (IntPtr sbuf, ulong invalidateRefCon)
{
@@ -612,8 +641,13 @@ namespace CoreMedia {
if (invalidateHandler is null) {
if (invalidate.IsAllocated)
invalidate.Free ();
-
- return CMSampleBufferSetInvalidateCallback (Handle, null, 0);
+#if NET
+ unsafe {
+#endif
+ return CMSampleBufferSetInvalidateCallback (Handle, null, 0);
+#if NET
+ }
+#endif
}
// only one callback can be assigned - and ObjC does not let you re-assign a different one,
@@ -623,7 +657,13 @@ namespace CoreMedia {
return CMSampleBufferError.RequiredParameterMissing;
invalidate = GCHandle.Alloc (Tuple.Create (invalidateHandler, this));
+#if NET
+ unsafe {
+ return CMSampleBufferSetInvalidateCallback (Handle, &InvalidateHandler, (ulong)(IntPtr)invalidate);
+ }
+#else
return CMSampleBufferSetInvalidateCallback (Handle, invalidate_handler, (ulong)(IntPtr)invalidate);
+#endif
}
[DllImport(Constants.CoreMediaLibrary)]
diff --git a/src/MediaToolbox/MTAudioProcessingTap.cs b/src/MediaToolbox/MTAudioProcessingTap.cs
index 754d8e6042..c42e7c20c0 100644
--- a/src/MediaToolbox/MTAudioProcessingTap.cs
+++ b/src/MediaToolbox/MTAudioProcessingTap.cs
@@ -57,11 +57,19 @@ namespace MediaToolbox
#pragma warning disable 169
/* int */ int version; // kMTAudioProcessingTapCallbacksVersion_0 == 0
public /* void* */ IntPtr clientInfo;
+#if NET
+ public /* MTAudioProcessingTapInitCallback */ delegate* unmanaged init;
+ public /* MTAudioProcessingTapFinalizeCallback */ delegate* unmanaged finalize;
+ public /* MTAudioProcessingTapPrepareCallback */ delegate* unmanaged prepare;
+ public /* MTAudioProcessingTapUnprepareCallback */ delegate* unmanaged unprepare;
+ public /* MTAudioProcessingTapProcessCallback */ delegate* unmanaged process;
+#else
public /* MTAudioProcessingTapInitCallback */ MTAudioProcessingTapInitCallbackProxy init;
public /* MTAudioProcessingTapFinalizeCallback */ Action_IntPtr finalize;
public /* MTAudioProcessingTapPrepareCallback */ MTAudioProcessingTapPrepareCallbackProxy prepare;
public /* MTAudioProcessingTapUnprepareCallback */ Action_IntPtr unprepare;
public /* MTAudioProcessingTapProcessCallback */ MTAudioProcessingTapProcessCallbackProxy process;
+#endif
#pragma warning restore 169
}
@@ -107,6 +115,17 @@ namespace MediaToolbox
var c = new Callbacks ();
unsafe {
+#if NET
+ if (callbacks.Initialize is not null)
+ c.init = &InitializeProxy;
+ if (callbacks.Finalize is not null)
+ c.finalize = &FinalizeProxy;
+ if (callbacks.Prepare is not null)
+ c.prepare = &PrepareProxy;
+ if (callbacks.Unprepare is not null)
+ c.unprepare = &UnprepareProxy;
+ c.process = &ProcessProxy;
+#else
if (callbacks.Initialize is not null)
c.init = InitializeProxy;
if (callbacks.Finalize is not null)
@@ -115,8 +134,9 @@ namespace MediaToolbox
c.prepare = PrepareProxy;
if (callbacks.Unprepare is not null)
c.unprepare = UnprepareProxy;
-
c.process = ProcessProxy;
+#endif
+
}
// a GCHandle is needed because we do not have an handle before calling MTAudioProcessingTapCreate
@@ -177,20 +197,42 @@ namespace MediaToolbox
//
// Proxy callbacks
//
+#if NET
+ [UnmanagedCallersOnly]
+ unsafe static void InitializeProxy (IntPtr tap, IntPtr /*void**/ clientInfo, void** tapStorage)
+#else
[MonoPInvokeCallback (typeof (MTAudioProcessingTapInitCallbackProxy))]
unsafe static void InitializeProxy (IntPtr tap, IntPtr /*void**/ clientInfo, out void* tapStorage)
+#endif
{
+#if NET
+ void *tempTapStorage = null;
+ *tapStorage = tempTapStorage;
+#else
tapStorage = null;
+#endif
// at this stage the handle is not yet known (or part of the `handles` dictionary
// so we track back the managed MTAudioProcessingTap instance from the GCHandle
var apt = (MTAudioProcessingTap?) GCHandle.FromIntPtr (clientInfo).Target;
- if (apt?.callbacks.Initialize is not null)
+ if (apt?.callbacks.Initialize is not null) {
+#if NET
+ apt?.callbacks.Initialize (apt, out tempTapStorage);
+ *tapStorage = tempTapStorage;
+#else
apt?.callbacks.Initialize (apt, out tapStorage);
+#endif
+ }
}
+#if NET
+ [UnmanagedCallersOnly]
+ static unsafe void ProcessProxy (IntPtr tap, IntPtr numberFrames, MTAudioProcessingTapFlags flags,
+ IntPtr bufferList, IntPtr* numberFramesOut, MTAudioProcessingTapFlags* flagsOut)
+#else
[MonoPInvokeCallback (typeof (MTAudioProcessingTapProcessCallbackProxy))]
static void ProcessProxy (IntPtr tap, IntPtr numberFrames, MTAudioProcessingTapFlags flags,
IntPtr bufferList, out IntPtr numberFramesOut, out MTAudioProcessingTapFlags flagsOut)
+#endif
{
// from here we do not have access to `clientInfo` so it's not possible to use the GCHandle to get the
// MTAudioProcessingTap managed instance. Instead we get it from a static Dictionary
@@ -198,15 +240,29 @@ namespace MediaToolbox
MTAudioProcessingTap apt;
lock (handles)
apt = handles [tap];
+#if NET
+ *flagsOut = default (MTAudioProcessingTapFlags);
+ *numberFramesOut = IntPtr.Zero;
+#else
flagsOut = default (MTAudioProcessingTapFlags);
numberFramesOut = IntPtr.Zero;
+#endif
if (apt.callbacks.Processing is not null) {
+#if NET
+ apt.callbacks.Processing (apt, (nint) numberFrames, flags, new AudioBuffers (bufferList), out numberOut, out System.Runtime.CompilerServices.Unsafe.AsRef (flagsOut));
+ *numberFramesOut = (IntPtr) numberOut;
+#else
apt.callbacks.Processing (apt, (nint) numberFrames, flags, new AudioBuffers (bufferList), out numberOut, out flagsOut);
numberFramesOut = (IntPtr) numberOut;
+#endif
}
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
[MonoPInvokeCallback (typeof (Action_IntPtr))]
+#endif
static void FinalizeProxy (IntPtr tap)
{
MTAudioProcessingTap apt;
@@ -215,18 +271,30 @@ namespace MediaToolbox
if (apt.callbacks.Finalize is not null)
apt.callbacks.Finalize (apt);
}
-
+#if NET
+ [UnmanagedCallersOnly]
+ static unsafe void PrepareProxy (IntPtr tap, IntPtr maxFrames, AudioStreamBasicDescription* processingFormat)
+#else
[MonoPInvokeCallback (typeof (MTAudioProcessingTapPrepareCallbackProxy))]
static void PrepareProxy (IntPtr tap, IntPtr maxFrames, ref AudioStreamBasicDescription processingFormat)
+#endif
{
MTAudioProcessingTap apt;
lock (handles)
apt = handles [tap];
if (apt.callbacks.Prepare is not null)
+#if NET
+ apt.callbacks.Prepare (apt, (nint) maxFrames, ref System.Runtime.CompilerServices.Unsafe.AsRef (processingFormat));
+#else
apt.callbacks.Prepare (apt, (nint) maxFrames, ref processingFormat);
+#endif
}
+#if NET
+ [UnmanagedCallersOnly]
+#else
[MonoPInvokeCallback (typeof (Action_IntPtr))]
+#endif
static void UnprepareProxy (IntPtr tap)
{
MTAudioProcessingTap apt;
diff --git a/tests/dotnet/Entitlements/AppDelegate.cs b/tests/dotnet/Entitlements/AppDelegate.cs
new file mode 100644
index 0000000000..24a52b91ba
--- /dev/null
+++ b/tests/dotnet/Entitlements/AppDelegate.cs
@@ -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;
+ }
+ }
+}
diff --git a/tests/dotnet/Entitlements/MacCatalyst/Entitlements.csproj b/tests/dotnet/Entitlements/MacCatalyst/Entitlements.csproj
new file mode 100644
index 0000000000..6b0e2c7731
--- /dev/null
+++ b/tests/dotnet/Entitlements/MacCatalyst/Entitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst
+
+
+
diff --git a/tests/dotnet/Entitlements/MacCatalyst/Entitlements.plist b/tests/dotnet/Entitlements/MacCatalyst/Entitlements.plist
new file mode 100644
index 0000000000..6631ffa6f2
--- /dev/null
+++ b/tests/dotnet/Entitlements/MacCatalyst/Entitlements.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/dotnet/Entitlements/MacCatalyst/Makefile b/tests/dotnet/Entitlements/MacCatalyst/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/Entitlements/MacCatalyst/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/Entitlements/Makefile b/tests/dotnet/Entitlements/Makefile
new file mode 100644
index 0000000000..6affa45ff1
--- /dev/null
+++ b/tests/dotnet/Entitlements/Makefile
@@ -0,0 +1,2 @@
+TOP=../../..
+include $(TOP)/tests/common/shared-dotnet-test.mk
diff --git a/tests/dotnet/Entitlements/iOS/Entitlements.csproj b/tests/dotnet/Entitlements/iOS/Entitlements.csproj
new file mode 100644
index 0000000000..86d408734a
--- /dev/null
+++ b/tests/dotnet/Entitlements/iOS/Entitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-ios
+
+
+
diff --git a/tests/dotnet/Entitlements/iOS/Entitlements.plist b/tests/dotnet/Entitlements/iOS/Entitlements.plist
new file mode 100644
index 0000000000..6631ffa6f2
--- /dev/null
+++ b/tests/dotnet/Entitlements/iOS/Entitlements.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/dotnet/Entitlements/iOS/Makefile b/tests/dotnet/Entitlements/iOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/Entitlements/iOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/Entitlements/macOS/Entitlements.csproj b/tests/dotnet/Entitlements/macOS/Entitlements.csproj
new file mode 100644
index 0000000000..a77287b9ba
--- /dev/null
+++ b/tests/dotnet/Entitlements/macOS/Entitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-macos
+
+
+
diff --git a/tests/dotnet/Entitlements/macOS/Entitlements.plist b/tests/dotnet/Entitlements/macOS/Entitlements.plist
new file mode 100644
index 0000000000..6631ffa6f2
--- /dev/null
+++ b/tests/dotnet/Entitlements/macOS/Entitlements.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/dotnet/Entitlements/macOS/Makefile b/tests/dotnet/Entitlements/macOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/Entitlements/macOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/Entitlements/shared.csproj b/tests/dotnet/Entitlements/shared.csproj
new file mode 100644
index 0000000000..648f2f35c4
--- /dev/null
+++ b/tests/dotnet/Entitlements/shared.csproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ Entitlements
+
+
+
+
+
+
+
+
diff --git a/tests/dotnet/Entitlements/shared.mk b/tests/dotnet/Entitlements/shared.mk
new file mode 100644
index 0000000000..ec2a0d435d
--- /dev/null
+++ b/tests/dotnet/Entitlements/shared.mk
@@ -0,0 +1,3 @@
+TOP=../../../..
+TESTNAME=AutoDetectEntitlements
+include $(TOP)/tests/common/shared-dotnet.mk
diff --git a/tests/dotnet/Entitlements/tvOS/Entitlements.csproj b/tests/dotnet/Entitlements/tvOS/Entitlements.csproj
new file mode 100644
index 0000000000..bd487ddcd8
--- /dev/null
+++ b/tests/dotnet/Entitlements/tvOS/Entitlements.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net$(BundledNETCoreAppTargetFrameworkVersion)-tvos
+
+
+
diff --git a/tests/dotnet/Entitlements/tvOS/Entitlements.plist b/tests/dotnet/Entitlements/tvOS/Entitlements.plist
new file mode 100644
index 0000000000..6631ffa6f2
--- /dev/null
+++ b/tests/dotnet/Entitlements/tvOS/Entitlements.plist
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/tests/dotnet/Entitlements/tvOS/Makefile b/tests/dotnet/Entitlements/tvOS/Makefile
new file mode 100644
index 0000000000..110d078f45
--- /dev/null
+++ b/tests/dotnet/Entitlements/tvOS/Makefile
@@ -0,0 +1 @@
+include ../shared.mk
diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs
index ce1bf14256..bee0b0cc68 100644
--- a/tests/dotnet/UnitTests/ProjectTest.cs
+++ b/tests/dotnet/UnitTests/ProjectTest.cs
@@ -1025,5 +1025,30 @@ namespace Xamarin.Tests {
properties ["AppBundleDir"] = customAppBundleDir;
var result = DotNet.AssertBuild (project_path, properties);
}
+
+ [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64", "Release")]
+ [TestCase (ApplePlatform.MacOSX, "osx-arm64", "Debug")]
+ public void AutoAllowJitEntitlements (ApplePlatform platform, string runtimeIdentifiers, string configuration)
+ {
+ var project = "Entitlements";
+ Configuration.IgnoreIfIgnoredPlatform (platform);
+
+ var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration);
+ Clean (project_path);
+
+ var properties = GetDefaultProperties (runtimeIdentifiers);
+ properties ["Configuration"] = configuration;
+ DotNet.AssertBuild (project_path, properties);
+
+ var executable = GetNativeExecutable (platform, appPath);
+ var foundEntitlements = TryGetEntitlements (executable, out var entitlements);
+ if (configuration == "Release") {
+ Assert.IsTrue (foundEntitlements, "Found in Release");
+ Assert.IsTrue (entitlements!.Get("com.apple.security.cs.allow-jit")?.Value, "Jit Allowed");
+ } else {
+ var jitNotAllowed = !foundEntitlements || !entitlements!.ContainsKey ("com.apple.security.cs.allow-jit");
+ Assert.True (jitNotAllowed, "Jit Not Allowed");
+ }
+ }
}
}
diff --git a/tests/dotnet/UnitTests/TemplateTest.cs b/tests/dotnet/UnitTests/TemplateTest.cs
index eb1fbbec4d..5ea51027cf 100644
--- a/tests/dotnet/UnitTests/TemplateTest.cs
+++ b/tests/dotnet/UnitTests/TemplateTest.cs
@@ -28,13 +28,13 @@ namespace Xamarin.Tests {
new TemplateInfo (ApplePlatform.iOS, "ios"),
new TemplateInfo (ApplePlatform.iOS, "ios-tabbed"),
new TemplateInfo (ApplePlatform.iOS, "ioslib"),
- new TemplateInfo (ApplePlatform.iOS, "iosbinding", false), // Bindings can not build without a native library assigned
+ new TemplateInfo (ApplePlatform.iOS, "iosbinding"),
new TemplateInfo (ApplePlatform.TVOS, "tvos"),
- new TemplateInfo (ApplePlatform.TVOS, "tvosbinding", false), // Bindings can not build without a native library assigned
+ new TemplateInfo (ApplePlatform.TVOS, "tvosbinding"),
new TemplateInfo (ApplePlatform.MacCatalyst, "maccatalyst", execute: true),
- new TemplateInfo (ApplePlatform.MacCatalyst, "maccatalystbinding", false), // Bindings can not build without a native library assigned
+ new TemplateInfo (ApplePlatform.MacCatalyst, "maccatalystbinding"),
new TemplateInfo (ApplePlatform.MacOSX, "macos", execute: true),
- new TemplateInfo (ApplePlatform.MacOSX, "macosbinding", false), // Bindings can not build without a native library assigned
+ new TemplateInfo (ApplePlatform.MacOSX, "macosbinding"),
};
public class TemplateConfig {
diff --git a/tests/dotnet/UnitTests/TestBaseClass.cs b/tests/dotnet/UnitTests/TestBaseClass.cs
index 86cf83539f..9efebfd930 100644
--- a/tests/dotnet/UnitTests/TestBaseClass.cs
+++ b/tests/dotnet/UnitTests/TestBaseClass.cs
@@ -1,9 +1,11 @@
#nullable enable
+using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Mono.Cecil;
+using Xamarin.MacDev;
using Xamarin.Tests;
namespace Xamarin.Tests {
@@ -347,5 +349,25 @@ namespace Xamarin.Tests {
}
return false;
}
+
+ protected bool TryGetEntitlements (string nativeExecutable, [NotNullWhen (true)] out PDictionary? entitlements)
+ {
+ var entitlementsPath = Path.Combine (Cache.CreateTemporaryDirectory (), "EntitlementsInBinary.plist");
+ var args = new string [] {
+ "--display",
+ "--entitlements",
+ entitlementsPath,
+ "--xml",
+ nativeExecutable
+ };
+ var rv = ExecutionHelper.Execute ("codesign", args, out var codesignOutput, TimeSpan.FromSeconds (15));
+ Assert.AreEqual (0, rv, $"'codesign {string.Join (" ", args)}' failed:\n{codesignOutput}");
+ if (File.Exists (entitlementsPath)) {
+ entitlements = PDictionary.FromFile(entitlementsPath);
+ return true;
+ }
+ entitlements = null;
+ return false;
+ }
}
}
diff --git a/tests/mmptest/src/BindingProjectNoEmbeddingTests.cs b/tests/mmptest/src/BindingProjectNoEmbeddingTests.cs
index 20624cbbbd..2196e901b8 100644
--- a/tests/mmptest/src/BindingProjectNoEmbeddingTests.cs
+++ b/tests/mmptest/src/BindingProjectNoEmbeddingTests.cs
@@ -71,8 +71,7 @@ namespace Xamarin.MMP.Tests
projects.Item1.LinkWithName = "SimpleClassDylib.dylib";
- var buildResult = BindingProjectTests.SetupAndBuildBindingProject (projects.Item1, false, shouldFail: true);
- buildResult.Messages.AssertError (7068, "Can't create a binding resource package unless there are native references in the binding project.\n ");
+ BindingProjectTests.SetupAndBuildBindingProject (projects.Item1, false);
});
}
diff --git a/tests/monotouch-test/Security/RecordTest.cs b/tests/monotouch-test/Security/RecordTest.cs
index 94e7613482..f170e67e30 100644
--- a/tests/monotouch-test/Security/RecordTest.cs
+++ b/tests/monotouch-test/Security/RecordTest.cs
@@ -160,7 +160,11 @@ namespace MonoTouchFixtures.Security {
if (!TestRuntime.CheckXcodeVersion (7, 0))
return;
+#if __TVOS__ || __WATCHOS__
+ Assert.That (rec.AuthenticationUI, Is.EqualTo (SecAuthenticationUI.Fail), "AuthenticationUI-get");
+#else
Assert.That (rec.AuthenticationUI, Is.EqualTo (SecAuthenticationUI.NotSet), "AuthenticationUI-get");
+#endif
rec.AuthenticationUI = SecAuthenticationUI.Allow;
Assert.That (rec.AuthenticationUI, Is.EqualTo (SecAuthenticationUI.Allow), "AuthenticationUI-set");
}
diff --git a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs
index dcb0df7474..88767eae0d 100644
--- a/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs
+++ b/tests/msbuild/Xamarin.MacDev.Tasks.Tests/TaskTests/CompileEntitlementsTaskTests.cs
@@ -1,16 +1,20 @@
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Utilities;
+using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Xamarin.iOS.Tasks;
using Xamarin.MacDev;
+#nullable enable
+
namespace Xamarin.MacDev.Tasks
{
class CustomCompileEntitlements : CompileEntitlements
{
- protected override MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid)
+ protected override MobileProvision? GetMobileProvision (MobileProvisionPlatform platform, string uuid)
{
if (File.Exists (ProvisioningProfile))
return MobileProvision.LoadFromFile (ProvisioningProfile);
@@ -22,19 +26,9 @@ namespace Xamarin.MacDev.Tasks
[TestFixture]
public class CompileEntitlementsTaskTests : TestBase
{
- CustomCompileEntitlements task {
- get; set;
- }
-
- string compiledEntitlements {
- get; set;
- }
-
- public override void Setup ()
+ CustomCompileEntitlements CreateEntitlementsTask (out string compiledEntitlements)
{
- base.Setup ();
-
- task = CreateTask ();
+ var task = CreateTask ();
task.AppBundleDir = AppBundlePath;
task.AppIdentifier = "32UV7A8CDE.com.xamarin.MySingleView";
@@ -48,11 +42,14 @@ namespace Xamarin.MacDev.Tasks
task.TargetFrameworkMoniker = "Xamarin.iOS,v1.0";
compiledEntitlements = task.CompiledEntitlements.ItemSpec;
+
+ return task;
}
[Test (Description = "Xambug #46298")]
public void ValidateEntitlement ()
{
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
ExecuteTask (task);
var compiled = PDictionary.FromFile (compiledEntitlements);
Assert.IsTrue (compiled.Get (EntitlementKeys.GetTaskAllow).Value, "#1");
@@ -63,5 +60,146 @@ namespace Xamarin.MacDev.Tasks
Assert.AreEqual ("Z8CSQKJE7R.com.xamarin.MySingleView", compiled.GetUbiquityKeyValueStore (), "#6");
Assert.AreEqual ("32UV7A8CDE.com.xamarin.MySingleView", compiled.GetKeychainAccessGroups ().ToStringArray ().First (), "#7");
}
+
+ [TestCase ("Invalid", null, "Unknown type 'Invalid' for the entitlement 'com.xamarin.custom.entitlement' specified in the CustomEntitlements item group. Expected 'Remove', 'Boolean', 'String', or 'StringArray'.")]
+ [TestCase ("Boolean", null, "Invalid value '' for the entitlement 'com.xamarin.custom.entitlement' of type 'Boolean' specified in the CustomEntitlements item group. Expected 'true' or 'false'.")]
+ [TestCase ("Boolean", "invalid", "Invalid value 'invalid' for the entitlement 'com.xamarin.custom.entitlement' of type 'Boolean' specified in the CustomEntitlements item group. Expected 'true' or 'false'.")]
+ [TestCase ("Remove", "invalid", "Invalid value 'invalid' for the entitlement 'com.xamarin.custom.entitlement' of type 'Remove' specified in the CustomEntitlements item group. Expected no value at all.")]
+ public void InvalidCustomEntitlements (string type, string? value, string errorMessage)
+ {
+ var dict = new Dictionary {
+ { "Type", type }
+ };
+ if (value is not null)
+ dict ["Value"] = value;
+
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.xamarin.custom.entitlement", dict)
+ };
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask (task, expectedErrorCount: 1);
+ Assert.AreEqual (errorMessage, Engine.Logger.ErrorEvents [0].Message, "Error message");
+ }
+
+ [Test]
+ [TestCase ("a-string-value")]
+ [TestCase ("")]
+ [TestCase (null)]
+ public void CustomEntitlemements_String (string value)
+ {
+ var dict = new Dictionary {
+ { "Type", "String" },
+ { "Value", value },
+ };
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.xamarin.custom.entitlement", dict)
+ };
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask (task);
+ var compiled = PDictionary.FromFile (compiledEntitlements);
+ Assert.AreEqual (value ?? string.Empty, compiled.GetString ("com.xamarin.custom.entitlement")?.Value, "#1");
+ }
+
+ [Test]
+ public void CustomEntitlemements_StringArray ()
+ {
+ var dict = new Dictionary {
+ { "Type", "StringArray" },
+ { "Value", "A;B;C" },
+ };
+ var customEntitlements = new TaskItem [] {
+ new TaskItem ("com.xamarin.custom.entitlement", dict)
+ };
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask (task);
+ var compiled = PDictionary.FromFile (compiledEntitlements);
+ var array = compiled.GetArray ("com.xamarin.custom.entitlement");
+ Assert.NotNull (array, "array");
+ Assert.AreEqual (new string [] { "A", "B", "C" }, array.ToStringArray (), "array contents");
+ }
+
+ [Test]
+ [TestCase (",")]
+ [TestCase ("😁")]
+ public void CustomEntitlemements_StringArray_CustomSeparator (string separator)
+ {
+ var dict = new Dictionary {
+ { "Type", "StringArray" },
+ { "Value", $"A;B;C{separator}D{separator}E" },
+ { "ArraySeparator", separator },
+ };
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.xamarin.custom.entitlement", dict)
+ };
+ var task = CreateEntitlementsTask(out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask(task);
+ var compiled = PDictionary.FromFile(compiledEntitlements);
+ var array = compiled.GetArray ("com.xamarin.custom.entitlement");
+ Assert.NotNull (array, "array");
+ Assert.AreEqual (new string [] { "A;B;C", "D", "E" }, array.ToStringArray (), "array contents");
+ }
+
+ [Test]
+ public void AllowJit_Default ()
+ {
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ ExecuteTask (task);
+ var compiled = PDictionary.FromFile (compiledEntitlements);
+ Assert.IsFalse (compiled.ContainsKey (EntitlementKeys.AllowExecutionOfJitCode), "#1");
+ }
+
+ [Test]
+ public void AllowJit_True ()
+ {
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.apple.security.cs.allow-jit", new Dictionary { { "Type", "Boolean" }, { "Value", "true" } }),
+ };
+ var task = CreateEntitlementsTask (out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask (task);
+ var compiled = PDictionary.FromFile(compiledEntitlements);
+ Assert.IsTrue (compiled.ContainsKey (EntitlementKeys.AllowExecutionOfJitCode), "#1");
+ Assert.IsTrue (compiled.Get(EntitlementKeys.AllowExecutionOfJitCode).Value, "#2");
+ }
+
+ [Test]
+ public void AllowJit_False ()
+ {
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.apple.security.cs.allow-jit", new Dictionary { { "Type", "Boolean" }, { "Value", "false" } }),
+ };
+ var task = CreateEntitlementsTask(out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask(task);
+ var compiled = PDictionary.FromFile (compiledEntitlements);
+ Assert.IsTrue (compiled.ContainsKey (EntitlementKeys.AllowExecutionOfJitCode), "#1");
+ Assert.IsFalse (compiled.Get (EntitlementKeys.AllowExecutionOfJitCode).Value, "#2");
+ }
+
+ [Test]
+ public void AllowJit_None ()
+ {
+ var customEntitlements = new TaskItem[] {
+ new TaskItem ("com.apple.security.cs.allow-jit", new Dictionary { { "Type", "Remove" } }),
+ };
+ var task = CreateEntitlementsTask(out var compiledEntitlements);
+ task.TargetFrameworkMoniker = ".NETCoreApp,Version=v6.0,Profile=maccatalyst";
+ task.CustomEntitlements = customEntitlements;
+ ExecuteTask(task);
+ var compiled = PDictionary.FromFile(compiledEntitlements);
+ Assert.IsFalse (compiled.ContainsKey (EntitlementKeys.AllowExecutionOfJitCode), "#1");
+ }
+
}
}
diff --git a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs
index 2d9a1fe246..8ce8b530b2 100644
--- a/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs
+++ b/tests/msbuild/Xamarin.MacDev.Tests/ProjectsTests/NativeReferencesNoEmbedding.cs
@@ -58,12 +58,6 @@ namespace Xamarin.MacDev.Tasks
Assert.True (File.Exists (finalFrameworkPath), $"{finalFrameworkPath} file was not part of bundle?");
}
- // [Test] MISSING_TEST - No LinkWith only projects
- public void DoesNotSupportLinkWith ()
- {
- Assert.Fail ();
- }
-
[TestCase (true)]
// [TestCase (false)] MISSING_TEST - Framework only tests
public void ShouldNotUnnecessarilyRebuildBindingProject (bool framework)