Skip to content

fix: support optional member detection with MSVC#353

Merged
webern merged 1 commit into
webern:mainfrom
rpatters1:windows-build-fix
Jul 14, 2026
Merged

fix: support optional member detection with MSVC#353
webern merged 1 commit into
webern:mainfrom
rpatters1:windows-build-fix

Conversation

@rpatters1

@rpatters1 rpatters1 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the mx::api build with MSVC by making optional-member setter detection two-stage. Resolves #352.

The helper macros now confirm that a generated core type exposes the field accessor before evaluating setter expressions that depend on the field’s optional value type. This prevents MSVC from diagnosing absent attributes such as font decoration and stop-length fields on types that do not support them.

Validation

  • Configured and built mx with CMake and Visual Studio 2022/MSVC.
  • mx.lib links successfully.
  • git diff --check passes.

Notes

  • There are still a number of pedantic lint warnings with /W4, so users should use /W3 for MSVC builds.
  • There is a potential name conflict in FontData.h with the small macro in the WinAPI header rpcndr.h. This PR does not address that issue.

Check that an optional field accessor exists before forming setter expressions that depend on its type.
This prevents MSVC from instantiating references to absent generated core members while building mx::api.
@github-actions

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.8% 28514 / 36648
Functions 74.2% 6352 / 8556
Branches 50.7% 22680 / 44751

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 84.5% 7237 / 8560
Functions 74.9% 2511 / 3352
Branches 52.4% 6327 / 12068

Core HTML report | API HTML report

Commit caec11106a87a4aa66e3cd6b74a9ce882a7b04a0.

@github-actions

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit caec11106a87a4aa66e3cd6b74a9ce882a7b04a0.

@webern webern left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you. I'll get Windows added to CI soon.

@webern
webern merged commit 5ee9908 into webern:main Jul 14, 2026
10 checks passed
webern added a commit that referenced this pull request Jul 15, 2026
## Human Summary

CI was hard to understand so I am attempting to simplify it.

## Summary

The Makefile target names and the CI job layout had both drifted into
something
hard to follow. This pass makes both legible around one mental model: a
single
product (`mx::api`) on a substrate (`mx::core`), plus a dev tool
(`gen/`).

Makefile:

- Targets renamed to a consistent area-first `<area>-<action>` scheme:
  `core-build` / `core-roundtrip-test` / `core-unit` / `core-coverage`,
`api-lib` / `api-build` / `api-test` / `api-roundtrip` / `api-coverage`,
plus `gen-test`, `audit-test`, `fmt-check`, and the `api-roundtrip-*`
helpers.
- New `test-all` runs every C++ suite at once (core roundtrip + unit +
api-test
  + api-roundtrip) — the deep gate CI uses on Linux.
- Deleted four low-value or redundant targets and their drivers:
`validate-cpp`
(plus `mxtest/validate/` and the `mxtest-validate` CMake target),
`probe-cpp`
(plus `mxtest/probe/`), `check-core-dev`, and `gen-check` (its rename
and
  collision checks already run during real generation).

CI, from ten always-on jobs down to a leaner set:

- `test-linux` (`make test-all`), `test-macos` (native AppleClang, api
tier),
  `test-windows` (new — native MSVC, driving CMake directly), `swift`,
`quality` (fmt-check + generated-output drift), and a `gen` job gated on
  changes under `gen/`.
- `test-windows` is a required check and is expected to stay red until
the code
  is MSVC-clean; it exists so that fallout runs on every PR from now on.
- Coverage moved out of the always-on run into a new manual-only
`coverage.yaml`, triggered by the workflow's Run button or a `/coverage`
  comment on a PR. It posts the same gcovr tables to the PR as before.

`pr-comment.yaml` is unchanged; it still posts the gen-quality comment
for fork
PRs. Docs, skills, and instruction files are updated to the new names.

## Testing

This is a CI/build change, so the workflows running on this PR are the
real
test. Verified locally:

- [x] `make help` renders, and `make -n test-all` resolves the full
dependency
  chain in both the in-container and docker-wrapper branches
- [x] Every dual-branch target is defined exactly once per branch, and
no stale
  target names remain outside `docs/ai/design/` (kept as historical)
- [x] All three workflow files parse as YAML
- [x] Full suites and coverage run in CI on this PR (not run locally)

## References

- Related: #354 (the `small` / `rpcndr.h` MSVC conflict the new Windows
job will
surface) and #353 (the recent MSVC build fix this CI job guards going
forward)


---
_Generated by [Claude
Code](https://claude.ai/code/session_01K3cW6EXsTowPxbmPSRVNAH)_
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.

Windows build fails with compiler errors

2 participants