SkNativeDependencyCompatibilityChecker.cs 975 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.InteropServices;
  4. using QuestPDF.Helpers;
  5. namespace QuestPDF.Skia;
  6. internal static class SkNativeDependencyCompatibilityChecker
  7. {
  8. private static NativeDependencyCompatibilityChecker Instance { get; } = new()
  9. {
  10. ExecuteNativeCode = ExecuteNativeCode
  11. };
  12. public static void Test()
  13. {
  14. Instance.Test();
  15. }
  16. private static void ExecuteNativeCode()
  17. {
  18. var random = new Random();
  19. var a = random.Next();
  20. var b = random.Next();
  21. var expected = a + b;
  22. var returned = API.check_compatibility_by_calculating_sum(a, b);
  23. if (expected != returned)
  24. throw new Exception();
  25. }
  26. private static class API
  27. {
  28. [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
  29. public static extern int check_compatibility_by_calculating_sum(int a, int b);
  30. }
  31. }