From 8fb010b669e02f73a8106b7341a050e456c84f3b Mon Sep 17 00:00:00 2001 From: jose_morato Date: Wed, 18 Dec 2024 13:05:35 +0100 Subject: [PATCH] Use LibraryImport only for NET8 and greater --- Native/CSharpCDRImplTemplate.txt | 2 +- .../OpenDDSharp.UnitTest/DataReaderCDRTest.cs | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Native/CSharpCDRImplTemplate.txt b/Native/CSharpCDRImplTemplate.txt index f556babc..35e0462e 100644 --- a/Native/CSharpCDRImplTemplate.txt +++ b/Native/CSharpCDRImplTemplate.txt @@ -307,7 +307,7 @@ public static partial class <%TYPE%>DataWriterNative { -#if NET7_0_OR_GREATER +#if NET8_0_OR_GREATER [SuppressUnmanagedCodeSecurity] [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataWriter_Narrow")] [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })] diff --git a/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs b/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs index b962b964..5b6d70c9 100644 --- a/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs +++ b/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs @@ -1856,29 +1856,29 @@ public void TestReadNextInstance() // Write two samples of three different instances for (short i = 1; i <= 3; i++) { - // evt.Reset(); - // TestHelper.CreateWaitSetThread(evt, statusCondition); + evt.Reset(); + TestHelper.CreateWaitSetThread(evt, statusCondition); result = dataWriter.Write(new TestInclude { Id = i.ToString() }); Assert.AreEqual(ReturnCode.Ok, result); - Thread.Sleep(1_000); - - // result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 }); - // Assert.AreEqual(ReturnCode.Ok, result); - // - // Assert.IsTrue(evt.Wait(1_500)); - // - // evt.Reset(); - // TestHelper.CreateWaitSetThread(evt, statusCondition); - - // result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i }); - // Assert.AreEqual(ReturnCode.Ok, result); // Thread.Sleep(1_000); - // result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 }); - // Assert.AreEqual(ReturnCode.Ok, result); - // - // Assert.IsTrue(evt.Wait(1_500)); + result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 }); + Assert.AreEqual(ReturnCode.Ok, result); + + Assert.IsTrue(evt.Wait(1_500)); + + evt.Reset(); + TestHelper.CreateWaitSetThread(evt, statusCondition); + + result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i }); + Assert.AreEqual(ReturnCode.Ok, result); + // Thread.Sleep(1_000); + + result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 }); + Assert.AreEqual(ReturnCode.Ok, result); + + Assert.IsTrue(evt.Wait(1_500)); } // Read next instance with the simplest overload