Merged
Conversation
…12) * Add struct-based SimVar set functionality Introduces IFieldWriter, SimVarFieldWriter, and SimVarFieldWriterFactory to enable writing SimVar-annotated structs into unmanaged buffers. Adds SimVarManager.SetAsync<T> and SetStructAsync for setting multiple SimVars in one call using a struct. Updates tests to verify struct-based SimVar setting and restoration. * Improve SimConnect struct writing and error handling Refactored string field writing to ensure explicit null-termination and use Latin1 encoding for SimConnect compatibility. Added caching of struct writers and total size in SimVarManager for efficient SetDataOnSimObject calls. Improved error handling and updated attribute references from [SimVar] to [SimConnect].
- Added ExceptionHelper for improved exception handling in various components. - Enhanced SimVar type inference for automatic detection of SimConnectDataInitPosition. - Improved struct-based SimVars.SetAsync<TStruct> for better performance and error handling. - Updated logging mechanisms to use ExceptionHelper for critical exception filtering. - Refined input event processing with defensive coding practices. - Maintained integration tests for better coverage and reliability. - Fixed issues with struct writers and SimVarManager logging.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces version 0.1.17 of SimConnect.NET with improvements focused on exception handling, struct-based SimVar operations, input event parsing robustness, and test infrastructure stability.
- Adds a central
ExceptionHelperto distinguish critical from non-critical exceptions across background loops - Enhances struct-based SimVar writing with cached writers and improved ANSI string encoding
- Strengthens input event parsing with defensive fallbacks and guarded type conversions
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Directory.Build.props | Bumps package version to 0.1.17 |
| CHANGELOG.md | Documents all changes in version 0.1.17 |
| src/SimConnect.NET/Internal/ExceptionHelper.cs | Adds new helper to identify critical exceptions that should not be swallowed |
| src/SimConnect.NET/SimConnectClient.cs | Adds exception filtering and improves cancellation logging |
| src/SimConnect.NET/SimConnectLogger.cs | Adds exception filtering, improves error reporting, and uses Path.Join |
| src/SimConnect.NET/SimVar/SimVarManager.cs | Adds cached struct writers, exception filtering, null-unit support, and type inference for SimConnectDataInitPosition |
| src/SimConnect.NET/SimVar/Internal/SimVarRequest.cs | Adds exception filtering and logging for user callback errors |
| src/SimConnect.NET/SimVar/Internal/SimVarFieldReaderFactory.cs | Updates error message to reference [SimConnect] attribute |
| src/SimConnect.NET/SimVar/Internal/SimVarFieldWriterFactory.cs | Updates error message and removes dead code assignment |
| src/SimConnect.NET/SimVar/Internal/SimVarFieldWriter.cs | Refactors string encoding to use Latin1 with explicit null termination |
| src/SimConnect.NET/InputEvents/InputEventManager.cs | Adds exception filtering and defensive input event parsing |
| src/SimConnect.NET/InputEvents/InputEventValue.cs | Refines exception handling in TryGetDoubleValue and simplifies TryGetStringValue |
| src/SimConnect.NET/AI/SimObjectType.cs | Refactors GetAllContainerTitles to use LINQ |
| tests/SimConnect.NET.Tests.Net8/Tests/TestRunner.cs | Refactors to reuse single SimConnectClient and updates test iteration |
| tests/SimConnect.NET.Tests.Net8/Tests/ConnectionTests.cs | Replaces unused local variables with discard operator |
| tests/SimConnect.NET.Tests.Net8/Tests/AIObjectTests.cs | Uses explicit double casts for position offset calculations |
Comments suppressed due to low confidence (1)
tests/SimConnect.NET.Tests.Net8/Tests/TestRunner.cs:121
- This foreach loop immediately maps its iteration variable to another variable - consider mapping the sequence explicitly using '.Select(...)'.
foreach (var resultTask in testsToRun.Select(test => this.RunSingleTestAsync(test)))
{
var result = await resultTask;
results.Add(result);
if (!result.Passed && options.StopOnFirstFailure)
{
Console.WriteLine("🛑 Stopping on first failure as requested");
break;
}
// Small delay between tests
await Task.Delay(500);
Console.WriteLine();
}
llamavert
approved these changes
Nov 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request delivers a set of improvements aimed at making SimConnect.NET more reliable, predictable, and easier to diagnose. It introduces safer exception handling across all background loops, improves struct based SimVar writing, strengthens input event parsing, and updates integration tests for better stability. The release also bumps the version to 0.1.17 and updates the changelog.
Changes Made
Additional Information
These changes collectively make exception behaviour more predictable, improve SimVar struct layout correctness, reduce hidden crashes in user code paths, and strengthen the overall test harness to prevent intermittent failures.
Author Information
Discord Username: AussieScorcher
Checklist: