Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dovholuknf committed Oct 8, 2023
1 parent 2a2f35c commit fa02114
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
12 changes: 0 additions & 12 deletions OpenZiti.NET.Tests/TestNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,18 @@ namespace OpenZiti.NET.Tests {
public class NativeCodeAlignmentChecker {
private static readonly NLog.Logger Log = NLog.LogManager.GetCurrentClassLogger();
private void verifyFieldCheck<T>(AlignmentCheck check, string expectedChecksum, uint expectedOffset, uint expectedSize) {
Log.Info($"{check.checksum}, {check.offset}, {check.size}");
//advance the curOffset by the size of the AlignmentCheck
Log.Info($"{check.checksum}, {check.offset}, {check.size}");
Assert.AreEqual(expectedChecksum, check.checksum);
Assert.AreEqual((int)expectedOffset, (int)check.offset);
Assert.AreEqual(expectedSize, check.size);
Log.Info($"{check.checksum}, {check.offset}, {check.size}");
}

public const CallingConvention CALL_CONVENTION = CallingConvention.Cdecl;
public const string Z4D_DLL_PATH = @"C:\git\github\openziti\ziti-sdk-csharp\ZitiNativeApiForDotnetCore\build\library\Debug\ziti4dotnet.dll";

[DllImport(Z4D_DLL_PATH, EntryPoint = "z4d_struct_test_ziti_auth_query_mfa", CallingConvention = CALL_CONVENTION)]
public static extern IntPtr z4d_struct_test_ziti_auth_query_mfa();

[TestMethod]
public void TestCSDKStructAlignments() {
Log.Info("test begins with: " + Native.API.GetZitiPath());

IntPtr testData = TestBlitting.z4d_struct_test();
uint size = Marshal.PtrToStructure<uint>(testData);
byte[] managedArray = new byte[size];
Marshal.Copy(testData, managedArray, 0, (int)size);

ziti_types native_structs = Marshal.PtrToStructure<ziti_types>(testData);

// as of 0.35.0, run ./build/library/Debug/zitistructalignment.exe and capture the output
Expand Down
11 changes: 0 additions & 11 deletions OpenZiti.NET/src/OpenZiti/Native/structs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public class TestBlitting {
[DllImport(API.Z4D_DLL_PATH, EntryPoint = "z4d_ziti_posture_query", CallingConvention = API.CALL_CONVENTION)]
public static extern IntPtr z4d_ziti_posture_query();

public static void Run() {
}


public static T ToContextEvent<T>(T desired, IntPtr /*byte[] input*/ input) {
int size = Marshal.SizeOf(desired);
IntPtr ptr = IntPtr.Zero;
Expand Down Expand Up @@ -90,13 +86,6 @@ public struct ziti_types_info {
public string checksum;
}

public static class IntPtrExtensions
{
public static bool Check(this IntPtr intPtr)
{
return intPtr != IntPtr.Zero;
}
}

[StructLayout(LayoutKind.Sequential)]
public struct ziti_types {
Expand Down

0 comments on commit fa02114

Please sign in to comment.