From c7a983cbd273a5065ebcd02842b1a16fb63cce48 Mon Sep 17 00:00:00 2001 From: Jhett Black <10942655+jhett12321@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:20:35 +0100 Subject: [PATCH] Fix code style errors. --- .../main/Async/MainThreadSynchronizationContext.cs | 11 +---------- .../src/main/Async/SynchronizationContextAwaiter.cs | 9 +-------- NWNX.NET.Tests/src/main/Constants/VMFunctions.cs | 2 ++ NWNX.NET.Tests/src/main/Program.cs | 3 +-- NWNX.NET.Tests/src/main/TestRunner.cs | 2 +- NWNX.NET.Tests/src/main/Tests/Hooks/HookTests.cs | 2 +- NWNX.NET.sln.DotSettings | 1 + NWNX.NET/src/main/API/NWNXAPI.VM.cs | 1 + 8 files changed, 9 insertions(+), 22 deletions(-) diff --git a/NWNX.NET.Tests/src/main/Async/MainThreadSynchronizationContext.cs b/NWNX.NET.Tests/src/main/Async/MainThreadSynchronizationContext.cs index a7e6d29..282620c 100644 --- a/NWNX.NET.Tests/src/main/Async/MainThreadSynchronizationContext.cs +++ b/NWNX.NET.Tests/src/main/Async/MainThreadSynchronizationContext.cs @@ -55,17 +55,8 @@ public void Update() } } - private readonly struct QueuedTask + private readonly struct QueuedTask(SendOrPostCallback callback, object? state) { - private readonly SendOrPostCallback callback; - private readonly object? state; - - public QueuedTask(SendOrPostCallback callback, object? state) - { - this.callback = callback; - this.state = state; - } - public void Invoke() { try diff --git a/NWNX.NET.Tests/src/main/Async/SynchronizationContextAwaiter.cs b/NWNX.NET.Tests/src/main/Async/SynchronizationContextAwaiter.cs index d29ece9..6af334c 100644 --- a/NWNX.NET.Tests/src/main/Async/SynchronizationContextAwaiter.cs +++ b/NWNX.NET.Tests/src/main/Async/SynchronizationContextAwaiter.cs @@ -5,17 +5,10 @@ namespace NWNX.NET.Tests.Async /// /// Awaits for the current async context to return to the specified context. /// - internal readonly struct SynchronizationContextAwaiter : IAwaiter + internal readonly struct SynchronizationContextAwaiter(SynchronizationContext context) : IAwaiter { private static readonly SendOrPostCallback PostCallback = state => ((System.Action?)state)?.Invoke(); - private readonly SynchronizationContext context; - - public SynchronizationContextAwaiter(SynchronizationContext context) - { - this.context = context; - } - public bool IsCompleted => context == SynchronizationContext.Current; public void GetResult() {} diff --git a/NWNX.NET.Tests/src/main/Constants/VMFunctions.cs b/NWNX.NET.Tests/src/main/Constants/VMFunctions.cs index d80f9c7..5a11374 100644 --- a/NWNX.NET.Tests/src/main/Constants/VMFunctions.cs +++ b/NWNX.NET.Tests/src/main/Constants/VMFunctions.cs @@ -1,3 +1,5 @@ +// ReSharper disable InconsistentNaming + namespace NWNX.NET.Tests.Constants { public static class VMFunctions diff --git a/NWNX.NET.Tests/src/main/Program.cs b/NWNX.NET.Tests/src/main/Program.cs index 622567d..20131d1 100644 --- a/NWNX.NET.Tests/src/main/Program.cs +++ b/NWNX.NET.Tests/src/main/Program.cs @@ -10,7 +10,7 @@ public static unsafe class Program private static readonly MainThreadSynchronizationContext TestSyncContext = new MainThreadSynchronizationContext(); private static readonly TestRunner TestRunner = new TestRunner(TestSyncContext); - public static event Action OnMainLoop; + public static event Action? OnMainLoop; public static void Main() { @@ -40,7 +40,6 @@ private static void NWNXSignalHandler(IntPtr signalPtr) TestRunner.RunTestsAsync(); break; case "ON_DESTROY_SERVER": - break; case "ON_DESTROY_SERVER_AFTER": break; } diff --git a/NWNX.NET.Tests/src/main/TestRunner.cs b/NWNX.NET.Tests/src/main/TestRunner.cs index 04ffc1d..bd2ce02 100644 --- a/NWNX.NET.Tests/src/main/TestRunner.cs +++ b/NWNX.NET.Tests/src/main/TestRunner.cs @@ -45,7 +45,7 @@ private void ExecuteTestRun() } } - private string[] GetRunnerArguments() + private static string[] GetRunnerArguments() { return ["--mainthread", $"--work={TestResultPath}"]; } diff --git a/NWNX.NET.Tests/src/main/Tests/Hooks/HookTests.cs b/NWNX.NET.Tests/src/main/Tests/Hooks/HookTests.cs index 6d559f5..d2d8044 100644 --- a/NWNX.NET.Tests/src/main/Tests/Hooks/HookTests.cs +++ b/NWNX.NET.Tests/src/main/Tests/Hooks/HookTests.cs @@ -46,7 +46,7 @@ public async Task WriteLogFileDelegateHookTest() Assert.That(logMessage, Is.EqualTo(expectedMessage + "\n")); } - private unsafe void WriteLogFileDelegateHandler(void* pExoDebugInternal, void* pMessage) + private static unsafe void WriteLogFileDelegateHandler(void* pExoDebugInternal, void* pMessage) { callCount++; logMessage = StringUtils.ReadNullTerminatedString(CExoStringCStr(pMessage)); diff --git a/NWNX.NET.sln.DotSettings b/NWNX.NET.sln.DotSettings index 6ecae3a..c03f994 100644 --- a/NWNX.NET.sln.DotSettings +++ b/NWNX.NET.sln.DotSettings @@ -665,6 +665,7 @@ NWM NWNX NWNXAPI + NWNXVM NWS PC PLH diff --git a/NWNX.NET/src/main/API/NWNXAPI.VM.cs b/NWNX.NET/src/main/API/NWNXAPI.VM.cs index d8363e8..4c65ef4 100644 --- a/NWNX.NET/src/main/API/NWNXAPI.VM.cs +++ b/NWNX.NET/src/main/API/NWNXAPI.VM.cs @@ -53,6 +53,7 @@ public static partial class NWNXAPI /// /// VM Function. Push a game defined structure (pointer) to the current argument stack. /// + /// The engine structure type. /// The value to push. [LibraryImport("NWNX_DotNET", EntryPoint = "StackPushGameDefinedStructure")] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]