feat: add support for struct simvar marshalling#9
Merged
AussieScorcher merged 4 commits intostopbars:mainfrom Aug 25, 2025
Merged
feat: add support for struct simvar marshalling#9AussieScorcher merged 4 commits intostopbars:mainfrom
AussieScorcher merged 4 commits intostopbars:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for struct-based SimVar marshalling, allowing developers to retrieve multiple SimVars in a single request by defining structs annotated with SimConnect attributes.
- Added struct marshalling capability through a new
GetAsync<T>()overload that accepts struct types - Introduced
SimConnectAttributefor annotating struct fields with SimVar metadata - Created infrastructure classes for struct binding, field ordering, and data type sizing
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| SimVarManager.cs | Added new GetAsync<T>() overload for struct marshalling with reflection-based field binding and data parsing |
| SimConnectAttribute.cs | New attribute class for annotating struct fields with SimVar name, unit, and data type information |
| SimVarStructBinder.cs | Internal utility for validating struct layouts and building SimConnect data definitions from annotated fields |
| SimVarDataTypeSizing.cs | Utility class providing size calculations and offset computations for SimConnect data types |
| SimVarTests.cs | Added test case demonstrating struct marshalling with a Position struct containing latitude, longitude, and altitude |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
undoing this suggestion from copilot since it caused the build to fail
AussieScorcher
approved these changes
Aug 25, 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
Added support to
GetAsyncto retrieve an entire structure at once.Example:
This will populate a struct like:
Changes Made
GetAsyncto return a struct.Additional Information
May need some polish but seems to be working.
orderattribute is not required. If set, attributes with an order are sorted first; otherwise, ordering falls back to struct field order.Tried to make attributes optional where possible.
name,unit, andSimConnectDataTypeexplicitly.null, the code attempts to look up the info from the registry.Nameis required.Overloads the existing
GetAsyncmethod.[StructLayout(LayoutKind.Sequential)]may not be necessary based on late testing.Author Information
Discord Username:
bstudtmaChecklist
[x] Have you followed the guidelines in our Contributing document?
[x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?