Skip to content

fix: use null unit when subscribing to string SimVars - #18

Open
airxiti2 wants to merge 1 commit into
stopbars:mainfrom
airxiti2:fix/string-subscription-unit
Open

airxiti2 wants to merge 1 commit into
stopbars:mainfrom
airxiti2:fix/string-subscription-unit

Conversation

@airxiti2

Copy link
Copy Markdown

Summary

Fixes a bug that prevented subscribing to string SimVars. The library previously passed "string" as the unit, but SimConnect requires the unit to be null for string data types.

Changes Made

  • Pass null as the unit when creating data definitions for string SimVars.
  • Allow nullable unit names in the native SimConnect declaration.

Additional Information

Author Information

Discord Username: airxiti


Checklist:

  • [ 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?

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects scalar string requests in SimVar workflows.

The string-unit fix should cover struct subscriptions before merging.

Findings

  1. P1 Struct subscriptions still fail ▶
Fix with agent prompt
### Issue 1
src/SimConnect.NET/SimVar/SimVarManager.cs:866-868
The fix only covers scalar subscriptions. `Subscribe<T>(period, onValue)` calls `EnsureTypeDefinition<T>`, which still passes `unit ?? string.Empty` to `SimConnect_AddToDataDefinition`. String fields therefore send `"string"` or an empty string instead of the required null pointer, so these subscriptions remain broken. Apply the same string-type check in that registration path.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR sends a null unit when registering scalar string SimVars and allows null in the native declaration.

  • String SimVar reads and subscriptions send no unit to SimConnect.

Reviews (1) · Last reviewed commit: "fix: use null unit when subscribing to s..." · Reviewed by Greptile

Comment on lines +866 to +868
if (IsStringDataType(dt))
{
unit = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Struct subscriptions still fail

The fix only covers scalar subscriptions. Subscribe<T>(period, onValue) calls EnsureTypeDefinition<T>, which still passes unit ?? string.Empty to SimConnect_AddToDataDefinition. String fields therefore send "string" or an empty string instead of the required null pointer, so these subscriptions remain broken. Apply the same string-type check in that registration path.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/SimConnect.NET/SimVar/SimVarManager.cs
Line: 866-868

Comment:
**Struct subscriptions still fail**

The fix only covers scalar subscriptions. `Subscribe<T>(period, onValue)` calls `EnsureTypeDefinition<T>`, which still passes `unit ?? string.Empty` to `SimConnect_AddToDataDefinition`. String fields therefore send `"string"` or an empty string instead of the required null pointer, so these subscriptions remain broken. Apply the same string-type check in that registration path.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant