Merge remote-tracking branch 'origin/main' into bump-main-in-net7.0-2022-09-15

This commit is contained in:
Rolf Bjarne Kvinge 2022-09-15 09:30:29 +02:00
Родитель 853fc1eb44 40199966b6
Коммит 5a613f7c86
45 изменённых файлов: 618 добавлений и 106 удалений

Просмотреть файл

@ -1795,16 +1795,6 @@ namespace Xamarin.Localization.MSBuild {
}
}
/// <summary>
/// Looks up a localized string similar to Can&apos;t create a binding resource package unless there are native references in the binding project.
/// .
/// </summary>
public static string E7068 {
get {
return ResourceManager.GetString("E7068", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Xamarin.iOS 14+ does not support watchOS 1 apps. Please migrate your project to watchOS 2+..
/// </summary>
@ -2039,6 +2029,33 @@ namespace Xamarin.Localization.MSBuild {
}
}
/// <summary>
/// Looks up a localized string similar to Invalid value &apos;{0}&apos; for the entitlement &apos;{1}&apos; of type &apos;{2}&apos; specified in the CustomEntitlements item group. Expected no value at all..
/// </summary>
public static string E7102 {
get {
return ResourceManager.GetString("E7102", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid value &apos;{0}&apos; for the entitlement &apos;{1}&apos; of type &apos;{2}&apos; specified in the CustomEntitlements item group. Expected &apos;true&apos; or &apos;false&apos;..
/// </summary>
public static string E7103 {
get {
return ResourceManager.GetString("E7103", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unknown type &apos;{0}&apos; for the entitlement &apos;{1}&apos; specified in the CustomEntitlements item group. Expected &apos;Remove&apos;, &apos;Boolean&apos;, &apos;String&apos;, or &apos;StringArray&apos;..
/// </summary>
public static string E7104 {
get {
return ResourceManager.GetString("E7104", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Invalid framework: {0}.
/// </summary>

Просмотреть файл

@ -1239,10 +1239,7 @@
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Can't create a binding resource package unless there are native references in the binding project.
</value>
</data>
<!-- E7068: not in use anymore -->
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ does not support watchOS 1 apps. Please migrate your project to watchOS 2+.</value>
@ -1428,4 +1425,29 @@
<data name="E7101" xml:space="preserve">
<value>Unknown property '{0}' with value '{1}'.</value>
</data>
<data name="E7102" xml:space="preserve">
<value>Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected no value at all.</value>
<comment>
Don't translate: CustomEntitlements (name of option in project file)
</comment>
</data>
<data name="E7103" xml:space="preserve">
<value>Invalid value '{0}' for the entitlement '{1}' of type '{2}' specified in the CustomEntitlements item group. Expected 'true' or 'false'.</value>
<comment>
Don't translate:
* CustomEntitlements (name of option in project file)
* 'true', 'false'
</comment>
</data>
<data name="E7104" xml:space="preserve">
<value>Unknown type '{0}' for the entitlement '{1}' specified in the CustomEntitlements item group. Expected 'Remove', 'Boolean', 'String', or 'StringArray'.</value>
<comment>
Don't translate:
* CustomEntitlements (name of option in project file)
* 'Remove', 'Boolean', 'String', 'StringArray'
</comment>
</data>
</root>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Nastavení: Položka {0} neexistuje.
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Pokud ve vazebním projektu neexistují nativní odkazy, nedá se vytvořit balíček prostředků vazby.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ nepodporuje aplikace watchOS 1. Migrujte projekt na watchOS 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Festlegen: Eintrag "{0}" ist nicht vorhanden.
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Ein Bindungsressourcenpaket kann nur erstellt werden, wenn im Bindungsprojektsystem native Verweise vorhanden sind.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ unterstützt keine Apps für watchOS 1. Migrieren Sie Ihr Projekt zu watchOS 2 +.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Establecer: la entrada, "{0}", no existe.
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>No se puede crear un paquete de recursos de enlace, a menos que haya referencias nativas en el proyecto de enlace.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ no es compatible con las aplicaciones watchOS 1. Migra tu proyecto a watchOS 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Set : l'entrée "{0}" n'existe pas
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Impossible de créer un paquet de ressources de liaison, sauf s'il existe des références natives dans le projet de liaison.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ ne prend pas en charge les applications Watchos 1. Effectuez la migration de votre projet vers Watchos 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Impostazione: la voce "{0}" non esiste
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Non è possibile creare un pacchetto di risorse di binding a meno che nel progetto di binding non siano presenti riferimenti nativi.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ non supporta le app watchOS 1. Eseguire la migrazione del progetto a watchOS 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>設定: エントリ "{0}" が存在しません
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>バインド プロジェクトにネイティブ参照がある場合を除いて、バインド リソース パッケージは作成できません。
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14 以降では watchOS 1 アプリがサポートされていません。プロジェクトを watchOS 2 以降に移行してください。</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>설정: '{0}' 항목이 없음
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>바인딩 프로젝트에 네이티브 참조가 없으면 바인딩 리소스 패키지를 생성할 수 없습니다.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14 이상은 watchOS 1 앱을 지원하지 않습니다. 프로젝트를 watchOS 2 이상으로 마이그레이션하세요.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Ustawianie: wpis („{0}”) nie istnieje
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Nie można utworzyć pakietu zasobów powiązania, chyba że istnieją odwołania natywne w projekcie powiązania.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ nie obsługuje aplikacji systemu watchOS 1. Dokonaj migracji projektu do systemu watchOS 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Configurar: A Entrada, "{0}", Não Existe
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Não é possível criar um pacote de recursos de associação, a menos que haja referências nativas no projeto de associação.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>O Xamarin.iOS 14+ não oferece suporte a aplicativos watchOS 1. Migre seu projeto para watchOS 2.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Задание: запись "{0}" не существует.
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Создание пакета ресурсов привязки возможно, только если в проекте привязки есть собственные ссылки.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ не поддерживает приложения watchOS 1. Перенесите свой проект на watchOS 2+.</value>
</data>

Просмотреть файл

@ -997,10 +997,6 @@
<value>Ayarla: "{0}" Girişi Yok
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>Bağlama projesinde yerel başvurular olmadığı sürece, bağlama kaynak paketi oluşturulamaz.
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ uzantısı watchOS 1 uygulamalarını desteklemiyor. Lütfen projenizi watchOS 2+ sürümüne geçirin.</value>
</data>

Просмотреть файл

@ -995,10 +995,6 @@
</data>
<data name="E7064" xml:space="preserve">
<value>设置: 不存在条目“{0}”
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>除非绑定项目中存在本机引用,否则无法创建绑定资源包。
</value>
</data>
<data name="E7069" xml:space="preserve">

Просмотреть файл

@ -997,10 +997,6 @@
<value>設定: 項目 "{0}" 不存在
</value>
</data>
<data name="E7068" xml:space="preserve">
<value>除非繫結專案中具有原生參考,否則無法建立繫結資源套件。
</value>
</data>
<data name="E7069" xml:space="preserve">
<value>Xamarin.iOS 14+ 不支援 watchOS 1 應用程式。請將您的專案遷移到 watchOS 2+。</value>
</data>

Просмотреть файл

@ -59,6 +59,8 @@ namespace Xamarin.MacDev.Tasks
[Required]
public ITaskItem? CompiledEntitlements { get; set; }
public ITaskItem[] CustomEntitlements { get; set; } = Array.Empty<ITaskItem> ();
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:
// <ItemGroup>
// <CustomEntitlements Include="name.of.entitlement" Type="Boolean" Value="true" /> <!-- value can be 'false' too (case doesn't matter) -->
// <CustomEntitlements Include="name.of.entitlement" Type="String" Value="stringvalue" />
// <CustomEntitlements Include="name.of.entitlement" Type="StringArray" Value="a;b" /> <!-- array of strings, separated by semicolon -->
// <CustomEntitlements Include="name.of.entitlement" Type="StringArray" Value="a😁b" ArraySeparator="😁" /> <!-- array of strings, separated by 😁 -->
// <CustomEntitlements Include="name.of.entitlement" Type="Remove" /> <!-- This will remove the corresponding entitlement -->
// </ItemGroup>
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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -645,12 +645,18 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(_RequireCodeSigning)' == 'true' Or '$(CodesignEntitlements)' != ''"
DependsOnTargets="$(_CompileEntitlementsDependsOn)"
Outputs="$(DeviceSpecificIntermediateOutputPath)Entitlements.xcent">
<!-- Automatically add the 'allow-jit' entitlement for desktop release builds in .NET -->
<ItemGroup Condition="'$(Configuration)' == 'Release' And ('$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst') And '$(UsingAppleNETSdk)' == 'true'">
<!-- We need to compare the result of AnyHaveMetadataValue to 'true', because if it's empty, the return value is not a boolean, it's an empty string -->
<CustomEntitlements Condition="'@(CustomEntitlements->AnyHaveMetadataValue('Identity','com.apple.security.cs.allow-jit'))' != 'true'" Include="com.apple.security.cs.allow-jit" Type="Boolean" Value="true" />
</ItemGroup>
<CompileEntitlements
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AppBundleDir="$(AppBundleDir)"
AppIdentifier="$(_AppIdentifier)"
BundleIdentifier="$(_BundleIdentifier)"
CustomEntitlements="@(CustomEntitlements)"
Entitlements="$(CodesignEntitlements)"
CompiledEntitlements="$(DeviceSpecificIntermediateOutputPath)Entitlements.xcent"
IsAppExtension="$(IsAppExtension)"

Просмотреть файл

@ -61,13 +61,25 @@ namespace CoreMedia {
struct CMBufferCallbacks {
internal uint version;
internal IntPtr refcon;
#if NET
internal unsafe delegate* unmanaged<IntPtr, IntPtr, CMTime> XgetDecodeTimeStamp;
internal unsafe delegate* unmanaged<IntPtr, IntPtr, CMTime> XgetPresentationTimeStamp;
internal unsafe delegate* unmanaged<IntPtr, IntPtr, CMTime> XgetDuration;
internal unsafe delegate* unmanaged<IntPtr, IntPtr, bool> XisDataReady;
internal unsafe delegate* unmanaged<IntPtr, IntPtr, IntPtr, int> 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<IntPtr, IntPtr, nint> 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)
{

Просмотреть файл

@ -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<IntPtr, nuint, IntPtr> Allocate;
public unsafe delegate* unmanaged<IntPtr, IntPtr, nuint, void> 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)
{

Просмотреть файл

@ -139,14 +139,23 @@ namespace CoreMedia {
[DllImport(Constants.CoreMediaLibrary)]
unsafe static extern CMSampleBufferError CMSampleBufferCallForEachSample (
/* CMSampleBufferRef */ IntPtr sbuf,
#if NET
delegate* unmanaged<IntPtr, int, IntPtr, CMSampleBufferError> 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<IntPtr, ulong, void> 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 ();
#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)]

Просмотреть файл

@ -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<IntPtr, IntPtr, void**, void> init;
public /* MTAudioProcessingTapFinalizeCallback */ delegate* unmanaged<IntPtr, void> finalize;
public /* MTAudioProcessingTapPrepareCallback */ delegate* unmanaged<IntPtr, IntPtr, AudioStreamBasicDescription*, void> prepare;
public /* MTAudioProcessingTapUnprepareCallback */ delegate* unmanaged<IntPtr, void> unprepare;
public /* MTAudioProcessingTapProcessCallback */ delegate* unmanaged<IntPtr, IntPtr, MTAudioProcessingTapFlags, IntPtr, IntPtr*, MTAudioProcessingTapFlags*, void> 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<MTAudioProcessingTapFlags> (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<AudioStreamBasicDescription> (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;

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-maccatalyst</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1 @@
include ../shared.mk

Просмотреть файл

@ -0,0 +1,2 @@
TOP=../../..
include $(TOP)/tests/common/shared-dotnet-test.mk

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-ios</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1 @@
include ../shared.mk

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-macos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1 @@
include ../shared.mk

Просмотреть файл

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<OutputType>Exe</OutputType>
<ApplicationId>Entitlements</ApplicationId>
</PropertyGroup>
<Import Project="../../common/shared-dotnet.csproj" />
<ItemGroup>
<Compile Include="../*.cs" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,3 @@
TOP=../../../..
TESTNAME=AutoDetectEntitlements
include $(TOP)/tests/common/shared-dotnet.mk

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net$(BundledNETCoreAppTargetFrameworkVersion)-tvos</TargetFramework>
</PropertyGroup>
<Import Project="..\shared.csproj" />
</Project>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1 @@
include ../shared.mk

Просмотреть файл

@ -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<PBoolean>("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");
}
}
}
}

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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;
}
}
}

Просмотреть файл

@ -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);
});
}

Просмотреть файл

@ -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");
}

Просмотреть файл

@ -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<CustomCompileEntitlements> ();
var task = CreateTask<CustomCompileEntitlements> ();
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<PBoolean> (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<string, string> {
{ "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<string, string> {
{ "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<string, string> {
{ "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<string, string> {
{ "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<string, string> { { "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<PBoolean>(EntitlementKeys.AllowExecutionOfJitCode).Value, "#2");
}
[Test]
public void AllowJit_False ()
{
var customEntitlements = new TaskItem[] {
new TaskItem ("com.apple.security.cs.allow-jit", new Dictionary<string, string> { { "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<PBoolean> (EntitlementKeys.AllowExecutionOfJitCode).Value, "#2");
}
[Test]
public void AllowJit_None ()
{
var customEntitlements = new TaskItem[] {
new TaskItem ("com.apple.security.cs.allow-jit", new Dictionary<string, string> { { "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");
}
}
}

Просмотреть файл

@ -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)