forked from xamarin/xamarin-macios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
comment out PKPayLaterValidateAmount bits until Apple replies
- Loading branch information
tj_devel709
committed
Oct 19, 2023
1 parent
d167a8a
commit 049c2de
Showing
4 changed files
with
92 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,72 @@ | ||
#nullable enable | ||
// Can be uncommented when this issue is resolved: # https://github.com/xamarin/xamarin-macios/issues/19271 | ||
|
||
#if IOS && !__MACCATALYST__ | ||
// #nullable enable | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.CompilerServices; | ||
using ObjCRuntime; | ||
using Foundation; | ||
using PassKit; | ||
// #if IOS && !__MACCATALYST__ | ||
|
||
#if !NET | ||
using NativeHandle = System.IntPtr; | ||
#endif | ||
// using System; | ||
// using System.Runtime.InteropServices; | ||
// using System.Runtime.CompilerServices; | ||
// using ObjCRuntime; | ||
// using Foundation; | ||
// using PassKit; | ||
|
||
namespace PassKit { | ||
// #if !NET | ||
// using NativeHandle = System.IntPtr; | ||
// #endif | ||
|
||
public partial class PKPayLaterView { | ||
// namespace PassKit { | ||
|
||
#if !NET | ||
delegate void PKPayLaterValidateAmountCompletionHandler (IntPtr block, byte eligible); | ||
static PKPayLaterValidateAmountCompletionHandler static_ValidateAmount = TrampolineValidateAmount; | ||
// public partial class PKPayLaterView { | ||
|
||
[MonoPInvokeCallback (typeof (PKPayLaterValidateAmountCompletionHandler))] | ||
#else | ||
[UnmanagedCallersOnly] | ||
#endif | ||
static void TrampolineValidateAmount (IntPtr block, byte eligible) | ||
{ | ||
var del = BlockLiteral.GetTarget<Action<bool>> (block); | ||
if (del is not null) { | ||
del (eligible != 0); | ||
} | ||
} | ||
// #if !NET | ||
// delegate void PKPayLaterValidateAmountCompletionHandler (IntPtr block, byte eligible); | ||
// static PKPayLaterValidateAmountCompletionHandler static_ValidateAmount = TrampolineValidateAmount; | ||
|
||
#if NET | ||
[SupportedOSPlatform ("ios17.0")] | ||
[UnsupportedOSPlatform ("maccatalyst")] | ||
[UnsupportedOSPlatform ("macos")] | ||
[UnsupportedOSPlatform ("tvos")] | ||
#endif | ||
[BindingImpl (BindingImplOptions.Optimizable)] | ||
public static void ValidateAmount (NSDecimalNumber amount, string currencyCode, Action<bool> callback) | ||
{ | ||
if (callback is null) | ||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (callback)); | ||
// [MonoPInvokeCallback (typeof (PKPayLaterValidateAmountCompletionHandler))] | ||
// #else | ||
// [UnmanagedCallersOnly] | ||
// #endif | ||
// static void TrampolineValidateAmount (IntPtr block, byte eligible) | ||
// { | ||
// var del = BlockLiteral.GetTarget<Action<bool>> (block); | ||
// if (del is not null) { | ||
// del (eligible != 0); | ||
// } | ||
// } | ||
|
||
unsafe { | ||
#if NET | ||
delegate* unmanaged<IntPtr, byte, void> trampoline = &TrampolineValidateAmount; | ||
using var block = new BlockLiteral (trampoline, callback, typeof (PKPayLaterView), nameof (TrampolineValidateAmount)); | ||
#else | ||
using var block = new BlockLiteral (); | ||
block.SetupBlockUnsafe (static_ValidateAmount, callback); | ||
#endif | ||
var nsCurrencyCodePtr = NSString.CreateNative (currencyCode); | ||
try { | ||
PKPayLaterValidateAmount (amount.Handle, nsCurrencyCodePtr, &block); | ||
} finally { | ||
NSString.ReleaseNative (nsCurrencyCodePtr); | ||
} | ||
} | ||
} | ||
// #if NET | ||
// [SupportedOSPlatform ("ios17.0")] | ||
// [UnsupportedOSPlatform ("maccatalyst")] | ||
// [UnsupportedOSPlatform ("macos")] | ||
// [UnsupportedOSPlatform ("tvos")] | ||
// #endif | ||
// [BindingImpl (BindingImplOptions.Optimizable)] | ||
// public static void ValidateAmount (NSDecimalNumber amount, string currencyCode, Action<bool> callback) | ||
// { | ||
// if (callback is null) | ||
// ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (callback)); | ||
|
||
[DllImport (Constants.PassKitLibrary)] | ||
unsafe static extern void PKPayLaterValidateAmount (IntPtr /* NSDecimalNumber */ amount, IntPtr /* NSString */ currencyCode, BlockLiteral* callback); | ||
} | ||
} | ||
// unsafe { | ||
// #if NET | ||
// delegate* unmanaged<IntPtr, byte, void> trampoline = &TrampolineValidateAmount; | ||
// using var block = new BlockLiteral (trampoline, callback, typeof (PKPayLaterView), nameof (TrampolineValidateAmount)); | ||
// #else | ||
// using var block = new BlockLiteral (); | ||
// block.SetupBlockUnsafe (static_ValidateAmount, callback); | ||
// #endif | ||
// var nsCurrencyCodePtr = NSString.CreateNative (currencyCode); | ||
// try { | ||
// PKPayLaterValidateAmount (amount.Handle, nsCurrencyCodePtr, &block); | ||
// } finally { | ||
// NSString.ReleaseNative (nsCurrencyCodePtr); | ||
// } | ||
// } | ||
// } | ||
|
||
#endif | ||
// [DllImport (Constants.PassKitLibrary)] | ||
// unsafe static extern void PKPayLaterValidateAmount (IntPtr /* NSDecimalNumber */ amount, IntPtr /* NSString */ currencyCode, BlockLiteral* callback); | ||
// } | ||
// } | ||
|
||
// #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
#if __IOS__ && !__MACCATALYST__ | ||
// Can be uncommented when this issue is resolved: # https://github.com/xamarin/xamarin-macios/issues/19271 | ||
|
||
using System; | ||
using Foundation; | ||
using UIKit; | ||
using PassKit; | ||
using NUnit.Framework; | ||
// #if __IOS__ && !__MACCATALYST__ | ||
|
||
namespace MonoTouchFixtures.PassKit { | ||
// using System; | ||
// using Foundation; | ||
// using UIKit; | ||
// using PassKit; | ||
// using NUnit.Framework; | ||
|
||
[TestFixture] | ||
[Preserve (AllMembers = true)] | ||
public class PKPayLaterViewTest { | ||
// namespace MonoTouchFixtures.PassKit { | ||
|
||
[Test] | ||
public void ValidateAmountTest () | ||
{ | ||
TestRuntime.AssertXcodeVersion (15, 0); | ||
// [TestFixture] | ||
// [Preserve (AllMembers = true)] | ||
// public class PKPayLaterViewTest { | ||
|
||
// From testing with Xcode 15.0.0, all values give the value of false to the completion handler. | ||
// Perhaps this will change in the future. | ||
// Apple feedback was submitted here: https://feedbackassistant.apple.com/feedback/13268898 | ||
for (int i = 0; i < 1000; i++){ | ||
PKPayLaterView.ValidateAmount (new NSDecimalNumber (i), "USD", (eligible) => { | ||
Assert.False (eligible); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
// [Test] | ||
// public void ValidateAmountTest () | ||
// { | ||
// TestRuntime.AssertXcodeVersion (15, 0); | ||
|
||
#endif | ||
// for (int i = 0; i < 1000; i++){ | ||
// PKPayLaterView.ValidateAmount (new NSDecimalNumber (i), "USD", (eligible) => { | ||
// Assert.False (eligible); | ||
// }); | ||
// } | ||
// } | ||
// } | ||
// } | ||
|
||
// #endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters