From 9264f83de4b0b76e00b8667022e0e5035dc749d6 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 20 Mar 2024 12:12:00 +0100 Subject: [PATCH] Add support for UnsafeBufferPointer types This commit introduces support for the UnsafeBufferPointer types. It also adds a test case for the CryptoKit bindings. --- .../BindingsGenerator.StringCSharpEmitter.cs | 3 + src/Swift.Bindings/src/Program.cs | 10 + src/Swift.Bindings/tests/CMakeLists.txt | 15 +- .../tests/{ => PInvoke}/PInvokeTests.cs | 808 +++++++++++++----- .../tests/{ => PInvoke}/PInvokeTests.swift | 0 .../tests/Swift.Bindings.Tests.csproj | 6 +- src/Swift.Bindings/tests/TestsHelper.cs | 48 +- .../UnsafeBufferPointerTests.Source.cs | 142 +++ .../UnsafeBufferPointerTests.cs | 23 + .../UnsafeBufferPointerTests.swift | 58 ++ .../UnsafePointerTests.Source.cs} | 6 +- .../tests/UnsafePointer/UnsafePointerTests.cs | 23 + .../UnsafePointerTests.swift} | 0 .../tests/UnsafeRawPointerTests.cs | 22 - src/Swift.Runtime/src/ISwiftObject.cs | 16 - .../src/Library/UnsafeBufferPointer.cs | 72 ++ src/Swift.Runtime/src/Swift.Runtime.csproj | 3 + src/Swift.Runtime/src/TypeDatabase.cs | 8 +- 18 files changed, 1002 insertions(+), 261 deletions(-) rename src/Swift.Bindings/tests/{ => PInvoke}/PInvokeTests.cs (76%) rename src/Swift.Bindings/tests/{ => PInvoke}/PInvokeTests.swift (100%) create mode 100644 src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.Source.cs create mode 100644 src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.cs create mode 100644 src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.swift rename src/Swift.Bindings/tests/{UnsafeRawPointerTests.cs.template => UnsafePointer/UnsafePointerTests.Source.cs} (94%) create mode 100644 src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.cs rename src/Swift.Bindings/tests/{UnsafeRawPointerTests.swift => UnsafePointer/UnsafePointerTests.swift} (100%) delete mode 100644 src/Swift.Bindings/tests/UnsafeRawPointerTests.cs delete mode 100644 src/Swift.Runtime/src/ISwiftObject.cs create mode 100644 src/Swift.Runtime/src/Library/UnsafeBufferPointer.cs diff --git a/src/Swift.Bindings/src/Emitter/BindingsGenerator.StringCSharpEmitter.cs b/src/Swift.Bindings/src/Emitter/BindingsGenerator.StringCSharpEmitter.cs index 4b71e577aab5..f49b9eb63544 100644 --- a/src/Swift.Bindings/src/Emitter/BindingsGenerator.StringCSharpEmitter.cs +++ b/src/Swift.Bindings/src/Emitter/BindingsGenerator.StringCSharpEmitter.cs @@ -41,6 +41,8 @@ public void EmitModule(ModuleDecl moduleDecl) var generatedNamespace = $"{moduleDecl.Name}Bindings"; writer.WriteLine($"using global::System;"); writer.WriteLine($"using global::System.Runtime.InteropServices;"); + writer.WriteLine($"using global::System.Runtime.CompilerServices;"); + writer.WriteLine($"using global::Swift.Runtime;"); writer.WriteLine(); writer.WriteLine($"namespace {generatedNamespace}"); writer.WriteLine($"{{"); @@ -74,6 +76,7 @@ public void EmitModule(ModuleDecl moduleDecl) /// The method declaration. public void EmitPInvoke(IndentedTextWriter writer, ModuleDecl moduleDecl, MethodDecl methodDecl) { + writer.WriteLine("[UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })]"); writer.WriteLine($"[DllImport(\"lib{moduleDecl.Name}.dylib\", EntryPoint = \"{methodDecl.MangledName}\")]"); writer.Write($"internal static extern"); EmitReturnType(writer, methodDecl.Signature); diff --git a/src/Swift.Bindings/src/Program.cs b/src/Swift.Bindings/src/Program.cs index d5706e149ca7..9d77687b031e 100644 --- a/src/Swift.Bindings/src/Program.cs +++ b/src/Swift.Bindings/src/Program.cs @@ -3,6 +3,7 @@ using System.CommandLine; using Swift.Runtime; +using System.IO; namespace BindingsGeneration { @@ -93,6 +94,15 @@ public static void GenerateBindings(string swiftAbiPath, string outputDirectory, ICSharpEmitter csharpEmitter = new StringCSharpEmitter(outputDirectory, typeDatabase, verbose); csharpEmitter.EmitModule(decl); + // Copy the Swift.Runtime types to the output directory + string[] fileEntries = Directory.GetFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Library")); + foreach (string filePath in fileEntries) + { + string fileName = Path.GetFileName(filePath); + string destFilePath = Path.Combine(outputDirectory, fileName); + File.Copy(filePath, destFilePath, true); + } + if (verbose > 0) Console.WriteLine("Bindings generation completed."); } diff --git a/src/Swift.Bindings/tests/CMakeLists.txt b/src/Swift.Bindings/tests/CMakeLists.txt index 2236f84ff9ca..cfc4ec567e51 100644 --- a/src/Swift.Bindings/tests/CMakeLists.txt +++ b/src/Swift.Bindings/tests/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.24) project(SwiftTests) # Find all Swift source files in the directory -file(GLOB SOURCES "*.swift") +file(GLOB SOURCES "**/*.swift") if (NOT SWIFT_COMPILER_TARGET) set(SWIFT_PLATFORM "macosx") @@ -18,13 +18,22 @@ if (NOT SWIFT_COMPILER_TARGET) endif() foreach(SOURCE_FILE ${SOURCES}) + get_filename_component(SOURCE_DIR ${SOURCE_FILE} DIRECTORY) + get_filename_component(PARENT_DIR_NAME ${SOURCE_DIR} NAME) get_filename_component(SOURCE_BASE_NAME ${SOURCE_FILE} NAME_WE) + set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${PARENT_DIR_NAME}") + message(STATUS "Generating ${OUTPUT_DIR} library") + file(MAKE_DIRECTORY ${OUTPUT_DIR}) add_custom_target(${SOURCE_BASE_NAME} ALL - COMMAND xcrun swiftc -target ${SWIFT_COMPILER_TARGET} -emit-module -emit-library -enable-library-evolution -emit-module-interface ${SOURCE_FILE} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${SOURCE_BASE_NAME}.dylib + COMMAND xcrun swiftc -target ${SWIFT_COMPILER_TARGET} -emit-module -emit-library -enable-library-evolution -emit-module-interface ${SOURCE_FILE} -o ${OUTPUT_DIR}/lib${SOURCE_BASE_NAME}.dylib DEPENDS ${SOURCE_FILE} COMMENT "Generating ${SOURCE_BASE_NAME} library" ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${SOURCE_BASE_NAME}.dylib + install(FILES ${OUTPUT_DIR}/lib${SOURCE_BASE_NAME}.dylib DESTINATION bin ) + add_custom_command(TARGET ${SOURCE_BASE_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${OUTPUT_DIR}/lib${SOURCE_BASE_NAME}.dylib ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Copying ${SOURCE_BASE_NAME} library to binary directory" + ) endforeach() diff --git a/src/Swift.Bindings/tests/PInvokeTests.cs b/src/Swift.Bindings/tests/PInvoke/PInvokeTests.cs similarity index 76% rename from src/Swift.Bindings/tests/PInvokeTests.cs rename to src/Swift.Bindings/tests/PInvoke/PInvokeTests.cs index e28c73ddab05..386d8d007fcc 100644 --- a/src/Swift.Bindings/tests/PInvokeTests.cs +++ b/src/Swift.Bindings/tests/PInvoke/PInvokeTests.cs @@ -10,7 +10,7 @@ public class PInvokeTests [Fact] public static void TestSwiftSmoke() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -34,7 +34,11 @@ public static int getResult() } """; - int result = (int)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + int result = (int)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(42, result); Console.WriteLine("OK"); } @@ -42,7 +46,7 @@ public static int getResult() [Fact] public static void TestSwiftFunc0() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -66,7 +70,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7706330218351441791, result); Console.WriteLine("OK"); } @@ -74,7 +82,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc1() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -98,7 +106,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-3202601456867082324, result); Console.WriteLine("OK"); } @@ -106,7 +118,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc2() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -130,7 +142,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(911474180935535301, result); Console.WriteLine("OK"); } @@ -138,7 +154,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc3() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -162,7 +178,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-6350065034291914241, result); Console.WriteLine("OK"); } @@ -170,7 +190,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc4() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -194,7 +214,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-9091922861563963282, result); Console.WriteLine("OK"); } @@ -202,7 +226,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc5() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -226,7 +250,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-3357359150345247842, result); Console.WriteLine("OK"); } @@ -234,7 +262,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc6() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -258,7 +286,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-581969692498632062, result); Console.WriteLine("OK"); } @@ -266,7 +298,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc7() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -290,7 +322,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4054341816496194551, result); Console.WriteLine("OK"); } @@ -298,7 +334,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc8() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -322,7 +358,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-2147505143518021575, result); Console.WriteLine("OK"); } @@ -330,7 +370,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc9() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -354,7 +394,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3533238385513656508, result); Console.WriteLine("OK"); } @@ -362,7 +406,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc10() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -386,7 +430,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8515181823957334780, result); Console.WriteLine("OK"); } @@ -394,7 +442,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc11() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -418,7 +466,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-5125817077505710853, result); Console.WriteLine("OK"); } @@ -426,7 +478,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc12() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -450,7 +502,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4774074602111830179, result); Console.WriteLine("OK"); } @@ -458,7 +514,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc13() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -482,7 +538,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8686515529117439727, result); Console.WriteLine("OK"); } @@ -490,7 +550,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc14() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -514,7 +574,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(1430703777921650146, result); Console.WriteLine("OK"); } @@ -522,7 +586,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc15() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -546,7 +610,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7324810059718518437, result); Console.WriteLine("OK"); } @@ -554,7 +622,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc16() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -578,7 +646,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-2322427926688559587, result); Console.WriteLine("OK"); } @@ -586,7 +658,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc17() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -610,7 +682,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-5704419938581148490, result); Console.WriteLine("OK"); } @@ -618,7 +694,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc18() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -642,7 +718,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7333181440701096551, result); Console.WriteLine("OK"); } @@ -650,7 +730,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc19() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -674,7 +754,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7514368921355633465, result); Console.WriteLine("OK"); } @@ -682,7 +766,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc20() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -706,7 +790,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4347999520285809529, result); Console.WriteLine("OK"); } @@ -714,7 +802,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc21() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -738,7 +826,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9056719667499044372, result); Console.WriteLine("OK"); } @@ -746,7 +838,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc22() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -770,7 +862,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(2450837469650376012, result); Console.WriteLine("OK"); } @@ -778,7 +874,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc23() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -802,7 +898,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-6077835106866375633, result); Console.WriteLine("OK"); } @@ -810,7 +910,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc24() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -834,7 +934,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7246961535839287248, result); Console.WriteLine("OK"); } @@ -842,7 +946,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc25() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -866,7 +970,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4681650148273269479, result); Console.WriteLine("OK"); } @@ -874,7 +982,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc26() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -898,7 +1006,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7896710633380101536, result); Console.WriteLine("OK"); } @@ -906,7 +1018,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc27() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -930,7 +1042,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-2413801917489038945, result); Console.WriteLine("OK"); } @@ -938,7 +1054,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc28() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -962,7 +1078,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-5115695744450024635, result); Console.WriteLine("OK"); } @@ -970,7 +1090,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc29() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -994,7 +1114,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7218188220935660367, result); Console.WriteLine("OK"); } @@ -1002,7 +1126,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc30() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1026,7 +1150,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3303407505715961682, result); Console.WriteLine("OK"); } @@ -1034,7 +1162,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc31() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1058,7 +1186,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(6926745355509484660, result); Console.WriteLine("OK"); } @@ -1066,7 +1198,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc32() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1090,7 +1222,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8134759728697468421, result); Console.WriteLine("OK"); } @@ -1098,7 +1234,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc33() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1122,7 +1258,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8926062754575499112, result); Console.WriteLine("OK"); } @@ -1130,7 +1270,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc34() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1154,7 +1294,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3916199453627741495, result); Console.WriteLine("OK"); } @@ -1162,7 +1306,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc35() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1186,7 +1330,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4225631615746848021, result); Console.WriteLine("OK"); } @@ -1194,7 +1342,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc36() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1218,7 +1366,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9029057458451328084, result); Console.WriteLine("OK"); } @@ -1226,7 +1378,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc37() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1250,7 +1402,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9091326884382848930, result); Console.WriteLine("OK"); } @@ -1258,7 +1414,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc38() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1282,7 +1438,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(2966780901945169708, result); Console.WriteLine("OK"); } @@ -1290,7 +1450,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc39() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1314,7 +1474,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7464446680392812994, result); Console.WriteLine("OK"); } @@ -1322,7 +1486,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc40() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1346,7 +1510,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-3563617050423332895, result); Console.WriteLine("OK"); } @@ -1354,7 +1522,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc41() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1378,7 +1546,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-2569382956498289470, result); Console.WriteLine("OK"); } @@ -1386,7 +1558,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc42() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1410,7 +1582,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-1108582741386924293, result); Console.WriteLine("OK"); } @@ -1418,7 +1594,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc43() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1442,7 +1618,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-5808479907339934850, result); Console.WriteLine("OK"); } @@ -1450,7 +1630,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc44() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1474,7 +1654,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-234686925954875908, result); Console.WriteLine("OK"); } @@ -1482,7 +1666,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc45() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1506,7 +1690,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-9083497234002976264, result); Console.WriteLine("OK"); } @@ -1514,7 +1702,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc46() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1538,7 +1726,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7467754277704703568, result); Console.WriteLine("OK"); } @@ -1546,7 +1738,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc47() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1570,7 +1762,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7149358155385248658, result); Console.WriteLine("OK"); } @@ -1578,7 +1774,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc48() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1602,7 +1798,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8590814201057560160, result); Console.WriteLine("OK"); } @@ -1610,7 +1810,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc49() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1634,7 +1834,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(739011484971652047, result); Console.WriteLine("OK"); } @@ -1642,7 +1846,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc50() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1666,7 +1870,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3055246540243887734, result); Console.WriteLine("OK"); } @@ -1674,7 +1882,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc51() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1698,7 +1906,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7917142179400080853, result); Console.WriteLine("OK"); } @@ -1706,7 +1918,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc52() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1730,7 +1942,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8118257769004209257, result); Console.WriteLine("OK"); } @@ -1738,7 +1954,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc53() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1762,7 +1978,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9075957082830800153, result); Console.WriteLine("OK"); } @@ -1770,7 +1990,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc54() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1794,7 +2014,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(715458900514912094, result); Console.WriteLine("OK"); } @@ -1802,7 +2026,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc55() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1826,7 +2050,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7812796314477300904, result); Console.WriteLine("OK"); } @@ -1834,7 +2062,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc56() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1858,7 +2086,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-3660123537755587162, result); Console.WriteLine("OK"); } @@ -1866,7 +2098,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc57() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1890,7 +2122,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8830493546874923270, result); Console.WriteLine("OK"); } @@ -1898,7 +2134,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc58() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1922,7 +2158,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(6514055640091085387, result); Console.WriteLine("OK"); } @@ -1930,7 +2170,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc59() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1954,7 +2194,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(5046324847209516867, result); Console.WriteLine("OK"); } @@ -1962,7 +2206,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc60() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -1986,7 +2230,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8176066941526010601, result); Console.WriteLine("OK"); } @@ -1994,7 +2242,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc61() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2018,7 +2266,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8047185703659702100, result); Console.WriteLine("OK"); } @@ -2026,7 +2278,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc62() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2050,7 +2302,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(6758416630263865563, result); Console.WriteLine("OK"); } @@ -2058,7 +2314,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc63() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2082,7 +2338,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-24765264996518815, result); Console.WriteLine("OK"); } @@ -2090,7 +2350,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc64() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2114,7 +2374,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4496411701938139124, result); Console.WriteLine("OK"); } @@ -2122,7 +2386,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc65() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2146,7 +2410,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7620356050748244213, result); Console.WriteLine("OK"); } @@ -2154,7 +2422,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc66() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2178,7 +2446,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-6837183037573462724, result); Console.WriteLine("OK"); } @@ -2186,7 +2458,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc67() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2210,7 +2482,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3965211134150981679, result); Console.WriteLine("OK"); } @@ -2218,7 +2494,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc68() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2242,7 +2518,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8645187640386338150, result); Console.WriteLine("OK"); } @@ -2250,7 +2530,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc69() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2274,7 +2554,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-2766546132850174765, result); Console.WriteLine("OK"); } @@ -2282,7 +2566,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc70() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2306,7 +2590,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-6730251310408327023, result); Console.WriteLine("OK"); } @@ -2314,7 +2602,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc71() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2338,7 +2626,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-4761426221194945322, result); Console.WriteLine("OK"); } @@ -2346,7 +2638,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc72() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2370,7 +2662,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8722701469163367659, result); Console.WriteLine("OK"); } @@ -2378,7 +2674,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc73() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2402,7 +2698,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9091436234605144348, result); Console.WriteLine("OK"); } @@ -2410,7 +2710,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc74() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2434,7 +2734,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-4564195959279673945, result); Console.WriteLine("OK"); } @@ -2442,7 +2746,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc75() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2466,7 +2770,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-3369734987080453648, result); Console.WriteLine("OK"); } @@ -2474,7 +2782,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc76() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2498,7 +2806,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8920640767423704440, result); Console.WriteLine("OK"); } @@ -2506,7 +2818,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc77() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2530,7 +2842,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(6960169366615671879, result); Console.WriteLine("OK"); } @@ -2538,7 +2854,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc78() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2562,7 +2878,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(4812301631028745377, result); Console.WriteLine("OK"); } @@ -2570,7 +2890,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc79() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2594,7 +2914,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(693619259694162127, result); Console.WriteLine("OK"); } @@ -2602,7 +2926,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc80() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2626,7 +2950,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-4631030647197364647, result); Console.WriteLine("OK"); } @@ -2634,7 +2962,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc81() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2658,7 +2986,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8908581242517107527, result); Console.WriteLine("OK"); } @@ -2666,7 +2998,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc82() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2690,7 +3022,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-1543576629977717704, result); Console.WriteLine("OK"); } @@ -2698,7 +3034,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc83() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2722,7 +3058,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-4161389211393419243, result); Console.WriteLine("OK"); } @@ -2730,7 +3070,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc84() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2754,7 +3094,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8984640578940854556, result); Console.WriteLine("OK"); } @@ -2762,7 +3106,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc85() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2786,7 +3130,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-5603269280984392717, result); Console.WriteLine("OK"); } @@ -2794,7 +3142,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc86() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2818,7 +3166,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-756030944410084256, result); Console.WriteLine("OK"); } @@ -2826,7 +3178,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc87() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2850,7 +3202,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3151224756940080953, result); Console.WriteLine("OK"); } @@ -2858,7 +3214,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc88() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2882,7 +3238,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3274371447309987255, result); Console.WriteLine("OK"); } @@ -2890,7 +3250,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc89() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2914,7 +3274,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-737269134554333880, result); Console.WriteLine("OK"); } @@ -2922,7 +3286,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc90() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2946,7 +3310,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(3441802633846719073, result); Console.WriteLine("OK"); } @@ -2954,7 +3322,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc91() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -2978,7 +3346,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(711186144202003795, result); Console.WriteLine("OK"); } @@ -2986,7 +3358,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc92() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3010,7 +3382,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(9206890599465525240, result); Console.WriteLine("OK"); } @@ -3018,7 +3394,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc93() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3042,7 +3418,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7367909694938381646, result); Console.WriteLine("OK"); } @@ -3050,7 +3430,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc94() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3074,7 +3454,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7957085466204676840, result); Console.WriteLine("OK"); } @@ -3082,7 +3466,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc95() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3106,7 +3490,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-8941275780625427292, result); Console.WriteLine("OK"); } @@ -3114,7 +3502,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc96() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3138,7 +3526,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(2083246537822351760, result); Console.WriteLine("OK"); } @@ -3146,7 +3538,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc97() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3170,7 +3562,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(8647824177212049859, result); Console.WriteLine("OK"); } @@ -3178,7 +3574,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc98() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3202,7 +3598,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(7040925530630314472, result); Console.WriteLine("OK"); } @@ -3210,7 +3610,7 @@ public static long getResult() [Fact] public static void TestSwiftFunc99() { - BindingsGenerator.GenerateBindings("PInvokeTests.abi.json", ""); + BindingsGenerator.GenerateBindings("PInvoke/PInvokeTests.abi.json", "PInvoke/"); var sourceCode = """ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -3234,7 +3634,11 @@ public static long getResult() } """; - long result = (long)TestsHelper.CompileAndExecute("PInvokeTestsBindings.cs", sourceCode, "Test.MainClass", "getResult", new object[] { }); + long result = (long)TestsHelper.CompileAndExecute( + new string [] { "PInvoke/*.cs" }, + new string [] { sourceCode }, + new string [] { }, + "Test.MainClass", "getResult", new object[] { }); Assert.Equal(-7883825139759684683, result); Console.WriteLine("OK"); } diff --git a/src/Swift.Bindings/tests/PInvokeTests.swift b/src/Swift.Bindings/tests/PInvoke/PInvokeTests.swift similarity index 100% rename from src/Swift.Bindings/tests/PInvokeTests.swift rename to src/Swift.Bindings/tests/PInvoke/PInvokeTests.swift diff --git a/src/Swift.Bindings/tests/Swift.Bindings.Tests.csproj b/src/Swift.Bindings/tests/Swift.Bindings.Tests.csproj index d7c46936c012..f1af9159118c 100644 --- a/src/Swift.Bindings/tests/Swift.Bindings.Tests.csproj +++ b/src/Swift.Bindings/tests/Swift.Bindings.Tests.csproj @@ -11,7 +11,11 @@ - + + + + + PreserveNewest diff --git a/src/Swift.Bindings/tests/TestsHelper.cs b/src/Swift.Bindings/tests/TestsHelper.cs index 3a4ec609510e..d2e33a7aff20 100644 --- a/src/Swift.Bindings/tests/TestsHelper.cs +++ b/src/Swift.Bindings/tests/TestsHelper.cs @@ -11,28 +11,30 @@ namespace BindingsGeneration.Tests public static class TestsHelper { private static int uniqueId = 0; - public static object CompileAndExecute(string filePath, string sourceCode, string typeName, string methodName, object[] args) - { - string fileSourceCode = File.ReadAllText(filePath); - var sourceCodes = new[] { fileSourceCode, sourceCode }; - return CompileAndExecute(sourceCodes, typeName, methodName, args); - } - private static object CompileAndExecute(string[] sourceCodes, string typeName, string methodName, object[] args) + + public static object CompileAndExecute(string[] filePaths, string[] sourceCodes, string[] dependencies, string typeName, string methodName, object[] args) { + var expandedFilePaths = ExpandFilePaths(filePaths); + Console.WriteLine($"Expanded file paths: {string.Join(", ", expandedFilePaths)}"); + var fileSourceCodes = expandedFilePaths.Select(File.ReadAllText).ToArray(); + var allSourceCodes = fileSourceCodes.Concat(sourceCodes).ToArray(); + var options = new CSharpCompilationOptions(OutputKind.ConsoleApplication, allowUnsafe: true); - var syntaxTrees = sourceCodes.Select(code => CSharpSyntaxTree.ParseText(code)).ToArray(); - var systemRuntimeAssemblyPath = Assembly.Load("System.Runtime").Location; - var systemSecurityCryptographyAssemblyPath = Assembly.Load("System.Security.Cryptography").Location; + var syntaxTrees = allSourceCodes.Select(code => CSharpSyntaxTree.ParseText(code)).ToArray(); - var references = new[] + var references = new List { MetadataReference.CreateFromFile(typeof(object).Assembly.Location), MetadataReference.CreateFromFile(typeof(Console).Assembly.Location), - MetadataReference.CreateFromFile(systemRuntimeAssemblyPath), - MetadataReference.CreateFromFile(systemSecurityCryptographyAssemblyPath), + MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location), + MetadataReference.CreateFromFile(Assembly.Load("System.Runtime.InteropServices").Location), }; + foreach (string dependency in dependencies) + { + references.Add(MetadataReference.CreateFromFile(Assembly.Load(dependency).Location)); + } var compilation = CSharpCompilation.Create($"CompiledAssembly{uniqueId}", syntaxTrees: syntaxTrees, @@ -60,5 +62,25 @@ private static object CompileAndExecute(string[] sourceCodes, string typeName, s MethodInfo customMethod = targetType.GetMethod(methodName); return customMethod.Invoke(null, args); } + + private static IEnumerable ExpandFilePaths(IEnumerable filePaths) + { + foreach (var path in filePaths) + { + if (path.Contains("*")) + { + var dirPath = Path.GetDirectoryName(path); + var searchPattern = Path.GetFileName(path); + foreach (var expandedPath in Directory.GetFiles(dirPath, searchPattern)) + { + yield return expandedPath; + } + } + else + { + yield return path; + } + } + } } } diff --git a/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.Source.cs b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.Source.cs new file mode 100644 index 000000000000..2cc13a507f6e --- /dev/null +++ b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.Source.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using UnsafeBufferPointerTestsBindings; +using System.Diagnostics; +using System.Security.Cryptography; +using Swift.Runtime; + +namespace Test +{ + public class MainClass + { + public static int Main(string[] args) + { + byte[] key = RandomNumberGenerator.GetBytes(32); // Generate a 256-bit key + byte[] nonce = RandomNumberGenerator.GetBytes(12); // Generate a 96-bit nonce + byte[] plaintext = System.Text.Encoding.UTF8.GetBytes("Hello, World!"); + byte[] aad = System.Text.Encoding.UTF8.GetBytes("Additional Authenticated Data"); + + byte[] ciphertext = new byte[plaintext.Length]; + byte[] tag = new byte[16]; // ChaCha20Poly1305 tag size + Console.WriteLine($"Plaintext: {BitConverter.ToString(plaintext)}"); + + ChaCha20Poly1305Encrypt( + key, + nonce, + plaintext, + ciphertext, + tag, + aad); + + Console.WriteLine($"Ciphertext: {BitConverter.ToString(ciphertext)}"); + Console.WriteLine($"Tag: {BitConverter.ToString(tag)}"); + + Array.Clear(plaintext, 0, plaintext.Length); + + ChaCha20Poly1305Decrypt( + key, + nonce, + ciphertext, + tag, + plaintext, + aad + ); + + string decryptedMessage = System.Text.Encoding.UTF8.GetString(plaintext); + Console.WriteLine($"Decrypted: {decryptedMessage}"); + return "Hello, World!" == decryptedMessage ? 1 : 0; + } + + internal static unsafe void ChaCha20Poly1305Encrypt( + ReadOnlySpan key, + ReadOnlySpan nonce, + ReadOnlySpan plaintext, + Span ciphertext, + Span tag, + ReadOnlySpan aad) + { + fixed (void* keyPtr = key) + fixed (void* noncePtr = nonce) + fixed (void* plaintextPtr = plaintext) + fixed (void* ciphertextPtr = ciphertext) + fixed (void* tagPtr = tag) + fixed (void* aadPtr = aad) + { + const int Success = 1; + + UnsafeRawBufferPointer keyBuffer = new UnsafeRawBufferPointer(keyPtr, key.Length); + UnsafeRawBufferPointer nonceBuffer = new UnsafeRawBufferPointer(noncePtr, nonce.Length); + UnsafeRawBufferPointer plaintextBuffer = new UnsafeRawBufferPointer(plaintextPtr, plaintext.Length); + UnsafeMutableBufferPointer ciphertextBuffer = new UnsafeMutableBufferPointer(ciphertextPtr, ciphertext.Length); + UnsafeMutableBufferPointer tagBuffer = new UnsafeMutableBufferPointer(tagPtr, tag.Length); + UnsafeRawBufferPointer aadBuffer = new UnsafeRawBufferPointer(aadPtr, aad.Length); + + int result = UnsafeBufferPointerTests.AppleCryptoNative_ChaCha20Poly1305Encrypt( + keyBuffer, + nonceBuffer, + plaintextBuffer, + ciphertextBuffer, + tagBuffer, + aadBuffer); + + if (result != Success) + { + Debug.Assert(result == 0); + Console.WriteLine("Encryption failed"); + } + } + } + + internal static unsafe void ChaCha20Poly1305Decrypt( + ReadOnlySpan key, + ReadOnlySpan nonce, + ReadOnlySpan ciphertext, + ReadOnlySpan tag, + Span plaintext, + ReadOnlySpan aad) + { + fixed (byte* keyPtr = key) + fixed (byte* noncePtr = nonce) + fixed (byte* ciphertextPtr = ciphertext) + fixed (byte* tagPtr = tag) + fixed (byte* plaintextPtr = plaintext) + fixed (byte* aadPtr = aad) + { + const int Success = 1; + const int AuthTagMismatch = -1; + + UnsafeRawBufferPointer keyBuffer = new UnsafeRawBufferPointer(keyPtr, key.Length); + UnsafeRawBufferPointer nonceBuffer = new UnsafeRawBufferPointer(noncePtr, nonce.Length); + UnsafeRawBufferPointer ciphertextBuffer = new UnsafeRawBufferPointer(ciphertextPtr, ciphertext.Length); + UnsafeRawBufferPointer tagBuffer = new UnsafeRawBufferPointer (tagPtr, tag.Length); + UnsafeMutableBufferPointer plaintextBuffer = new UnsafeMutableBufferPointer(plaintextPtr, plaintext.Length); + UnsafeRawBufferPointer aadBuffer = new UnsafeRawBufferPointer(aadPtr, aad.Length); + + int result = UnsafeBufferPointerTests.AppleCryptoNative_ChaCha20Poly1305Decrypt( + keyBuffer, + nonceBuffer, + ciphertextBuffer, + tagBuffer, + plaintextBuffer, + aadBuffer); + + if (result != Success) + { + CryptographicOperations.ZeroMemory(plaintext); + + if (result == AuthTagMismatch) + { + throw new AuthenticationTagMismatchException(); + } + else + { + Debug.Assert(result == 0); + throw new CryptographicException(); + } + } + } + } + } +} diff --git a/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.cs b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.cs new file mode 100644 index 000000000000..c25123a304e0 --- /dev/null +++ b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using Xunit; + +namespace BindingsGeneration.Tests +{ + public class UnsafeBufferPointerTests + { + [Fact] + public static void TestUnsafeBufferPointerCryptoKit() + { + BindingsGenerator.GenerateBindings("UnsafeBufferPointer/UnsafeBufferPointerTests.abi.json", "UnsafeBufferPointer/"); + + int result = (int)TestsHelper.CompileAndExecute( + new string [] { "UnsafeBufferPointer/*.cs" }, + new string [] { }, + new string [] { "System.Security.Cryptography" }, + "Test.MainClass", "Main", new object [] { new string[0] }); + Assert.Equal(1, result); + } + } +} diff --git a/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.swift b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.swift new file mode 100644 index 000000000000..72ec7bcc7609 --- /dev/null +++ b/src/Swift.Bindings/tests/UnsafeBufferPointer/UnsafeBufferPointerTests.swift @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import CryptoKit +import Foundation + +public func AppleCryptoNative_ChaCha20Poly1305Encrypt( + keyPtr: UnsafeRawBufferPointer, + noncePtr: UnsafeRawBufferPointer, + plaintextPtr: UnsafeRawBufferPointer, + ciphertextPtr: UnsafeMutableBufferPointer, + tagPtr: UnsafeMutableBufferPointer, + aadPtr: UnsafeRawBufferPointer + ) -> Int32 { + let nonce = try! ChaChaPoly.Nonce(data: noncePtr) + let symmetricKey = SymmetricKey(data: keyPtr) + + guard let result = try? ChaChaPoly.seal(plaintextPtr, using: symmetricKey, nonce: nonce, authenticating: aadPtr) else { + return 0 + } + + assert(ciphertextPtr.count >= result.ciphertext.count) + assert(tagPtr.count >= result.tag.count) + + result.ciphertext.copyBytes(to: ciphertextPtr, count: result.ciphertext.count) + result.tag.copyBytes(to: tagPtr, count: result.tag.count) + return 1 + } + +public func AppleCryptoNative_ChaCha20Poly1305Decrypt( + keyPtr: UnsafeRawBufferPointer, + noncePtr: UnsafeRawBufferPointer, + ciphertextPtr: UnsafeRawBufferPointer, + tagPtr: UnsafeRawBufferPointer, + plaintextPtr: UnsafeMutableBufferPointer, + aadPtr: UnsafeRawBufferPointer +) -> Int32 { + let nonce = try! ChaChaPoly.Nonce(data: noncePtr) + let symmetricKey = SymmetricKey(data: keyPtr) + + guard let sealedBox = try? ChaChaPoly.SealedBox(nonce: nonce, ciphertext: ciphertextPtr, tag: tagPtr) else { + return 0 + } + + do { + let result = try ChaChaPoly.open(sealedBox, using: symmetricKey, authenticating: aadPtr) + + assert(plaintextPtr.count >= result.count) + result.copyBytes(to: plaintextPtr, count: result.count) + return 1 + } + catch CryptoKitError.authenticationFailure { + return -1 + } + catch { + return 0 + } +} diff --git a/src/Swift.Bindings/tests/UnsafeRawPointerTests.cs.template b/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.Source.cs similarity index 94% rename from src/Swift.Bindings/tests/UnsafeRawPointerTests.cs.template rename to src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.Source.cs index 9ce6415d2f19..4cf354ea9714 100644 --- a/src/Swift.Bindings/tests/UnsafeRawPointerTests.cs.template +++ b/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.Source.cs @@ -2,7 +2,7 @@ // Licensed under the MIT License. using System; -using UnsafeRawPointerTestsBindings; +using UnsafePointerTestsBindings; using System.Diagnostics; using System.Security.Cryptography; @@ -65,7 +65,7 @@ public static int Main(string[] args) { const int Success = 1; - int result = UnsafeRawPointerTests.AppleCryptoNative_ChaCha20Poly1305Encrypt( + int result = UnsafePointerTests.AppleCryptoNative_ChaCha20Poly1305Encrypt( keyPtr, key.Length, noncePtr, nonce.Length, plaintextPtr, plaintext.Length, @@ -99,7 +99,7 @@ public static int Main(string[] args) const int Success = 1; const int AuthTagMismatch = -1; - int result = UnsafeRawPointerTests.AppleCryptoNative_ChaCha20Poly1305Decrypt( + int result = UnsafePointerTests.AppleCryptoNative_ChaCha20Poly1305Decrypt( keyPtr, key.Length, noncePtr, nonce.Length, ciphertextPtr, ciphertext.Length, diff --git a/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.cs b/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.cs new file mode 100644 index 000000000000..ab912cd5fd21 --- /dev/null +++ b/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using Xunit; + +namespace BindingsGeneration.Tests +{ + public class UnsafePointerTests + { + [Fact] + public static void TestUnsafePointerCryptoKit() + { + BindingsGenerator.GenerateBindings("UnsafePointer/UnsafePointerTests.abi.json", "UnsafePointer/"); + + int result = (int)TestsHelper.CompileAndExecute( + new string [] { "UnsafePointer/*.cs" }, + new string [] { }, + new string [] { "System.Security.Cryptography" }, + "Test.MainClass", "Main", new object [] { new string[0] }); + Assert.Equal(1, result); + } + } +} diff --git a/src/Swift.Bindings/tests/UnsafeRawPointerTests.swift b/src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.swift similarity index 100% rename from src/Swift.Bindings/tests/UnsafeRawPointerTests.swift rename to src/Swift.Bindings/tests/UnsafePointer/UnsafePointerTests.swift diff --git a/src/Swift.Bindings/tests/UnsafeRawPointerTests.cs b/src/Swift.Bindings/tests/UnsafeRawPointerTests.cs deleted file mode 100644 index 78b77b84159b..000000000000 --- a/src/Swift.Bindings/tests/UnsafeRawPointerTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -using Xunit; - -namespace BindingsGeneration.Tests -{ - public class UnsafeRawPointerTests - { - [Fact] - public static void TestUnsafeRawPointerCryptoKit() - { - BindingsGenerator.GenerateBindings("UnsafeRawPointerTests.abi.json", ""); - - string filePath = "UnsafeRawPointerTests.cs.template"; - string sourceCode = File.ReadAllText(filePath); - - int result = (int)TestsHelper.CompileAndExecute("UnsafeRawPointerTestsBindings.cs", sourceCode, "Test.MainClass", "Main", new object [] { new string[0] }); - Assert.Equal(1, result); - } - } -} diff --git a/src/Swift.Runtime/src/ISwiftObject.cs b/src/Swift.Runtime/src/ISwiftObject.cs deleted file mode 100644 index e21677dd1f36..000000000000 --- a/src/Swift.Runtime/src/ISwiftObject.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -namespace Swift.Runtime -{ - /// - /// Represents an instance of a Swift class object. - /// - public unsafe interface ISwiftObject - { - /// - /// Gets the handle to the Swift object instance. - /// - public void* SwiftObject { get; } - } -} diff --git a/src/Swift.Runtime/src/Library/UnsafeBufferPointer.cs b/src/Swift.Runtime/src/Library/UnsafeBufferPointer.cs new file mode 100644 index 000000000000..e241eb8334b6 --- /dev/null +++ b/src/Swift.Runtime/src/Library/UnsafeBufferPointer.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace Swift.Runtime +{ + // + // Represents Swift UnsafeRawBufferPointer in C#. + // + public unsafe readonly struct UnsafeRawBufferPointer + { + private readonly void* _Position; + private readonly void* _End; + public UnsafeRawBufferPointer(void* start, nint count) + { + _Position = start; + _End = (byte*)start + count; + } + + public void* BaseAddress => _Position; + public nint Count => (nint)((byte*)_End - (byte*)_Position); + } + + + // + // Represents Swift UnsafeMutableRawBufferPointer in C#. + // + public unsafe readonly struct UnsafeMutableRawBufferPointer + { + private readonly void* _Position; + private readonly void* _End; + public UnsafeMutableRawBufferPointer(void* start, nint count) + { + _Position = start; + _End = (byte*)start + count; + } + + public void* BaseAddress => _Position; + public nint Count => (nint)((byte*)_End - (byte*)_Position); + } + + // + // Represents Swift UnsafeBufferPointer in C#. + // + public unsafe readonly struct UnsafeBufferPointer + { + private readonly void* _Position; + public readonly nint Count; + public UnsafeBufferPointer(void* start, nint count) + { + _Position = start; + Count = count; + } + + public void* BaseAddress => _Position; + } + + // + // Represents Swift UnsafeMutableBufferPointer in C#. + // + public unsafe readonly struct UnsafeMutableBufferPointer + { + private readonly void* _Position; + public readonly nint Count; + public UnsafeMutableBufferPointer(void* start, nint count) + { + _Position = start; + Count = count; + } + + public void* BaseAddress => _Position; + } +} diff --git a/src/Swift.Runtime/src/Swift.Runtime.csproj b/src/Swift.Runtime/src/Swift.Runtime.csproj index 5d832a581caa..894158d1a558 100644 --- a/src/Swift.Runtime/src/Swift.Runtime.csproj +++ b/src/Swift.Runtime/src/Swift.Runtime.csproj @@ -14,6 +14,9 @@ PreserveNewest + + PreserveNewest + diff --git a/src/Swift.Runtime/src/TypeDatabase.cs b/src/Swift.Runtime/src/TypeDatabase.cs index 38845266488f..72398b325b89 100644 --- a/src/Swift.Runtime/src/TypeDatabase.cs +++ b/src/Swift.Runtime/src/TypeDatabase.cs @@ -103,11 +103,17 @@ private void ReadVersion1_0(XmlDocument xmlDoc) /// The corresponding C# type name. public string GetCSharpName(string swiftName) { + // Try to find a known mapping if (_swiftToCSharpMapping.TryGetValue(swiftName, out string? csharpName)) { return csharpName; } - throw new Exception($"No mapping for {swiftName} found in the type database."); + // Try to find a type in Swift.Runtime + Type? swiftType = Type.GetType($"Swift.Runtime.{swiftName}"); + if (swiftType != null) + return swiftType.Name; + + throw new Exception($"No mapping for {swiftName} type found."); } ///