From 7e20a09b28ac41b474f16ca0e9db37cc62535cf7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 9 Sep 2022 17:10:41 +0200 Subject: [PATCH 1/5] [msbuild] Ignore MSB3246 in Xamarin.iOS.Tasks.Windows to avoid a warning about a dll which isn't an assembly. (#15887) --- .../Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj index f9995134ce..3a70fd058e 100644 --- a/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj +++ b/msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.Tasks.Windows.csproj @@ -13,6 +13,7 @@ Nullable $(NoWarn);NU1603 $(NoWarn);NU1701 + $(NoWarn);MSB3246 From b6cdde42807c6ed5c5fedf471feea0ce4441e584 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 9 Sep 2022 17:10:50 +0200 Subject: [PATCH 2/5] [msbuild] Add support for keeping temporary output when looking for AOT compilers. (#15884) --- dotnet/targets/Xamarin.Shared.Sdk.targets | 1 + .../Tasks/FindAotCompilerTaskBase.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 4fc1d1921b..ba1d70d901 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -975,6 +975,7 @@ @@ -72,6 +77,7 @@ namespace Xamarin.MacDev.Tasks { arguments.Add ("/p:OutputFilePath=" + outputFile); arguments.Add ("/p:RuntimeIdentifier=" + RuntimeIdentifier); arguments.Add ("/t:ComputeAotCompilerPath"); + arguments.Add ("/bl:" + binlog); arguments.Add (projectPath); var environment = default (Dictionary); @@ -85,8 +91,16 @@ namespace Xamarin.MacDev.Tasks { ExecuteAsync (executable, arguments, environment: environment).Wait (); return File.ReadAllText (outputFile).Trim (); } finally { - File.Delete (projectPath); - File.Delete (outputFile); + if (KeepTemporaryOutput) { + Log.LogMessage (MessageImportance.Normal, "Temporary files for the FindAotCompiler task:"); + Log.LogMessage (MessageImportance.Normal, $" Project file: {projectPath}"); + Log.LogMessage (MessageImportance.Normal, $" Output file: {outputFile}"); + Log.LogMessage (MessageImportance.Normal, $" Binary log: {binlog}"); + } else { + File.Delete (projectPath); + File.Delete (outputFile); + File.Delete (binlog); + } } } } From 61e8ce443f2e9472d25c8670aead43bee18fe934 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 9 Sep 2022 20:29:37 +0200 Subject: [PATCH 3/5] [tests] Skip SecRecord tests on macOS 11 (#15825) It may hang on the bots. --- tests/monotouch-test/Security/KeyChainTest.cs | 50 ++--- tests/monotouch-test/Security/KeyTest.cs | 20 +- tests/monotouch-test/Security/RecordTest.cs | 194 ++++++++++++------ 3 files changed, 171 insertions(+), 93 deletions(-) diff --git a/tests/monotouch-test/Security/KeyChainTest.cs b/tests/monotouch-test/Security/KeyChainTest.cs index 1aee2bdcd3..7a5407ba41 100644 --- a/tests/monotouch-test/Security/KeyChainTest.cs +++ b/tests/monotouch-test/Security/KeyChainTest.cs @@ -35,9 +35,9 @@ namespace MonoTouchFixtures.Security { #endif NSData data = NSData.FromStream (certStream); - var query = new SecRecord (SecKind.Certificate) { - Label = $"Internet Widgits Pty Ltd", - }; + var query = RecordTest.CreateSecRecord (SecKind.Certificate, + label: $"Internet Widgits Pty Ltd" + ); var rec = query.Clone (); rec.SetValueRef (new SecCertificate (data)); @@ -62,7 +62,7 @@ namespace MonoTouchFixtures.Security { { if (TestRuntime.CheckXcodeVersion (13, 0)) Assert.Ignore ("code == errSecInternal (-26276)"); - using (SecRecord rec = new SecRecord (SecKind.Identity)) + using (var rec = RecordTest.CreateSecRecord (SecKind.Identity)) using (var id = IdentityTest.GetIdentity ()) { rec.SetValueRef (id); SecStatusCode code = SecKeyChain.Add (rec); @@ -72,7 +72,7 @@ namespace MonoTouchFixtures.Security { if (!TestRuntime.CheckXcodeVersion (5, 0)) Assert.Inconclusive ("QueryAsConcreteType does not work before iOS7"); - using (SecRecord rec = new SecRecord (SecKind.Identity)) { + using (var rec = RecordTest.CreateSecRecord (SecKind.Identity)) { SecStatusCode code; var match = SecKeyChain.QueryAsConcreteType (rec, out code); if ((match == null) && (code == SecStatusCode.ItemNotFound)) @@ -148,10 +148,10 @@ namespace MonoTouchFixtures.Security { Guid GetID () { SecStatusCode code; - SecRecord queryRec = new SecRecord (SecKind.GenericPassword) { - Service = RecordService, - Account = RecordAccount, - }; + var queryRec = RecordTest.CreateSecRecord (SecKind.GenericPassword, + service: RecordService, + account: RecordAccount + ); var queryResponse = SecKeyChain.QueryAsRecord (queryRec, out code); if (code == SecStatusCode.Success && queryResponse?.Generic != null) return new Guid (NSString.FromData (queryResponse.Generic, NSStringEncoding.UTF8)); @@ -163,10 +163,10 @@ namespace MonoTouchFixtures.Security { public void QueryAsData () { SecStatusCode code; - SecRecord queryRec = new SecRecord (SecKind.GenericPassword) { - Service = RecordService, - Account = RecordAccount, - }; + var queryRec = RecordTest.CreateSecRecord (SecKind.GenericPassword, + service: RecordService, + account: RecordAccount + ); var data = SecKeyChain.QueryAsData (queryRec, true, out code); if (code == SecStatusCode.Success && queryRec != null) { Assert.NotNull (data.Bytes); @@ -177,10 +177,10 @@ namespace MonoTouchFixtures.Security { public void QueryAsDataArray () { SecStatusCode code; - SecRecord queryRec = new SecRecord (SecKind.GenericPassword) { - Service = RecordService, - Account = RecordAccount, - }; + var queryRec = RecordTest.CreateSecRecord (SecKind.GenericPassword, + service: RecordService, + account: RecordAccount + ); var data = SecKeyChain.QueryAsData (queryRec, true, 1, out code); if (code == SecStatusCode.Success && queryRec != null) { Assert.NotNull (data [0].Bytes); @@ -189,19 +189,19 @@ namespace MonoTouchFixtures.Security { SecStatusCode RemoveID () { - var queryRec = new SecRecord (SecKind.GenericPassword) { - Service = RecordService, - Account = RecordAccount, - }; + var queryRec = RecordTest.CreateSecRecord (SecKind.GenericPassword, + service: RecordService, + account: RecordAccount + ); return SecKeyChain.Remove (queryRec); } SecStatusCode SetID (Guid setID) { - var queryRec = new SecRecord (SecKind.GenericPassword) { - Service = RecordService, - Account = RecordAccount, - }; + var queryRec = RecordTest.CreateSecRecord (SecKind.GenericPassword, + service: RecordService, + account: RecordAccount + ); var record = queryRec.Clone (); record.Generic = NSData.FromString (Convert.ToString (setID), NSStringEncoding.UTF8); record.Accessible = SecAccessible.Always; diff --git a/tests/monotouch-test/Security/KeyTest.cs b/tests/monotouch-test/Security/KeyTest.cs index 32202d4e48..8575b2824b 100644 --- a/tests/monotouch-test/Security/KeyTest.cs +++ b/tests/monotouch-test/Security/KeyTest.cs @@ -51,9 +51,9 @@ namespace MonoTouchFixtures.Security { public static void DeleteKeysWithLabel (string label) { - var query = new SecRecord (SecKind.Key) { - Label = label, - }; + var query = RecordTest.CreateSecRecord (SecKind.Key, + label: label + ); SecStatusCode code; do { // For some reason each call to SecKeyChain will only remove a single key, so do a loop. @@ -118,7 +118,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.RoundtripRSAMinPKCS1-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = MinRsaKeySize; // it's not a performance test :) record.Label = label; @@ -208,7 +208,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.EncryptTooLarge-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = MinRsaKeySize; // it's not a performance test :) record.Label = label; @@ -245,7 +245,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.RoundtripRSA1024OAEP-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = 1024; // it's not a performance test :) record.Label = label; @@ -299,7 +299,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.SignVerifyRSAMinPKCS1SHA1-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = MinRsaKeySize; // it's not a performance test :) record.Label = label; @@ -335,7 +335,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.SignVerifyECSHA1-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.EC; record.KeySizeInBits = 256; // it's not a performance test :) record.Label = label; @@ -371,7 +371,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.GenerateKeyPairTooLargeRSA-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; // maximum documented as 2048, .NET maximum is 16384 record.KeySizeInBits = 16384; @@ -437,7 +437,7 @@ namespace MonoTouchFixtures.Security { var label = $"KeyTest.BenchmarkNative4096-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}"; try { - using (var record = new SecRecord (SecKind.Key)) { + using (var record = RecordTest.CreateSecRecord (SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = 4096; record.Label = label; diff --git a/tests/monotouch-test/Security/RecordTest.cs b/tests/monotouch-test/Security/RecordTest.cs index c020055b77..94e7613482 100644 --- a/tests/monotouch-test/Security/RecordTest.cs +++ b/tests/monotouch-test/Security/RecordTest.cs @@ -5,6 +5,9 @@ using System.Diagnostics; using CoreFoundation; using Foundation; +#if HAS_LOCALAUTHENTICATION +using LocalAuthentication; +#endif using Security; #if MONOMAC using AppKit; @@ -21,13 +24,88 @@ namespace MonoTouchFixtures.Security { [Preserve (AllMembers = true)] public class RecordTest { + static void InitSecRecord (SecRecord rec) + { +#if __MACOS__ + // ignore on macOS 11.* (but not 12+) + if (TestRuntime.CheckXcodeVersion (12, 2) && !TestRuntime.CheckXcodeVersion (13, 0)) + TestRuntime.IgnoreInCI ("Skip on macOS 11.* because it hangs"); +#endif + +#if HAS_LOCALAUTHENTICATION + var context = new LAContext (); + context.InteractionNotAllowed = true; + rec.AuthenticationContext = context; +#else + // This is deprecated, but there's no alternative on tvOS + rec.AuthenticationUI = SecAuthenticationUI.Fail; +#endif + } + + public static SecRecord CreateSecRecord (SecKind kind, string? account = null, NSData? valueData = null, SecAccessible? accessible = null, SecProtocol? protocol = null, string? server = null, SecAuthenticationType? authenticationType = null, string? service = null, string? label = null) + { + var rec = new SecRecord (kind); + InitSecRecord (rec); + + if (account is not null) + rec.Account = account; + + if (valueData is not null) + rec.ValueData = valueData; + + if (accessible is not null) + rec.Accessible = accessible.Value; + + if (protocol is not null) + rec.Protocol = protocol.Value; + + if (server is not null) + rec.Server = server; + + if (authenticationType is not null) + rec.AuthenticationType = authenticationType.Value; + + if (service is not null) + rec.Service = service; + + if (label is not null) + rec.Label = label; + + return rec; + } + + public static SecRecord CreateSecRecord (SecIdentity identity) + { + var rec = new SecRecord (identity); + InitSecRecord (rec); + return rec; + } + + public static SecRecord CreateSecRecord (SecKey key) + { + var rec = new SecRecord (key); + InitSecRecord (rec); + return rec; + } + + public static SecRecord CreateSecRecord (SecCertificate certificate, string? label = null) + { + var rec = new SecRecord (certificate); + InitSecRecord (rec); + + if (label is not null) + rec.Label = label; + + return rec; + } + [Test] public void Identity () { - var rec = new SecRecord (SecKind.Identity) { - Account = "Username", - ValueData = NSData.FromString ("Password"), - }; + var rec = CreateSecRecord (SecKind.Identity, + account: "Username", + valueData: NSData.FromString ("Password") + ); // prior to iOS7 you had to deal without the class using (var dict = rec.ToDictionary ()) { @@ -45,16 +123,16 @@ namespace MonoTouchFixtures.Security { void Accessible (SecAccessible access) { - var rec = new SecRecord (SecKind.GenericPassword) { - Account = "Username" - }; + var rec = CreateSecRecord (SecKind.GenericPassword, + account: "Username" + ); SecKeyChain.Remove (rec); // it might already exists (or not) - rec = new SecRecord (SecKind.GenericPassword) { - Account = "Username", - ValueData = NSData.FromString ("Password"), - Accessible = access - }; + rec = CreateSecRecord (SecKind.GenericPassword, + account: "Username", + valueData: NSData.FromString ("Password"), + accessible: access + ); Assert.That (SecKeyChain.Add (rec), Is.EqualTo (SecStatusCode.Success), "Add"); @@ -68,9 +146,9 @@ namespace MonoTouchFixtures.Security { [Test] public void Match () { - var rec = new SecRecord (SecKind.GenericPassword) { - Account = "Username", - }; + var rec = CreateSecRecord (SecKind.GenericPassword, + account: "Username" + ); Assert.Null (rec.MatchIssuers, "MatchIssuers"); // we do not have a way (except the getter) to craete SecKeyChain instances Assert.Null (rec.MatchItemList, "MatchItemList"); @@ -106,18 +184,18 @@ namespace MonoTouchFixtures.Security { void Protocol (SecProtocol protocol) { - var rec = new SecRecord (SecKind.InternetPassword) { - Account = $"Protocol-{protocol}-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}", - }; + var rec = CreateSecRecord (SecKind.InternetPassword, + account: $"Protocol-{protocol}-{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}" + ); try { SecKeyChain.Remove (rec); // it might already exists (or not) - rec = new SecRecord (SecKind.InternetPassword) { - Account = "Protocol", - ValueData = NSData.FromString ("Password"), - Protocol = protocol, - Server = "www.xamarin.com" - }; + rec = CreateSecRecord (SecKind.InternetPassword, + account: "Protocol", + valueData: NSData.FromString ("Password"), + protocol: protocol, + server: "www.xamarin.com" + ); Assert.That (SecKeyChain.Add (rec), Is.EqualTo (SecStatusCode.Success), "Add"); @@ -173,26 +251,26 @@ namespace MonoTouchFixtures.Security { void AuthenticationType (SecAuthenticationType type) { - var rec = new SecRecord (SecKind.InternetPassword) { - Account = "AuthenticationType" - }; + var rec = CreateSecRecord (SecKind.InternetPassword, + account: "AuthenticationType" + ); SecKeyChain.Remove (rec); // it might already exists (or not) - rec = new SecRecord (SecKind.InternetPassword) { - Account = $"{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}", - ValueData = NSData.FromString ("Password"), - AuthenticationType = type, - Server = "www.xamarin.com" - }; + rec = CreateSecRecord (SecKind.InternetPassword, + account: $"{CFBundle.GetMain ().Identifier}-{GetType ().FullName}-{Process.GetCurrentProcess ().Id}", + valueData: NSData.FromString ("Password"), + authenticationType: type, + server: "www.xamarin.com" + ); try { Assert.That (SecKeyChain.Add (rec), Is.EqualTo (SecStatusCode.Success), "Add"); - var query = new SecRecord (SecKind.InternetPassword) { - Account = rec.Account, - AuthenticationType = rec.AuthenticationType, - Server = rec.Server, - }; + var query = CreateSecRecord (SecKind.InternetPassword, + account: rec.Account, + authenticationType: rec.AuthenticationType, + server: rec.Server + ); SecStatusCode code; var match = SecKeyChain.QueryAsRecord (query, out code); @@ -259,10 +337,10 @@ namespace MonoTouchFixtures.Security { public static string GetUserPassword (string username) { string password = null; - var searchRecord = new SecRecord (SecKind.InternetPassword) { - Server = "Test1", - Account = username.ToLower() - }; + var searchRecord = CreateSecRecord (SecKind.InternetPassword, + server: "Test1", + account: username.ToLower () + ); SecStatusCode code; var record = SecKeyChain.QueryAsRecord(searchRecord, out code); if (code == SecStatusCode.Success && record != null) @@ -273,18 +351,18 @@ namespace MonoTouchFixtures.Security { public static bool SaveUserPassword (string username, string password) { var success = false; - var searchRecord = new SecRecord (SecKind.InternetPassword) { - Server = "Test1", - Account = username.ToLower () - }; + var searchRecord = CreateSecRecord (SecKind.InternetPassword, + server: "Test1", + account: username.ToLower () + ); SecStatusCode queryCode; var record = SecKeyChain.QueryAsRecord (searchRecord, out queryCode); if (queryCode == SecStatusCode.ItemNotFound) { - record = new SecRecord (SecKind.InternetPassword) { - Server = "Test1", - Account = username.ToLower (), - ValueData = NSData.FromString (password) - }; + record = CreateSecRecord (SecKind.InternetPassword, + server: "Test1", + account: username.ToLower (), + valueData: NSData.FromString (password) + ); var addCode = SecKeyChain.Add (record); success = (addCode == SecStatusCode.Success); } @@ -299,10 +377,10 @@ namespace MonoTouchFixtures.Security { public static bool ClearUserPassword (string username) { var success = false; - var searchRecord = new SecRecord (SecKind.InternetPassword) { - Server = "Test1", - Account = username.ToLower () - }; + var searchRecord = CreateSecRecord (SecKind.InternetPassword, + server: "Test1", + account: username.ToLower () + ); SecStatusCode queryCode; var record = SecKeyChain.QueryAsRecord (searchRecord, out queryCode); @@ -325,7 +403,7 @@ namespace MonoTouchFixtures.Security { Assert.Ignore ("code == errSecInternal (-26276)"); using (var identity = IdentityTest.GetIdentity ()) - using (var rec = new SecRecord (identity)) { + using (var rec = CreateSecRecord (identity)) { SecStatusCode code = SecKeyChain.Add (rec); Assert.True (code == SecStatusCode.DuplicateItem || code == SecStatusCode.Success, "Identity added"); @@ -344,7 +422,7 @@ namespace MonoTouchFixtures.Security { { using (var cert = new X509Certificate (CertificateTest.mail_google_com)) using (var sc = new SecCertificate (cert)) - using (var rec = new SecRecord (sc)) { + using (var rec = CreateSecRecord (sc)) { Assert.NotNull (rec, "rec is null"); var ret = rec.GetCertificate (); @@ -368,7 +446,7 @@ namespace MonoTouchFixtures.Security { using (var trust = new SecTrust (cert, policy)) { trust.Evaluate (); using (SecKey pubkey = trust.GetPublicKey ()) - using (var rec = new SecRecord (pubkey)) { + using (var rec = CreateSecRecord (pubkey)) { Assert.NotNull (rec, "rec is null"); var ret = rec.GetKey (); From e84cca8cb6d350890975631d77b06aefc633842f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 12 Sep 2022 10:21:47 +0200 Subject: [PATCH 4/5] [dotnet] Add binding templates for tvOS and macOS. Fixes #15839. (#15921) Fixes https://github.com/xamarin/xamarin-macios/issues/15839. --- .../localize/templatestrings.cs.json | 5 ++ .../localize/templatestrings.de.json | 5 ++ .../localize/templatestrings.en.json | 5 ++ .../localize/templatestrings.es.json | 5 ++ .../localize/templatestrings.fr.json | 5 ++ .../localize/templatestrings.it.json | 5 ++ .../localize/templatestrings.ja.json | 5 ++ .../localize/templatestrings.ko.json | 5 ++ .../localize/templatestrings.pl.json | 5 ++ .../localize/templatestrings.pt-BR.json | 5 ++ .../localize/templatestrings.ru.json | 5 ++ .../localize/templatestrings.tr.json | 5 ++ .../localize/templatestrings.zh-Hans.json | 5 ++ .../localize/templatestrings.zh-Hant.json | 5 ++ .../.template.config/template.json | 19 +++++ .../macosbinding/ApiDefinition.cs | 70 +++++++++++++++++++ .../macosbinding/StructsAndEnums.cs | 4 ++ .../macosbinding/macOSBinding1.csproj | 14 ++++ .../localize/templatestrings.cs.json | 5 ++ .../localize/templatestrings.de.json | 5 ++ .../localize/templatestrings.en.json | 5 ++ .../localize/templatestrings.es.json | 5 ++ .../localize/templatestrings.fr.json | 5 ++ .../localize/templatestrings.it.json | 5 ++ .../localize/templatestrings.ja.json | 5 ++ .../localize/templatestrings.ko.json | 5 ++ .../localize/templatestrings.pl.json | 5 ++ .../localize/templatestrings.pt-BR.json | 5 ++ .../localize/templatestrings.ru.json | 5 ++ .../localize/templatestrings.tr.json | 5 ++ .../localize/templatestrings.zh-Hans.json | 5 ++ .../localize/templatestrings.zh-Hant.json | 5 ++ .../.template.config/template.json | 19 +++++ .../tvosbinding/ApiDefinition.cs | 70 +++++++++++++++++++ .../tvosbinding/StructsAndEnums.cs | 4 ++ .../tvosbinding/tvOSBinding1.csproj | 14 ++++ tests/dotnet/UnitTests/TemplateTest.cs | 2 + 37 files changed, 356 insertions(+) create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.cs.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.de.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.en.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.es.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.fr.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.it.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ja.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ko.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pl.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pt-BR.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ru.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.tr.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hans.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hant.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/template.json create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/ApiDefinition.cs create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/StructsAndEnums.cs create mode 100644 dotnet/Templates/Microsoft.macOS.Templates/macosbinding/macOSBinding1.csproj create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.cs.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.de.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.en.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.es.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.fr.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.it.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ja.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ko.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pl.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pt-BR.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ru.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.tr.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hans.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hant.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/template.json create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/ApiDefinition.cs create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/StructsAndEnums.cs create mode 100644 dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/tvOSBinding1.csproj diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.cs.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.cs.json new file mode 100644 index 0000000000..611aa2e1e3 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.cs.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Projekt pro vytvoření knihovny vazeb .NET pro macOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.de.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.de.json new file mode 100644 index 0000000000..48fde09929 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.de.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Ein Projekt zum Erstellen einer .NET macOS-Bindungsbibliothek" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.en.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.en.json new file mode 100644 index 0000000000..d5342e00c1 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.en.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "A project for creating a .NET macOS binding library" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.es.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.es.json new file mode 100644 index 0000000000..3d2546bb87 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.es.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Proyecto para crear una biblioteca de enlaces de macOS de .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.fr.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.fr.json new file mode 100644 index 0000000000..be23e09609 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.fr.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Projet de création d’une bibliothèque de liaisons .NET macOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.it.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.it.json new file mode 100644 index 0000000000..1071a72e5d --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.it.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Progetto per la creazione di una libreria di binding macOS .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ja.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ja.json new file mode 100644 index 0000000000..3d7d1c58ed --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ja.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": ".NET macOS バインド ライブラリを作成するためのプロジェクト" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ko.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ko.json new file mode 100644 index 0000000000..9b071d15fa --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ko.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": ".NET macOS 바인딩 라이브러리를 만들기 위한 프로젝트" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pl.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pl.json new file mode 100644 index 0000000000..f4bc94d20d --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pl.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Projekt służący do tworzenia biblioteki powiązań platformy .NET 6 dla systemu macOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pt-BR.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pt-BR.json new file mode 100644 index 0000000000..47b986eb0a --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.pt-BR.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Um projeto para criar uma biblioteca de vinculação do macOS .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ru.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ru.json new file mode 100644 index 0000000000..d22d74a57f --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.ru.json @@ -0,0 +1,5 @@ +{ + "author": "Майкрософт", + "name": "macOS Binding Library", + "description": "Проект для создания библиотеки привязок .NET для macOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.tr.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.tr.json new file mode 100644 index 0000000000..3f6bee2d15 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.tr.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "Bir .NET macOS bağlama kitaplığı oluşturmaya yönelik proje" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hans.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hans.json new file mode 100644 index 0000000000..1e1e1fc3bb --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hans.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "用于创建 .NET macOS 绑定库的项目" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hant.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hant.json new file mode 100644 index 0000000000..a81f6a72a2 --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/localize/templatestrings.zh-Hant.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "macOS Binding Library", + "description": "用於建立 .NET 6 macOS 繫結程式庫的專案" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/template.json b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/template.json new file mode 100644 index 0000000000..c5d3d1d39c --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/.template.config/template.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Microsoft", + "classifications": [ "macOS", "Mobile" ], + "identity": "Microsoft.macOS.macOSBinding", + "name": "macOS Binding Library", + "description": "A project for creating a .NET macOS binding library", + "shortName": "macosbinding", + "tags": { + "language": "C#", + "type": "project" + }, + "sourceName": "macOSBinding1", + "preferNameDirectory": true, + "primaryOutputs": [ + { "path": "macOSBinding1.csproj" } + ], + "defaultName": "macOSBinding1" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/ApiDefinition.cs b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/ApiDefinition.cs new file mode 100644 index 0000000000..22ada7ca6f --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/ApiDefinition.cs @@ -0,0 +1,70 @@ +namespace macOSBinding1 +{ + +// The first step to creating a binding is to add your native framework ("MyLibrary.xcframework") +// to the project. +// Open your binding csproj and add a section like this +// +// +// Framework +// +// +// +// +// Once you've added it, you will need to customize it for your specific library: +// - Change the Include to the correct path/name of your library +// - Change Kind to Static (.a) or Framework (.framework/.xcframework) based upon the library kind and extension. +// - Dynamic (.dylib) is a third option but rarely if ever valid, and only on macOS and Mac Catalyst +// - If your library depends on other frameworks, add them inside +// Example: +// +// Framework +// CoreLocation ModelIO +// +// +// Once you've done that, you're ready to move on to binding the API... +// +// Here is where you'd define your API definition for the native Objective-C library. +// +// For example, to bind the following Objective-C class: +// +// @interface Widget : NSObject { +// } +// +// The C# binding would look like this: +// +// [BaseType (typeof (NSObject))] +// interface Widget { +// } +// +// To bind Objective-C properties, such as: +// +// @property (nonatomic, readwrite, assign) CGPoint center; +// +// You would add a property definition in the C# interface like so: +// +// [Export ("center")] +// CGPoint Center { get; set; } +// +// To bind an Objective-C method, such as: +// +// -(void) doSomething:(NSObject *)object atIndex:(NSInteger)index; +// +// You would add a method definition to the C# interface like so: +// +// [Export ("doSomething:atIndex:")] +// void DoSomething (NSObject object, nint index); +// +// Objective-C "constructors" such as: +// +// -(id)initWithElmo:(ElmoMuppet *)elmo; +// +// Can be bound as: +// +// [Export ("initWithElmo:")] +// NativeHandle Constructor (ElmoMuppet elmo); +// +// For more information, see https://aka.ms/ios-binding +// + +} diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/StructsAndEnums.cs b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/StructsAndEnums.cs new file mode 100644 index 0000000000..936dba220e --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/StructsAndEnums.cs @@ -0,0 +1,4 @@ +namespace macOSBinding1 +{ + +} diff --git a/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/macOSBinding1.csproj b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/macOSBinding1.csproj new file mode 100644 index 0000000000..1c7193741e --- /dev/null +++ b/dotnet/Templates/Microsoft.macOS.Templates/macosbinding/macOSBinding1.csproj @@ -0,0 +1,14 @@ + + + net6.0-macos + macOSBinding1 + enable + true + true + + + + + + + diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.cs.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.cs.json new file mode 100644 index 0000000000..82a3decde3 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.cs.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Projekt pro vytvoření knihovny vazeb .NET pro tvOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.de.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.de.json new file mode 100644 index 0000000000..bc30ff439d --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.de.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Ein Projekt zum Erstellen einer .NET tvOS-Bindungsbibliothek" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.en.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.en.json new file mode 100644 index 0000000000..f4751616f0 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.en.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "A project for creating a .NET tvOS binding library" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.es.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.es.json new file mode 100644 index 0000000000..d3d338a5d2 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.es.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Proyecto para crear una biblioteca de enlaces de tvOS de .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.fr.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.fr.json new file mode 100644 index 0000000000..9eefaed5c1 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.fr.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Projet de création d’une bibliothèque de liaisons .NET tvOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.it.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.it.json new file mode 100644 index 0000000000..aa5ae377dd --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.it.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Progetto per la creazione di una libreria di binding tvOS .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ja.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ja.json new file mode 100644 index 0000000000..c84498c325 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ja.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": ".NET tvOS バインド ライブラリを作成するためのプロジェクト" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ko.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ko.json new file mode 100644 index 0000000000..3aea9916ed --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ko.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": ".NET tvOS 바인딩 라이브러리를 만들기 위한 프로젝트" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pl.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pl.json new file mode 100644 index 0000000000..2478babd7c --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pl.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Projekt służący do tworzenia biblioteki powiązań platformy .NET 6 dla systemu tvOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pt-BR.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pt-BR.json new file mode 100644 index 0000000000..68ea941cd4 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.pt-BR.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Um projeto para criar uma biblioteca de vinculação do tvOS .NET" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ru.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ru.json new file mode 100644 index 0000000000..442335f9f2 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.ru.json @@ -0,0 +1,5 @@ +{ + "author": "Майкрософт", + "name": "tvOS Binding Library", + "description": "Проект для создания библиотеки привязок .NET для tvOS" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.tr.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.tr.json new file mode 100644 index 0000000000..44156f0927 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.tr.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "Bir .NET tvOS bağlama kitaplığı oluşturmaya yönelik proje" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hans.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hans.json new file mode 100644 index 0000000000..55fc491bd0 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hans.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "用于创建 .NET tvOS 绑定库的项目" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hant.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hant.json new file mode 100644 index 0000000000..389e8056d7 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/localize/templatestrings.zh-Hant.json @@ -0,0 +1,5 @@ +{ + "author": "Microsoft", + "name": "tvOS Binding Library", + "description": "用於建立 .NET 6 tvOS 繫結程式庫的專案" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/template.json b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/template.json new file mode 100644 index 0000000000..d1ac05ae7a --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/.template.config/template.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Microsoft", + "classifications": [ "tvOS", "Mobile" ], + "identity": "Microsoft.tvOS.tvOSBinding", + "name": "tvOS Binding Library", + "description": "A project for creating a .NET tvOS binding library", + "shortName": "tvosbinding", + "tags": { + "language": "C#", + "type": "project" + }, + "sourceName": "tvOSBinding1", + "preferNameDirectory": true, + "primaryOutputs": [ + { "path": "tvOSBinding1.csproj" } + ], + "defaultName": "tvOSBinding1" +} \ No newline at end of file diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/ApiDefinition.cs b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/ApiDefinition.cs new file mode 100644 index 0000000000..88e886e49d --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/ApiDefinition.cs @@ -0,0 +1,70 @@ +namespace tvOSBinding1 +{ + +// The first step to creating a binding is to add your native framework ("MyLibrary.xcframework") +// to the project. +// Open your binding csproj and add a section like this +// +// +// Framework +// +// +// +// +// Once you've added it, you will need to customize it for your specific library: +// - Change the Include to the correct path/name of your library +// - Change Kind to Static (.a) or Framework (.framework/.xcframework) based upon the library kind and extension. +// - Dynamic (.dylib) is a third option but rarely if ever valid, and only on macOS and Mac Catalyst +// - If your library depends on other frameworks, add them inside +// Example: +// +// Framework +// CoreLocation ModelIO +// +// +// Once you've done that, you're ready to move on to binding the API... +// +// Here is where you'd define your API definition for the native Objective-C library. +// +// For example, to bind the following Objective-C class: +// +// @interface Widget : NSObject { +// } +// +// The C# binding would look like this: +// +// [BaseType (typeof (NSObject))] +// interface Widget { +// } +// +// To bind Objective-C properties, such as: +// +// @property (nonatomic, readwrite, assign) CGPoint center; +// +// You would add a property definition in the C# interface like so: +// +// [Export ("center")] +// CGPoint Center { get; set; } +// +// To bind an Objective-C method, such as: +// +// -(void) doSomething:(NSObject *)object atIndex:(NSInteger)index; +// +// You would add a method definition to the C# interface like so: +// +// [Export ("doSomething:atIndex:")] +// void DoSomething (NSObject object, nint index); +// +// Objective-C "constructors" such as: +// +// -(id)initWithElmo:(ElmoMuppet *)elmo; +// +// Can be bound as: +// +// [Export ("initWithElmo:")] +// NativeHandle Constructor (ElmoMuppet elmo); +// +// For more information, see https://aka.ms/ios-binding +// + +} diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/StructsAndEnums.cs b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/StructsAndEnums.cs new file mode 100644 index 0000000000..83bd2875e6 --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/StructsAndEnums.cs @@ -0,0 +1,4 @@ +namespace tvOSBinding1 +{ + +} diff --git a/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/tvOSBinding1.csproj b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/tvOSBinding1.csproj new file mode 100644 index 0000000000..8ef5e38caa --- /dev/null +++ b/dotnet/Templates/Microsoft.tvOS.Templates/tvosbinding/tvOSBinding1.csproj @@ -0,0 +1,14 @@ + + + net6.0-tvos + tvOSBinding1 + enable + true + true + + + + + + + diff --git a/tests/dotnet/UnitTests/TemplateTest.cs b/tests/dotnet/UnitTests/TemplateTest.cs index c7e13d5bf0..2ccf0755a9 100644 --- a/tests/dotnet/UnitTests/TemplateTest.cs +++ b/tests/dotnet/UnitTests/TemplateTest.cs @@ -25,9 +25,11 @@ namespace Xamarin.Tests { new TemplateInfo (ApplePlatform.iOS, "ioslib"), new TemplateInfo (ApplePlatform.iOS, "iosbinding", false), // Bindings can not build without a native library assigned new TemplateInfo (ApplePlatform.TVOS, "tvos"), + new TemplateInfo (ApplePlatform.TVOS, "tvosbinding", false), // Bindings can not build without a native library assigned 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.MacOSX, "macos", execute: true), + new TemplateInfo (ApplePlatform.MacOSX, "macosbinding", false), // Bindings can not build without a native library assigned }; public class TemplateConfig { From b353c2110827fd0aaaa32bac142e34071fa13d44 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 12 Sep 2022 11:21:44 +0200 Subject: [PATCH 5/5] [msbuild] Enable nullability in the CompileEntitlements task. (#15912) Also remove the 'MergeProfileEntitlements' property, since its value is always 'true' and thus the property is redundant. --- .../Tasks/CompileEntitlementsTaskBase.cs | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs index 24ffd52b3f..d2fd1648c6 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlementsTaskBase.cs @@ -7,6 +7,8 @@ using Microsoft.Build.Framework; using Xamarin.Localization.MSBuild; using Xamarin.Utils; +#nullable enable + namespace Xamarin.MacDev.Tasks { public abstract class CompileEntitlementsTaskBase : XamarinTask @@ -46,42 +48,42 @@ namespace Xamarin.MacDev.Tasks #region Inputs [Required] - public string AppBundleDir { get; set; } + public string AppBundleDir { get; set; } = string.Empty; [Required] - public string AppIdentifier { get; set; } + public string AppIdentifier { get; set; } = string.Empty; [Required] - public string BundleIdentifier { get; set; } + public string BundleIdentifier { get; set; } = string.Empty; [Required] - public ITaskItem CompiledEntitlements { get; set; } + public ITaskItem? CompiledEntitlements { get; set; } public bool Debug { get; set; } - public string Entitlements { get; set; } + public string Entitlements { get; set; } = string.Empty; [Required] public bool IsAppExtension { get; set; } - public string ProvisioningProfile { get; set; } + public string ProvisioningProfile { get; set; } = string.Empty; [Required] - public string SdkDevPath { get; set; } + public string SdkDevPath { get; set; } = string.Empty; public bool SdkIsSimulator { get; set; } [Required] - public string SdkPlatform { get; set; } + public string SdkPlatform { get; set; } = string.Empty; [Required] - public string SdkVersion { get; set; } + public string SdkVersion { get; set; } = string.Empty; [Output] - public ITaskItem EntitlementsInExecutable { get; set; } + public ITaskItem? EntitlementsInExecutable { get; set; } [Output] - public ITaskItem EntitlementsInSignature { get; set; } + public ITaskItem? EntitlementsInSignature { get; set; } #endregion @@ -139,11 +141,7 @@ namespace Xamarin.MacDev.Tasks } } - protected virtual bool MergeProfileEntitlements { - get { return true; } - } - - PString MergeEntitlementString (PString pstr, MobileProvision profile, bool expandWildcards) + PString MergeEntitlementString (PString pstr, MobileProvision? profile, bool expandWildcards) { string TeamIdentifierPrefix; string AppIdentifierPrefix; @@ -151,7 +149,7 @@ namespace Xamarin.MacDev.Tasks if (string.IsNullOrEmpty (pstr.Value)) return (PString) pstr.Clone (); - if (profile == null) { + if (profile is null) { if (!warnedTeamIdentifierPrefix && pstr.Value.Contains ("$(TeamIdentifierPrefix)")) { Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0108); warnedTeamIdentifierPrefix = true; @@ -163,12 +161,12 @@ namespace Xamarin.MacDev.Tasks } } - if (profile != null && profile.ApplicationIdentifierPrefix.Count > 0) + if (profile is not null && profile.ApplicationIdentifierPrefix.Count > 0) AppIdentifierPrefix = profile.ApplicationIdentifierPrefix[0] + "."; else AppIdentifierPrefix = string.Empty; - if (profile != null && profile.TeamIdentifierPrefix.Count > 0) + if (profile is not null && profile.TeamIdentifierPrefix.Count > 0) TeamIdentifierPrefix = profile.TeamIdentifierPrefix[0] + "."; else TeamIdentifierPrefix = AppIdentifierPrefix; @@ -203,12 +201,12 @@ namespace Xamarin.MacDev.Tasks return new PString (expanded); } - PArray MergeEntitlementArray (PArray array, MobileProvision profile) + PArray? MergeEntitlementArray (PArray array, MobileProvision? profile) { var result = new PArray (); foreach (var item in array) { - PObject value; + PObject? value; if (item is PDictionary) value = MergeEntitlementDictionary ((PDictionary) item, profile); @@ -219,7 +217,7 @@ namespace Xamarin.MacDev.Tasks else value = item.Clone (); - if (value != null) + if (value is not null) result.Add (value); } @@ -229,12 +227,12 @@ namespace Xamarin.MacDev.Tasks return null; } - PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision profile) + PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision? profile) { var result = new PDictionary (); foreach (var item in dict) { - PObject value = item.Value; + PObject? value = item.Value; if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); @@ -245,7 +243,7 @@ namespace Xamarin.MacDev.Tasks else value = value.Clone (); - if (value != null) + if (value is not null) result.Add (item.Key, value); } @@ -289,11 +287,11 @@ namespace Xamarin.MacDev.Tasks } } - protected virtual PDictionary GetCompiledEntitlements (MobileProvision profile, PDictionary template) + protected virtual PDictionary GetCompiledEntitlements (MobileProvision? profile, PDictionary template) { var entitlements = new PDictionary (); - if (profile != null && MergeProfileEntitlements) { + if (profile is not null) { // start off with the settings from the provisioning profile foreach (var item in profile.Entitlements) { if (!AllowedProvisioningKeys.Contains (item.Key)) @@ -312,7 +310,7 @@ namespace Xamarin.MacDev.Tasks else value = value.Clone (); - if (value != null) + if (value is not null) entitlements.Add (item.Key, value); } } @@ -325,7 +323,7 @@ namespace Xamarin.MacDev.Tasks item.Key == "com.apple.developer.icloud-container-identifiers" || item.Key == "com.apple.developer.icloud-container-environment" || item.Key == "com.apple.developer.icloud-services") { - if (profile == null) + if (profile is null) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0110, item.Key); else if (!profile.Entitlements.ContainsKey (item.Key)) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, MSBStrings.W0111, item.Key); @@ -333,7 +331,7 @@ namespace Xamarin.MacDev.Tasks var str = value as PString; // Ignore ONLY if it is empty, otherwise take the user's value - if (str == null || string.IsNullOrEmpty (str.Value)) + if (str is null || string.IsNullOrEmpty (str.Value)) continue; } @@ -346,7 +344,7 @@ namespace Xamarin.MacDev.Tasks else value = value.Clone (); - if (value != null) + if (value is not null) entitlements[item.Key] = value; } @@ -389,7 +387,7 @@ namespace Xamarin.MacDev.Tasks public override bool Execute () { MobileProvisionPlatform platform; - MobileProvision profile; + MobileProvision? profile; PDictionary template; PDictionary compiled; PDictionary archived; @@ -418,7 +416,7 @@ namespace Xamarin.MacDev.Tasks } if (!string.IsNullOrEmpty (ProvisioningProfile)) { - if ((profile = GetMobileProvision (platform, ProvisioningProfile)) == null) { + if ((profile = GetMobileProvision (platform, ProvisioningProfile)) is null) { Log.LogError (MSBStrings.E0049, ProvisioningProfile); return false; } @@ -448,7 +446,7 @@ namespace Xamarin.MacDev.Tasks archived = GetArchivedExpandedEntitlements (template, compiled); try { - Directory.CreateDirectory (Path.GetDirectoryName (CompiledEntitlements.ItemSpec)); + Directory.CreateDirectory (Path.GetDirectoryName (CompiledEntitlements!.ItemSpec)); WriteXcent (compiled, CompiledEntitlements.ItemSpec); } catch (Exception ex) { Log.LogError (MSBStrings.E0114, CompiledEntitlements, ex.Message);