Skip to content

fix(generator): emit string macros as strings, not floats - #4

Merged
jcant0n merged 1 commit into
mainfrom
fix/string-macro-constants
Aug 4, 2026
Merged

fix(generator): emit string macros as strings, not floats#4
jcant0n merged 1 commit into
mainfrom
fix/string-macro-constants

Conversation

@jcant0n

@jcant0n jcant0n commented Aug 4, 2026

Copy link
Copy Markdown
Member

main currently does not compile. The CD committed this and then failed to pack it:

public const float JOLT_VERSION = "5.5.0";

Cause

The macro classifier decided the type from the value's shape:

else if (value.EndsWith("f") || value.Contains("."))
    type = "float";

A quoted string containing a dot satisfies that. JOLTC_JOLT_VERSION "5.5.0" — which I added to JoltPhysicsC so the binding could state which Jolt it wraps — is exactly that shape. The change that made the version legible is the change that broke the build.

Fix

  • String macros are recognised before the numeric guesses. A quoted string can contain anything that looks like a number, so it has to be tested first.
  • The float case uses TryParse. "Contains a dot or ends in f" accepted any value with punctuation in it and emitted a float declaration initialised with something that is not a float. The next such macro would have failed the same way.

public const string JOLT_VERSION = "5.5.0" is also the outcome worth having: a consumer reads the wrapped JoltPhysics version off the binding, instead of chasing two repositories and resolving a commit against a tag list.

Verified by regenerating — binding, API tests and sample all build.

Why CI did not catch it

CI regenerates from the vendored headers, which predate the version macro. The CD fetches from the tracked release tag, which contains it. So the first run that could see this was the first run after switching to release tracking.

That run was a dry run with skip-assets-publishing, so nothing reached nuget.org. The cost was a red main for the length of this pull request.

🤖 Generated with Claude Code

The CD committed `public const float JOLT_VERSION = "5.5.0";` to main and then failed to
pack it. The macro classifier decided the type by looking at the value:

    else if (value.EndsWith("f") || value.Contains("."))
        type = "float";

A quoted string containing a dot satisfies that. JOLTC_JOLT_VERSION, which I added to
JoltPhysicsC yesterday so the binding could state which Jolt it wraps, is exactly that
shape -- so the change that made the version legible is the change that broke the build.

Two corrections. String macros are recognised before the numeric guesses, because a
quoted string can contain anything that looks like a number. And the float case now uses
TryParse instead of "contains a dot or ends in f", which accepted any value with
punctuation and emitted a float initialised with something that is not one.

`public const string JOLT_VERSION = "5.5.0"` is also the useful outcome: a consumer can
read the wrapped JoltPhysics version off the binding without chasing two repositories.

Verified by regenerating: the binding, the API tests and the sample all build.

Worth noting how this surfaced. CI passed on the pull request because it regenerates from
the *vendored* headers, which predate the version macro. The CD fetches from the tracked
release tag, which contains it. So the first run that could see this was the first run
after switching to release tracking -- and it was a dry run with publishing off, so
nothing shipped.
@jcant0n
jcant0n merged commit 5db3900 into main Aug 4, 2026
4 of 5 checks passed
@jcant0n
jcant0n deleted the fix/string-macro-constants branch August 4, 2026 09:42
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