2018-08-01 17:55:06 +03:00
|
|
|
#if !__WATCHOS__
|
2016-05-05 03:14:32 +03:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Drawing;
|
|
|
|
using System.IO;
|
|
|
|
using System.Net;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Security.Cryptography.X509Certificates;
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
using AudioToolbox;
|
|
|
|
using AudioUnit;
|
|
|
|
using CoreMedia;
|
|
|
|
using CoreFoundation;
|
|
|
|
using CoreGraphics;
|
|
|
|
using CoreText;
|
2022-01-19 10:07:06 +03:00
|
|
|
#if NET
|
|
|
|
using CFNetwork;
|
|
|
|
#else
|
2016-05-05 03:14:32 +03:00
|
|
|
using CoreServices;
|
2022-01-19 10:07:06 +03:00
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
using CoreVideo;
|
|
|
|
using Foundation;
|
|
|
|
using ImageIO;
|
|
|
|
using MediaToolbox;
|
|
|
|
using SystemConfiguration;
|
|
|
|
using ObjCRuntime;
|
|
|
|
using Security;
|
2017-02-04 01:09:46 +03:00
|
|
|
using VideoToolbox;
|
2016-05-05 03:14:32 +03:00
|
|
|
using UIKit;
|
2018-07-24 20:05:17 +03:00
|
|
|
using Network;
|
2016-05-05 03:14:32 +03:00
|
|
|
|
2022-01-13 09:18:39 +03:00
|
|
|
#if NET
|
|
|
|
using GColorConversionInfoTriple = CoreGraphics.CGColorConversionInfoTriple;
|
|
|
|
#endif
|
|
|
|
|
2016-05-05 03:14:32 +03:00
|
|
|
namespace Introspection {
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
public class ApiCMAttachmentTest : ApiBaseTest {
|
|
|
|
static Type CMClockType = typeof (CMClock);
|
|
|
|
static Type CMAttachmentInterfaceType = typeof (ICMAttachmentBearer);
|
|
|
|
static Type NativeObjectInterfaceType = typeof (INativeObject);
|
|
|
|
static Type DispatchSourceType = typeof (DispatchSource);
|
|
|
|
// CN=mail.google.com, O=Google Inc, L=Mountain View, S=California, C=US
|
2022-11-07 17:20:26 +03:00
|
|
|
static public byte [] mail_google_com = {
|
2016-05-05 03:14:32 +03:00
|
|
|
0x30, 0x82, 0x03, 0x22, 0x30, 0x82, 0x02, 0x8b, 0xa0, 0x03, 0x02, 0x01,
|
|
|
|
0x02, 0x02, 0x10, 0x2b, 0x9f, 0x7e, 0xe5, 0xca, 0x25, 0xa6, 0x25, 0x14,
|
|
|
|
0x20, 0x47, 0x82, 0x75, 0x3a, 0x9b, 0xb9, 0x30, 0x0d, 0x06, 0x09, 0x2a,
|
|
|
|
0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x4c,
|
|
|
|
0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x5a,
|
|
|
|
0x41, 0x31, 0x25, 0x30, 0x23, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x1c,
|
|
|
|
0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x73, 0x75,
|
|
|
|
0x6c, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x28, 0x50, 0x74, 0x79, 0x29, 0x20,
|
|
|
|
0x4c, 0x74, 0x64, 0x2e, 0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04,
|
|
|
|
0x03, 0x13, 0x0d, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65, 0x20, 0x53, 0x47,
|
|
|
|
0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x31, 0x31, 0x30,
|
|
|
|
0x32, 0x36, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x31,
|
|
|
|
0x33, 0x30, 0x39, 0x33, 0x30, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a,
|
|
|
|
0x30, 0x69, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
|
|
|
0x02, 0x55, 0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x08,
|
|
|
|
0x13, 0x0a, 0x43, 0x61, 0x6c, 0x69, 0x66, 0x6f, 0x72, 0x6e, 0x69, 0x61,
|
|
|
|
0x31, 0x16, 0x30, 0x14, 0x06, 0x03, 0x55, 0x04, 0x07, 0x14, 0x0d, 0x4d,
|
|
|
|
0x6f, 0x75, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x56, 0x69, 0x65, 0x77,
|
|
|
|
0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x14, 0x0a, 0x47,
|
|
|
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x20, 0x49, 0x6e, 0x63, 0x31, 0x18, 0x30,
|
|
|
|
0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x14, 0x0f, 0x6d, 0x61, 0x69, 0x6c,
|
|
|
|
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30,
|
|
|
|
0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
|
|
|
|
0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, 0x89,
|
|
|
|
0x02, 0x81, 0x81, 0x00, 0xaf, 0x39, 0x15, 0x98, 0x68, 0xe4, 0x92, 0xfe,
|
|
|
|
0x4f, 0x4f, 0xf1, 0xbb, 0xff, 0x0d, 0x2e, 0xb0, 0xfe, 0x25, 0xaa, 0xbd,
|
|
|
|
0x68, 0x04, 0x67, 0x27, 0xea, 0x6c, 0x43, 0x4c, 0xa7, 0x6d, 0xcb, 0xc8,
|
|
|
|
0x8f, 0x7e, 0x81, 0xee, 0x87, 0x26, 0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, 0x63, 0x72, 0x6c, 0x30, 0x28, 0x06,
|
|
|
|
0x03, 0x55, 0x1d, 0x25, 0x04, 0x21, 0x30, 0x1f, 0x06, 0x08, 0x2b, 0x06,
|
|
|
|
0x01, 0x05, 0x05, 0x07, 0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
|
|
|
|
0x05, 0x07, 0x03, 0x02, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8,
|
|
|
|
0x42, 0x04, 0x01, 0x30, 0x72, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
|
|
|
|
0x07, 0x01, 0x01, 0x04, 0x66, 0x30, 0x64, 0x30, 0x22, 0x06, 0x08, 0x2b,
|
|
|
|
0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01, 0x86, 0x16, 0x68, 0x74, 0x74,
|
|
|
|
0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, 0x74, 0x68, 0x61,
|
|
|
|
0x77, 0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x3e, 0x06, 0x08, 0x2b,
|
|
|
|
0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x32, 0x68, 0x74, 0x74,
|
|
|
|
0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x74, 0x68, 0x61, 0x77,
|
|
|
|
0x74, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x65, 0x70, 0x6f, 0x73,
|
|
|
|
0x69, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x54, 0x68, 0x61, 0x77, 0x74, 0x65,
|
|
|
|
0x5f, 0x53, 0x47, 0x43, 0x5f, 0x43, 0x41, 0x2e, 0x63, 0x72, 0x74, 0x30,
|
|
|
|
0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05,
|
|
|
|
0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x35, 0x80, 0x11, 0xcd, 0x52, 0x3e,
|
|
|
|
0x84, 0x29, 0xfb, 0xc1, 0x28, 0xe1, 0x20, 0xe5, 0x02, 0x8f, 0x5f, 0x71,
|
|
|
|
0x65, 0x58, 0x1d, 0x62, 0x72, 0x57, 0x3c, 0xe6, 0x5e, 0x25, 0x61, 0xd3,
|
|
|
|
0xcb, 0xad, 0x22, 0xf8, 0xd8, 0x81, 0xa4, 0xe7, 0xf4, 0xae, 0x7c, 0xd9,
|
|
|
|
0xc1, 0x6d, 0xaa, 0x93, 0x0d, 0x62, 0x07, 0x9f, 0xf2, 0x67, 0x47, 0x99,
|
|
|
|
0x34, 0x33, 0x4f, 0x3d, 0x02, 0x74, 0xf4, 0x81, 0xd6, 0x38, 0x08, 0x21,
|
|
|
|
0xe8, 0xe2, 0xa1, 0xfa, 0x05, 0x41, 0x9c, 0x9c, 0xc9, 0xf9, 0xf3, 0xc8,
|
|
|
|
0xa3, 0xee, 0x0d, 0xa5, 0xd7, 0x50, 0x54, 0x5e, 0x2f, 0x7d, 0x79, 0xb7,
|
|
|
|
0x7e, 0x0a, 0x7c, 0xb6, 0xe2, 0x2c, 0xa8, 0xae, 0xfe, 0x94, 0xd7, 0xcd,
|
|
|
|
0x16, 0x30, 0x71, 0x04, 0xaa, 0x9e, 0x79, 0xc3, 0xd2, 0xb6, 0x24, 0xa7,
|
|
|
|
0x25, 0xab, 0xf0, 0x48, 0x8e, 0x2f, 0xc3, 0xa7, 0xbb, 0x50, 0xdd, 0x0f,
|
|
|
|
0xcf, 0xb0, };
|
2022-11-07 17:20:26 +03:00
|
|
|
|
2016-05-05 03:14:32 +03:00
|
|
|
// copy-pasted from mono/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509Cert20Test.cs
|
2022-11-07 17:20:26 +03:00
|
|
|
static public byte [] farscape_pfx = { 0x30, 0x82, 0x06, 0xA3, 0x02, 0x01, 0x03, 0x30, 0x82, 0x06, 0x63, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x06, 0x54, 0x04, 0x82, 0x06, 0x50, 0x30, 0x82, 0x06, 0x4C, 0x30, 0x82, 0x03, 0x8D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0xA0, 0x82, 0x03, 0x7E, 0x04, 0x82, 0x03, 0x7A, 0x30, 0x82, 0x03, 0x76, 0x30, 0x82, 0x03, 0x72, 0x06, 0x0B, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x0A, 0x01, 0x02, 0xA0, 0x82, 0x02, 0xB6, 0x30, 0x82, 0x02, 0xB2, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01, 0x03, 0x30,
|
|
|
|
0x0E, 0x04, 0x08, 0x67, 0xFE, 0x3A, 0x52, 0x75, 0xF3, 0x82, 0x1F, 0x02, 0x02, 0x07, 0xD0, 0x04, 0x82, 0x02, 0x90, 0x31, 0x6B, 0x00, 0xFA, 0x73, 0xE6, 0x8D, 0x3D, 0x62, 0x93, 0x41, 0xA1, 0x44, 0x04, 0x17, 0x8D, 0x66, 0x7A, 0x75, 0x14, 0x89, 0xA8, 0xD1, 0x4D, 0x2A, 0xD7, 0x20, 0x27, 0x71, 0x58, 0x81, 0x16, 0xB5, 0xA6, 0x41, 0x75, 0x92, 0xB2, 0xF4, 0x0C, 0xAA, 0x9B, 0x00, 0x46, 0x85, 0x85, 0x3B, 0x09, 0x2A, 0x62, 0x33, 0x3F, 0x3D, 0x06, 0xC7, 0xE7, 0x16, 0x0C, 0xA7, 0x1D, 0x9C, 0xDA, 0x9D, 0xD3, 0xC9, 0x05, 0x60, 0xA5, 0xBE, 0xF0, 0x07, 0xD5, 0xA9, 0x4F, 0x8A, 0x80,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 0x0F, 0x88, 0x3F, 0xE2, 0xCB, 0x60, 0xF0, 0x6A, 0xEC, 0xD0, 0xF4, 0x0D, 0x11, 0xC2, 0x84, 0x19, 0x67, 0x52, 0xAD, 0xC0, 0xC0, 0x20, 0x84, 0x6D, 0x7D, 0xEA, 0xD2, 0xF9, 0x3F, 0xE5, 0x58, 0x00, 0xED, 0x24, 0xD6, 0x50, 0x9B, 0x80, 0x80, 0x0A, 0x31, 0x81, 0xA8, 0x30, 0x0D, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x02, 0x31, 0x00, 0x30, 0x13, 0x06, 0x09, 0x2A, 0x86, 0x48,
|
|
|
|
0x86, 0xF7, 0x0D, 0x01, 0x09, 0x15, 0x31, 0x06, 0x04, 0x04, 0x01, 0x00, 0x00, 0x00, 0x30, 0x17, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x14, 0x31, 0x0A, 0x1E, 0x08, 0x00, 0x4D, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x6F, 0x30, 0x69, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x11, 0x01, 0x31, 0x5C, 0x1E, 0x5A, 0x00, 0x4D, 0x00, 0x69, 0x00, 0x63, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x6F, 0x00, 0x66, 0x00, 0x74, 0x00, 0x20, 0x00, 0x52, 0x00, 0x53, 0x00, 0x41, 0x00, 0x20, 0x00, 0x53, 0x00, 0x43, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6E, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x6C,
|
|
|
|
0x00, 0x20, 0x00, 0x43, 0x00, 0x72, 0x00, 0x79, 0x00, 0x70, 0x00, 0x74, 0x00, 0x6F, 0x00, 0x67, 0x00, 0x72, 0x00, 0x61, 0x00, 0x70, 0x00, 0x68, 0x00, 0x69, 0x00, 0x63, 0x00, 0x20, 0x00, 0x50, 0x00, 0x72, 0x00, 0x6F, 0x00, 0x76, 0x00, 0x69, 0x00, 0x64, 0x00, 0x65, 0x00, 0x72, 0x30, 0x82, 0x02, 0xB7, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x06, 0xA0, 0x82, 0x02, 0xA8, 0x30, 0x82, 0x02, 0xA4, 0x02, 0x01, 0x00, 0x30, 0x82, 0x02, 0x9D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x01, 0x30, 0x1C, 0x06, 0x0A, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x0C, 0x01,
|
|
|
|
0x06, 0x30, 0x0E, 0x04, 0x08, 0xB8, 0x22, 0xEA, 0x3C, 0x70, 0x6A, 0xFC, 0x39, 0x02, 0x02, 0x07, 0xD0, 0x80, 0x82, 0x02, 0x70, 0x76, 0xBE, 0x5B, 0xD5, 0x3D, 0x05, 0xC1, 0xDB, 0x10, 0xA3, 0x02, 0xBB, 0x7F, 0x0A, 0x8B, 0x54, 0xC1, 0x7D, 0x19, 0xDA, 0x7E, 0x82, 0xDF, 0xAD, 0x6B, 0x42, 0xC2, 0x95, 0x95, 0x00, 0x6E, 0x82, 0x77, 0xD5, 0x42, 0x6E, 0x21, 0xA2, 0x95, 0xB4, 0x98, 0xF5, 0xDD, 0x18, 0x6F, 0xC4, 0xF3, 0xB6, 0x93, 0xA0, 0x6C, 0xF4, 0x34, 0x7A, 0x48, 0x72, 0x08, 0xB1, 0x28, 0x51, 0x54, 0x10, 0x7F, 0x35, 0xB2, 0xE5, 0x89, 0x5C, 0x0A, 0x14, 0x31, 0x1C, 0x9D, 0xA9, 0xE4, 0x94, 0x91, 0x28, 0x65,
|
|
|
|
0xC4, 0xE7, 0x5E, 0xA9, 0x37, 0x08, 0x3D, 0xB1, 0x16, 0x61, 0x9D, 0xA9, 0x44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04, 0x14, 0xA2, 0xED, 0x05, 0x50, 0x89, 0x91, 0x1D, 0xEB, 0xF6, 0x57, 0x66, 0xAF, 0x70, 0x15, 0xDD, 0x1A, 0xA1, 0x94, 0xB7, 0xB2, 0x04, 0x14, 0x09, 0xE4, 0x0B, 0xEC, 0x1D, 0x93, 0x3E, 0x32, 0x94, 0x6A, 0x95, 0x36, 0xDD, 0xBA, 0x93, 0x9D, 0x75, 0xB6,
|
2016-05-05 03:14:32 +03:00
|
|
|
0x3E, 0xF5 };
|
|
|
|
|
|
|
|
// wrap the object so that we can use the extensions and fail
|
2022-11-07 17:20:26 +03:00
|
|
|
class AttachableNativeObject : ICMAttachmentBearer {
|
2016-05-05 03:14:32 +03:00
|
|
|
INativeObject nativeObj;
|
|
|
|
|
|
|
|
public AttachableNativeObject (INativeObject obj)
|
|
|
|
{
|
2023-05-05 18:52:19 +03:00
|
|
|
if (obj is null)
|
2021-04-13 22:48:20 +03:00
|
|
|
throw new ArgumentNullException ("obj");
|
2016-05-05 03:14:32 +03:00
|
|
|
nativeObj = obj;
|
|
|
|
}
|
|
|
|
|
2021-11-18 11:06:09 +03:00
|
|
|
#if NET
|
|
|
|
public NativeHandle Handle
|
|
|
|
#else
|
2016-05-05 03:14:32 +03:00
|
|
|
public IntPtr Handle
|
2021-11-18 11:06:09 +03:00
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
{
|
|
|
|
get { return nativeObj.Handle; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected virtual bool Skip (Type type)
|
|
|
|
{
|
2019-10-23 23:03:02 +03:00
|
|
|
return SkipNameSpace (type.Namespace) || Skip (type.Name) || SkipDueToAttribute (type);
|
2016-05-05 03:14:32 +03:00
|
|
|
}
|
|
|
|
|
2019-10-23 23:03:02 +03:00
|
|
|
protected virtual bool SkipNameSpace (string nameSpace)
|
|
|
|
{
|
|
|
|
switch (nameSpace) {
|
|
|
|
case "Network": // none of the classes support it and they require a lot of setup to confirm it
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-05 03:14:32 +03:00
|
|
|
protected virtual bool Skip (string nativeName)
|
|
|
|
{
|
|
|
|
if (nativeName.Contains ("`")) {
|
2018-08-29 16:10:03 +03:00
|
|
|
nativeName = nativeName.Substring (0, nativeName.IndexOf ('`'));
|
2016-05-05 03:14:32 +03:00
|
|
|
}
|
2018-08-29 16:10:03 +03:00
|
|
|
if (nativeName.StartsWith ("CGPDF", StringComparison.Ordinal)) // all those types crash the app
|
2016-05-05 03:14:32 +03:00
|
|
|
return true;
|
|
|
|
switch (nativeName) {
|
2019-07-30 11:37:15 +03:00
|
|
|
case "ABRecord": // abstract class
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CFMachPort":
|
|
|
|
case "CFMessagePort":
|
2018-08-02 11:12:34 +03:00
|
|
|
case "DispatchIO": // no way to instantiate it
|
2016-05-05 03:14:32 +03:00
|
|
|
case "DispatchSource":
|
|
|
|
case "AudioConverter": // does crash the tests
|
|
|
|
case "AudioFile": // does crash the tests
|
|
|
|
case "CFHTTPAuthentication":
|
|
|
|
case "CFHTTPStream":
|
2021-10-25 16:19:00 +03:00
|
|
|
case "CFType":
|
2016-05-05 03:14:32 +03:00
|
|
|
case "SystemSound": // does crash the tests
|
|
|
|
case "MusicPlayer": // does crash the tests
|
|
|
|
case "MusicTrack": // does crash the tests
|
|
|
|
case "AUGraph": // does crash the tests
|
|
|
|
case "CGFunction":
|
|
|
|
case "CGShading":
|
|
|
|
case "CVMetalTexture":
|
|
|
|
case "CVMetalTextureCache":
|
|
|
|
case "CTRun":
|
|
|
|
case "CTRunDelegate":
|
|
|
|
case "CGImageMetadata":
|
|
|
|
case "SecKeyChain": // static class
|
|
|
|
case "VTDecompressionSession":
|
|
|
|
case "Class": // makes no sense to test
|
|
|
|
case "Selector": // makes no sense to test
|
|
|
|
case "CFRunLoopSource":
|
|
|
|
case "CFRunLoop":
|
|
|
|
case "NSZone":
|
|
|
|
case "MusicSequence": // crashes tests
|
|
|
|
case "AudioBuffers": // crashes tests
|
|
|
|
case "CGContext":
|
|
|
|
case "AudioComponent":
|
|
|
|
case "AudioUnit":
|
|
|
|
case "AURenderEventEnumerator":
|
2018-08-01 17:55:06 +03:00
|
|
|
case "CFPropertyList":
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CGLayer":
|
|
|
|
case "CMFormatDescription":
|
|
|
|
case "CMAudioFormatDescription":
|
|
|
|
case "CMVideoFormatDescription":
|
|
|
|
case "CMBlockBuffer":
|
|
|
|
case "CMSampleBuffer":
|
|
|
|
case "CVBuffer": // DOES support the API, but it has its own version and is already in the bindings, so no need ATM
|
|
|
|
case "CVImageBuffer": // same as CVBuffer
|
|
|
|
case "CVPixelBuffer": // same as CVBuffer
|
|
|
|
case "MTAudioProcessingTap":
|
|
|
|
case "Protocol":
|
|
|
|
case "MidiObject": // causes crash
|
|
|
|
case "CMClockOrTimebase":
|
|
|
|
case "MidiClient":
|
|
|
|
case "MidiPort":
|
|
|
|
case "MidiEntity":
|
|
|
|
case "MidiDevice":
|
|
|
|
case "MidiEndpoint":
|
|
|
|
case "ABMultiValue":
|
2016-06-17 13:04:00 +03:00
|
|
|
case "ABMutableMultiValue":
|
2018-07-19 19:08:48 +03:00
|
|
|
case "SecProtocolMetadata": // Read-only object that is surfaced during TLS negotiation callbacks, can not be created from user code.
|
2018-07-23 23:17:12 +03:00
|
|
|
case "SecProtocolOptions": // Read-only object that is surfaced during TLS negotiation callbacks, can not be created from user code.
|
2016-08-19 06:02:42 +03:00
|
|
|
case "ABSource": // not skipped when running on iOS 6.1
|
2022-11-07 17:20:26 +03:00
|
|
|
// type was removed in iOS 10 (and replaced) and never consumed by other API
|
2016-08-17 02:07:01 +03:00
|
|
|
case "CGColorConverter":
|
2019-10-25 00:46:03 +03:00
|
|
|
case "OSLog": // c api, no need to check
|
2016-05-05 03:14:32 +03:00
|
|
|
return true;
|
2021-02-17 21:56:40 +03:00
|
|
|
case "SecIdentity": // hangs with xcode12.5 beta 2 while loading p12 file
|
|
|
|
case "SecIdentity2": // same (dupe logic)
|
2021-08-12 03:05:13 +03:00
|
|
|
case "Authorization":
|
2021-02-17 21:56:40 +03:00
|
|
|
return true;
|
2021-09-16 09:25:29 +03:00
|
|
|
case "VTCompressionSession":
|
|
|
|
case "VTSession":
|
|
|
|
case "VTFrameSilo":
|
|
|
|
case "VTMultiPassStorage":
|
|
|
|
#if __TVOS__
|
|
|
|
// Causes a crash in a background thread.
|
|
|
|
if (Runtime.Arch == Arch.DEVICE)
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
return false;
|
[Metal] Add support for Xcode15. (#19379)
This PR brings all the changes from the new Metal APIs. During the
review pay special attention to the changes done in the Protocols in
order to add tvOS support.
The main problem we have had doing this PR is that tvOS was not done on
time before the NET branching, that left us with a lot of memebers that
were NOT added in tvOS that are abstract on dotnet, which has left use
in a pickle.
Lets use the following code as an example.
Code found before this commit:
```csharp
[Mac (11, 0), iOS (14, 0), NoTV]
[MacCatalyst (14, 0)]
#if NET
[Abstract]
#endif
[Export ("accelerationStructureCommandEncoder")]
IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```
A naive approach would be to add just the tvOS suppor as follows:
```csharp
[Mac (11, 0), iOS (14, 0), TV (16,0)]
[MacCatalyst (14, 0)]
#if NET
[Abstract]
#endif
[Export ("accelerationStructureCommandEncoder")]
IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```
The above change represents and API braking change on the donet tvOS dll
because it adds a new Abstrtact members, so this is no an acceptable
solution.
There is a second naive approach we can take which is as follows:
```csharp
[Mac (11, 0), iOS (14, 0), TV (16,0)]
[MacCatalyst (14, 0)]
#if NET &!TVOS
[Abstract]
#endif
[Export ("accelerationStructureCommandEncoder")]
IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```
Yet again, the naive approach has an issue with it. In this case, all
the extension methods that are generated for tvOS (something the
generator writes when methods are not abstract) will be decorated with
availability attributes for all the other platforms, which is incorrect
and will make developers life worse.
That leaves us with the following approach:
```csharp
#if NET
#if !TVOS
[Mac (11, 0), iOS (14, 0), NoTV, MacCatalyst (14, 0)]
[Abstract]
#else
[NoMac, NoiOS, TV (16,0), NoMacCatalyst]
#endif
#else
[Mac (11, 0), iOS (14, 0), TV (16,0), MacCatalyst (14, 0)]
#endif
[Export ("accelerationStructureCommandEncoder")]
IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```
With the above change, we do not add an abstract method in tvOS and we
only add the tvOS abailabity attribute to the extension methods, and use
NoiOS etc for all the other platforms.
The change had to be done to ALL methods that added tvOS support. The
good news are that our cecil tests and our introspection tests catch the
two naive approaces :)
---------
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-12-13 01:39:56 +03:00
|
|
|
case "MTLIOCompressionContext":
|
|
|
|
return true;
|
2016-05-05 03:14:32 +03:00
|
|
|
default:
|
2022-11-07 17:20:26 +03:00
|
|
|
return false;
|
2016-05-05 03:14:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected INativeObject GetINativeInstance (Type t)
|
|
|
|
{
|
|
|
|
var ctor = t.GetConstructor (Type.EmptyTypes);
|
2023-05-05 18:52:19 +03:00
|
|
|
if ((ctor is not null) && !ctor.IsAbstract)
|
2016-05-05 03:14:32 +03:00
|
|
|
return ctor.Invoke (null) as INativeObject;
|
|
|
|
|
|
|
|
if (!NativeObjectInterfaceType.IsAssignableFrom (t))
|
|
|
|
throw new ArgumentException ("t");
|
|
|
|
switch (t.Name) {
|
|
|
|
case "CFAllocator":
|
|
|
|
return CFAllocator.SystemDefault;
|
2021-07-20 01:10:44 +03:00
|
|
|
case "CFArray":
|
|
|
|
return Runtime.GetINativeObject<CFArray> (new NSArray ().Handle, false);
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CFBundle":
|
|
|
|
var bundles = CFBundle.GetAll ();
|
|
|
|
if (bundles.Length > 0)
|
|
|
|
return bundles [0];
|
|
|
|
else
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance for type {0}.", t.Name));
|
|
|
|
case "CFNotificationCenter":
|
|
|
|
return CFNotificationCenter.Darwin;
|
|
|
|
case "CFReadStream":
|
|
|
|
case "CFStream":
|
|
|
|
CFReadStream readStream;
|
|
|
|
CFWriteStream writeStream;
|
|
|
|
CFStream.CreatePairWithSocketToHost ("www.google.com", 80, out readStream, out writeStream);
|
|
|
|
return readStream;
|
|
|
|
case "CFWriteStream":
|
|
|
|
CFStream.CreatePairWithSocketToHost ("www.google.com", 80, out readStream, out writeStream);
|
|
|
|
return writeStream;
|
|
|
|
case "CFUrl":
|
|
|
|
return CFUrl.FromFile ("/etc");
|
2018-08-01 17:25:40 +03:00
|
|
|
case "CFPropertyList":
|
|
|
|
return CFPropertyList.FromData (NSData.FromString ("<string>data</string>")).PropertyList;
|
2018-08-02 11:12:34 +03:00
|
|
|
case "DispatchData":
|
|
|
|
return DispatchData.FromByteBuffer (new byte [] { 1, 2, 3, 4 });
|
2016-05-05 03:14:32 +03:00
|
|
|
case "AudioFile":
|
|
|
|
var path = Path.GetFullPath ("1.caf");
|
|
|
|
var af = AudioFile.Open (CFUrl.FromFile (path), AudioFilePermission.Read, AudioFileType.CAF);
|
|
|
|
return af;
|
|
|
|
case "CFHTTPMessage":
|
|
|
|
return CFHTTPMessage.CreateEmpty (false);
|
2019-03-06 16:04:17 +03:00
|
|
|
case "CFMutableString":
|
|
|
|
return new CFMutableString ("xamarin");
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CGBitmapContext":
|
2022-11-07 17:20:26 +03:00
|
|
|
byte [] data = new byte [400];
|
2016-05-05 03:14:32 +03:00
|
|
|
using (CGColorSpace space = CGColorSpace.CreateDeviceRGB ()) {
|
|
|
|
return new CGBitmapContext (data, 10, 10, 8, 40, space, CGBitmapFlags.PremultipliedLast);
|
|
|
|
}
|
|
|
|
case "CGContextPDF":
|
|
|
|
var filename = Environment.GetFolderPath (Environment.SpecialFolder.CommonDocuments) + "/t.pdf";
|
|
|
|
using (var url = new NSUrl (filename))
|
|
|
|
return new CGContextPDF (url);
|
2016-08-12 14:45:09 +03:00
|
|
|
case "CGColorConversionInfo":
|
|
|
|
var cci = new GColorConversionInfoTriple () {
|
|
|
|
Space = CGColorSpace.CreateGenericRgb (),
|
|
|
|
Intent = CGColorRenderingIntent.Default,
|
|
|
|
Transform = CGColorConversionInfoTransformType.ApplySpace
|
|
|
|
};
|
|
|
|
return new CGColorConversionInfo ((NSDictionary) null, cci, cci, cci);
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CGDataConsumer":
|
|
|
|
using (NSMutableData destData = new NSMutableData ()) {
|
|
|
|
return new CGDataConsumer (destData);
|
|
|
|
}
|
|
|
|
case "CGDataProvider":
|
2021-04-13 22:48:20 +03:00
|
|
|
#if __MACCATALYST__
|
|
|
|
filename = Path.Combine ("Contents", "Resources", "xamarin1.png");
|
|
|
|
#else
|
2016-05-05 03:14:32 +03:00
|
|
|
filename = "xamarin1.png";
|
2021-04-13 22:48:20 +03:00
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
return new CGDataProvider (filename);
|
|
|
|
case "CGFont":
|
|
|
|
return CGFont.CreateWithFontName ("Courier New");
|
|
|
|
case "CGPattern":
|
|
|
|
return new CGPattern (
|
2022-11-07 17:20:26 +03:00
|
|
|
new RectangleF (0, 0, 16, 16),
|
|
|
|
CGAffineTransform.MakeIdentity (),
|
|
|
|
16, 16,
|
2016-05-05 03:14:32 +03:00
|
|
|
CGPatternTiling.NoDistortion,
|
2022-11-07 17:20:26 +03:00
|
|
|
true,
|
|
|
|
(cgc) => { });
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CMBufferQueue":
|
|
|
|
return CMBufferQueue.CreateUnsorted (2);
|
|
|
|
case "CTFont":
|
|
|
|
CTFontDescriptorAttributes fda = new CTFontDescriptorAttributes () {
|
|
|
|
FamilyName = "Courier",
|
|
|
|
StyleName = "Bold",
|
|
|
|
Size = 16.0f
|
|
|
|
};
|
|
|
|
using (var fd = new CTFontDescriptor (fda))
|
2018-08-29 16:10:03 +03:00
|
|
|
return new CTFont (fd, 10);
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CTFontCollection":
|
|
|
|
return new CTFontCollection (new CTFontCollectionOptions ());
|
|
|
|
case "CTFontDescriptor":
|
|
|
|
fda = new CTFontDescriptorAttributes ();
|
|
|
|
return new CTFontDescriptor (fda);
|
|
|
|
case "CTTextTab":
|
|
|
|
return new CTTextTab (CTTextAlignment.Left, 2);
|
|
|
|
case "CTTypesetter":
|
|
|
|
return new CTTypesetter (new NSAttributedString ("Hello, world",
|
|
|
|
new CTStringAttributes () {
|
2022-11-07 17:20:26 +03:00
|
|
|
ForegroundColorFromContext = true,
|
2016-08-19 06:02:42 +03:00
|
|
|
Font = new CTFont ("ArialMT", 24)
|
2016-05-05 03:14:32 +03:00
|
|
|
}));
|
|
|
|
case "CTFrame":
|
|
|
|
var framesetter = new CTFramesetter (new NSAttributedString ("Hello, world",
|
|
|
|
new CTStringAttributes () {
|
2022-11-07 17:20:26 +03:00
|
|
|
ForegroundColorFromContext = true,
|
2016-08-19 06:02:42 +03:00
|
|
|
Font = new CTFont ("ArialMT", 24)
|
2016-05-05 03:14:32 +03:00
|
|
|
}));
|
|
|
|
var bPath = UIBezierPath.FromRect (new RectangleF (0, 0, 3, 3));
|
|
|
|
return framesetter.GetFrame (new NSRange (0, 0), bPath.CGPath, null);
|
|
|
|
case "CTFramesetter":
|
|
|
|
return new CTFramesetter (new NSAttributedString ("Hello, world",
|
|
|
|
new CTStringAttributes () {
|
2022-11-07 17:20:26 +03:00
|
|
|
ForegroundColorFromContext = true,
|
2016-08-19 06:02:42 +03:00
|
|
|
Font = new CTFont ("ArialMT", 24)
|
2016-05-05 03:14:32 +03:00
|
|
|
}));
|
|
|
|
case "CTGlyphInfo":
|
2019-06-12 07:25:32 +03:00
|
|
|
return new CTGlyphInfo ("copyright", new CTFont ("ArialMY", 24), "Foo");
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CTLine":
|
|
|
|
return new CTLine (new NSAttributedString ("Hello, world",
|
|
|
|
new CTStringAttributes () {
|
2022-11-07 17:20:26 +03:00
|
|
|
ForegroundColorFromContext = true,
|
2016-08-19 06:02:42 +03:00
|
|
|
Font = new CTFont ("ArialMT", 24)
|
2016-05-05 03:14:32 +03:00
|
|
|
}));
|
2022-03-01 00:35:42 +03:00
|
|
|
#if __MACCATALYST__ || __MACOS__
|
|
|
|
case "CGEvent":
|
|
|
|
return new CGEvent ((CGEventSource) null);
|
|
|
|
case "CGEventSource":
|
|
|
|
return new CGEventSource (CGEventSourceStateID.CombinedSession);
|
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CGImageDestination":
|
|
|
|
var storage = new NSMutableData ();
|
|
|
|
return CGImageDestination.Create (new CGDataConsumer (storage), "public.png", 1);
|
|
|
|
case "CGImageMetadataTag":
|
|
|
|
using (NSString name = new NSString ("tagName"))
|
|
|
|
using (var value = new NSString ("value"))
|
|
|
|
return new CGImageMetadataTag (CGImageMetadataTagNamespaces.Exif, CGImageMetadataTagPrefixes.Exif, name, CGImageMetadataType.Default, value);
|
|
|
|
case "CGImageSource":
|
2021-04-13 22:48:20 +03:00
|
|
|
#if __MACCATALYST__
|
|
|
|
filename = Path.Combine ("Contents", "Resources", "xamarin1.png");
|
|
|
|
#else
|
2016-05-05 03:14:32 +03:00
|
|
|
filename = "xamarin1.png";
|
2021-04-13 22:48:20 +03:00
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
return CGImageSource.FromUrl (NSUrl.FromFilename (filename));
|
|
|
|
case "SecPolicy":
|
|
|
|
return SecPolicy.CreateSslPolicy (false, null);
|
|
|
|
case "SecIdentity":
|
|
|
|
using (var options = NSDictionary.FromObjectAndKey (new NSString ("farscape"), SecImportExport.Passphrase)) {
|
2022-11-07 17:20:26 +03:00
|
|
|
NSDictionary [] array;
|
2016-05-05 03:14:32 +03:00
|
|
|
var result = SecImportExport.ImportPkcs12 (farscape_pfx, options, out array);
|
|
|
|
if (result != SecStatusCode.Success)
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance for type {0} due to {1}.", t.Name, result));
|
2021-11-02 09:48:55 +03:00
|
|
|
return Runtime.GetINativeObject<SecIdentity> (array [0].LowlevelObjectForKey (SecImportExport.Identity.Handle), false);
|
2016-05-05 03:14:32 +03:00
|
|
|
}
|
|
|
|
case "SecTrust":
|
|
|
|
X509Certificate x = new X509Certificate (mail_google_com);
|
|
|
|
using (var policy = SecPolicy.CreateSslPolicy (true, "mail.google.com"))
|
|
|
|
return new SecTrust (x, policy);
|
|
|
|
case "SslContext":
|
|
|
|
return new SslContext (SslProtocolSide.Client, SslConnectionType.Stream);
|
|
|
|
case "UIFontFeature":
|
|
|
|
return new UIFontFeature (CTFontFeatureNumberSpacing.Selector.ProportionalNumbers);
|
|
|
|
case "NetworkReachability":
|
|
|
|
return new NetworkReachability (IPAddress.Loopback, null);
|
|
|
|
case "VTCompressionSession":
|
|
|
|
case "VTSession":
|
|
|
|
return VTCompressionSession.Create (1024, 768, CMVideoCodecType.H264, (sourceFrame, status, flags, buffer) => { }, null, (CVPixelBufferAttributes) null);
|
2022-10-13 18:27:15 +03:00
|
|
|
case "VTPixelRotationSession":
|
|
|
|
return VTPixelRotationSession.Create ();
|
|
|
|
case "VTPixelTransferSession":
|
|
|
|
return VTPixelTransferSession.Create ();
|
2016-05-05 03:14:32 +03:00
|
|
|
case "VTFrameSilo":
|
|
|
|
return VTFrameSilo.Create ();
|
|
|
|
case "VTMultiPassStorage":
|
|
|
|
return VTMultiPassStorage.Create ();
|
|
|
|
case "CFString":
|
|
|
|
return new CFString ("test");
|
2019-01-17 20:40:58 +03:00
|
|
|
case "DispatchBlock":
|
|
|
|
return new DispatchBlock (() => { });
|
2016-05-05 03:14:32 +03:00
|
|
|
case "DispatchQueue":
|
|
|
|
return new DispatchQueue ("com.example.subsystem.taskXYZ");
|
|
|
|
case "DispatchGroup":
|
|
|
|
return DispatchGroup.Create ();
|
|
|
|
case "CGColorSpace":
|
2016-08-19 06:02:42 +03:00
|
|
|
return CGColorSpace.CreateDeviceCmyk ();
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CGGradient":
|
2022-11-07 17:20:26 +03:00
|
|
|
CGColor [] cArray = { UIColor.Black.CGColor, UIColor.Clear.CGColor, UIColor.Blue.CGColor };
|
2016-05-05 03:14:32 +03:00
|
|
|
return new CGGradient (null, cArray);
|
|
|
|
case "CGImage":
|
2021-04-13 22:48:20 +03:00
|
|
|
#if __MACCATALYST__
|
|
|
|
filename = Path.Combine ("Contents", "Resources", "xamarin1.png");
|
|
|
|
#else
|
2016-05-05 03:14:32 +03:00
|
|
|
filename = "xamarin1.png";
|
2021-04-13 22:48:20 +03:00
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
using (var dp = new CGDataProvider (filename))
|
|
|
|
return CGImage.FromPNG (dp, null, false, CGColorRenderingIntent.Default);
|
|
|
|
case "CGColor":
|
|
|
|
return UIColor.Black.CGColor;
|
|
|
|
case "CMClock":
|
2020-07-24 15:52:33 +03:00
|
|
|
return CMClock.HostTimeClock;
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CMTimebase":
|
2020-07-24 15:52:33 +03:00
|
|
|
return new CMTimebase (CMClock.HostTimeClock);
|
2016-05-05 03:14:32 +03:00
|
|
|
case "CVPixelBufferPool":
|
|
|
|
return new CVPixelBufferPool (
|
|
|
|
new CVPixelBufferPoolSettings (),
|
|
|
|
new CVPixelBufferAttributes (CVPixelFormatType.CV24RGB, 100, 50)
|
|
|
|
);
|
|
|
|
case "SecCertificate":
|
|
|
|
using (var cdata = NSData.FromArray (mail_google_com))
|
|
|
|
return new SecCertificate (cdata);
|
2018-07-23 23:17:12 +03:00
|
|
|
case "SecCertificate2":
|
|
|
|
using (var cdata = NSData.FromArray (mail_google_com))
|
|
|
|
return new SecCertificate2 (new SecCertificate (cdata));
|
2018-07-26 21:54:09 +03:00
|
|
|
case "SecTrust2":
|
2018-07-27 15:49:07 +03:00
|
|
|
X509Certificate x2 = new X509Certificate (mail_google_com);
|
2018-07-26 21:54:09 +03:00
|
|
|
using (var policy = SecPolicy.CreateSslPolicy (true, "mail.google.com"))
|
2018-07-27 15:49:07 +03:00
|
|
|
return new SecTrust2 (new SecTrust (x2, policy));
|
2018-07-26 21:54:09 +03:00
|
|
|
case "SecIdentity2":
|
|
|
|
using (var options = NSDictionary.FromObjectAndKey (new NSString ("farscape"), SecImportExport.Passphrase)) {
|
2022-11-07 17:20:26 +03:00
|
|
|
NSDictionary [] array;
|
2018-07-26 21:54:09 +03:00
|
|
|
var result = SecImportExport.ImportPkcs12 (farscape_pfx, options, out array);
|
|
|
|
if (result != SecStatusCode.Success)
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance for type {0} due to {1}.", t.Name, result));
|
2021-11-02 09:48:55 +03:00
|
|
|
return new SecIdentity2 (Runtime.GetINativeObject<SecIdentity> (array [0].LowlevelObjectForKey (SecImportExport.Identity.Handle), false));
|
2018-07-26 21:54:09 +03:00
|
|
|
}
|
2022-11-07 17:20:26 +03:00
|
|
|
|
2016-05-05 03:14:32 +03:00
|
|
|
case "SecKey":
|
|
|
|
SecKey private_key;
|
|
|
|
SecKey public_key;
|
|
|
|
using (var record = new SecRecord (SecKind.Key)) {
|
|
|
|
record.KeyType = SecKeyType.RSA;
|
|
|
|
record.KeySizeInBits = 512; // it's not a performance test :)
|
|
|
|
SecKey.GenerateKeyPair (record.ToDictionary (), out public_key, out private_key);
|
|
|
|
return private_key;
|
|
|
|
}
|
|
|
|
case "SecAccessControl":
|
|
|
|
return new SecAccessControl (SecAccessible.WhenPasscodeSetThisDeviceOnly);
|
2021-08-12 03:05:13 +03:00
|
|
|
#if __MACCATALYST__
|
|
|
|
case "Authorization":
|
|
|
|
return Security.Authorization.Create (AuthorizationFlags.Defaults);
|
|
|
|
#endif
|
2016-05-05 03:14:32 +03:00
|
|
|
default:
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance for type {0}.", t.Name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected ICMAttachmentBearer GetInstance (Type t)
|
|
|
|
{
|
|
|
|
if (!CMAttachmentInterfaceType.IsAssignableFrom (t))
|
|
|
|
throw new ArgumentException ("t");
|
|
|
|
switch (t.Name) {
|
|
|
|
case "CMBlockBuffer":
|
|
|
|
CMBlockBufferError bbe;
|
|
|
|
var result = CMBlockBuffer.CreateEmpty (0, CMBlockBufferFlags.AssureMemoryNow, out bbe);
|
|
|
|
if (bbe == CMBlockBufferError.None)
|
|
|
|
return result;
|
|
|
|
else
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance {0}.", bbe.ToString ()));
|
|
|
|
case "CMSampleBuffer":
|
|
|
|
var pixelBuffer = new CVPixelBuffer (20, 10, CVPixelFormatType.CV24RGB);
|
|
|
|
|
|
|
|
CMFormatDescriptionError fde;
|
|
|
|
var desc = CMVideoFormatDescription.CreateForImageBuffer (pixelBuffer, out fde);
|
|
|
|
|
|
|
|
var sampleTiming = new CMSampleTimingInfo ();
|
|
|
|
|
|
|
|
CMSampleBufferError sbe;
|
|
|
|
var sb = CMSampleBuffer.CreateForImageBuffer (pixelBuffer, true, desc, sampleTiming, out sbe);
|
|
|
|
if (sbe == CMSampleBufferError.None)
|
|
|
|
return sb;
|
|
|
|
else
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance {0}.", sbe.ToString ()));
|
|
|
|
default:
|
|
|
|
throw new InvalidOperationException (string.Format ("Could not create the new instance for type {0}.", t.Name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
// test that the tag classes DO support the attachments API.
|
|
|
|
public void CheckAttachments ()
|
|
|
|
{
|
|
|
|
var types = CMClockType.Assembly.GetTypes ()
|
2022-11-07 17:20:26 +03:00
|
|
|
.Where (t => CMAttachmentInterfaceType.IsAssignableFrom (t) && !t.IsInterface);
|
2016-05-05 03:14:32 +03:00
|
|
|
foreach (var t in types) {
|
|
|
|
ICMAttachmentBearer obj = GetInstance (t);
|
|
|
|
if (obj is NSObject)
|
|
|
|
continue;
|
|
|
|
Assert.That (obj.Handle, Is.Not.EqualTo (IntPtr.Zero), t.Name + ".Handle");
|
|
|
|
using (var attch = new CFString ("myAttch")) {
|
|
|
|
var mode = CMAttachmentMode.ShouldNotPropagate;
|
|
|
|
CMAttachmentMode otherMode;
|
|
|
|
obj.SetAttachment ("key", attch, CMAttachmentMode.ShouldNotPropagate);
|
|
|
|
using (var otherAttch = obj.GetAttachment<CFString> ("key", out otherMode)) {
|
|
|
|
obj.RemoveAllAttachments ();
|
|
|
|
Assert.AreEqual (mode, otherMode);
|
|
|
|
Assert.IsNotNull (otherAttch, "For type {0}", t.Name);
|
|
|
|
Assert.AreEqual (attch.ToString (), otherAttch.ToString (), "For type {0}", t.Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (t is IDisposable) {
|
|
|
|
var disposable = obj as IDisposable;
|
|
|
|
disposable.Dispose ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
// test that the classes do not support the attachments API
|
|
|
|
public void CheckFailAttachments ()
|
|
|
|
{
|
|
|
|
// get all tupes that are public, native object but not NSobjects or DispatchSources and that are not interfaces or abstract classes
|
|
|
|
var types = CMClockType.Assembly.GetTypes ()
|
2022-11-07 17:20:26 +03:00
|
|
|
.Where (t => !t.IsNotPublic && !CMAttachmentInterfaceType.IsAssignableFrom (t)
|
2016-05-05 03:14:32 +03:00
|
|
|
&& NativeObjectInterfaceType.IsAssignableFrom (t) && !t.IsSubclassOf (NSObjectType)
|
|
|
|
&& !t.IsSubclassOf (DispatchSourceType) && !t.IsInterface && !t.IsAbstract);
|
|
|
|
foreach (var t in types) {
|
|
|
|
if (Skip (t))
|
2021-04-13 22:48:20 +03:00
|
|
|
continue;
|
|
|
|
var n = GetINativeInstance (t);
|
2023-05-05 18:52:19 +03:00
|
|
|
if (n is null)
|
2021-04-13 22:48:20 +03:00
|
|
|
Assert.Fail ("Could not create instance of '{0}'.", t);
|
|
|
|
var obj = new AttachableNativeObject (n);
|
2016-05-05 03:14:32 +03:00
|
|
|
Assert.That (obj.Handle, Is.Not.EqualTo (IntPtr.Zero), t.Name + ".Handle");
|
|
|
|
using (var attch = new CFString ("myAttch")) {
|
|
|
|
CMAttachmentMode otherMode;
|
|
|
|
obj.SetAttachment ("key", attch, CMAttachmentMode.ShouldNotPropagate);
|
|
|
|
using (var otherAttch = obj.GetAttachment<CFString> ("key", out otherMode)) {
|
|
|
|
obj.RemoveAllAttachments ();
|
|
|
|
Assert.Null (otherAttch, "For type {0}", t.Name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (t is IDisposable) {
|
|
|
|
var disposable = obj as IDisposable;
|
|
|
|
disposable.Dispose ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // !__WATCHOS__
|