Repository navigation
fix(managed): report member signature issues at artifact offsets - #7879
Conversation
Field, MethodDef and MemberRef signature issues reported the invalid operand's offset inside its blob, while local signature issues in the same coverage array used artifact file offsets. Translate both through one helper that adds the blob's artifact base. Fixes morluto#7385
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Low impact] The changed code appears safe to merge; no actionable issues were found. SummaryCorrects member-signature error locations by translating blob-relative offsets into artifact file offsets.
No actionable issues or security concerns were found in the changed paths. Tests were not run during this review. Whether another PR supersedes this one could not be checked because GitHub authentication was unavailable. Reviews (1) · Last reviewed commit: "fix(managed): report member signature is..." · Reviewed by Greptile |
Summary
Fixes #7385.
inspect-managed-membersreported an invalid operand in a Field, MethodDef or MemberRef signature at its offset inside the signature blob, while the equivalent StandAloneSig (local variable) issue in the samecoverage.issuesarray used the artifact file offset. On the issue's fixture the field issue saidoffset: 2(a DOS-header byte) instead of1229.Problem and expected behavior
Fixture from the issue:
fieldSignature = 06 12 07(FIELD, CLASS, TypeDefOrRefOrSpec0x07whose tag 3 is undefined per ECMA-335 II.23.2.8) and a LocalVarSig07 01 12 07with the same operand. On basee79ad6cathe compiled CLI prints:{"state":"partial","issues":[ {"code":"invalid-row","scope":"Field:0x04000001.signature","offset":2,"detail":"TypeDefOrRefOrSpec operand 0x7 is invalid: coded index tag 3 is not defined"}, {"code":"invalid-row","scope":"metadata.StandAloneSig:0x11000001.signature","offset":1238,"detail":"TypeDefOrRefOrSpec operand 0x7 is invalid: coded index tag 3 is not defined"}]}The convention is artifact file offsets: CHANGELOG ("Metadata errors report artifact file offsets") and
readLocalSignatureFacts, which already adds the blob's artifact base.metadataSignatureforwarded the decoder's blob-relative offset unchanged, and its only caller,budgetedSignature, never had the blob's position.Change and scope
ManagedMemberInspectorCore.ts: one helper,artifactSignatureIssue, translates a decoder issue into artifact coordinates.readLocalSignatureFactsnow uses it instead of its inline copy, andmetadataSignaturetakes a requiredblobOffsetand applies it to every issue it receives from the decoder. So both signature paths share one owner for the translation.ManagedMemberRows.ts:budgetedSignaturereceives the artifact buffer it read the blob from and passesblob.byteOffset - artifact.byteOffset, the same derivationManagedMethodBodyReaderuses for local signatures. The Field, MemberRef and MethodDef call sites pass it.Not changed: the separate
Expected field signature; decoded methodissue keepsoffset: null, since it describes the whole blob rather than a byte. Scopes, details, decoded signatures and coverage state are unchanged.Follow the contribution scope.
Ordinary fix within existing boundaries; a maintainer scope decision is not applicable.
Contract and boundary impact
metadataSignature, the metadata-owned signature decoder insrc/dotnet/ManagedMemberInspectorCore.ts. Consumer:budgetedSignatureinsrc/dotnet/ManagedMemberRows.ts.coverage.issues[].offsetfor Field/MethodDef/MemberRef signature issues changes from blob-relative to artifact file offset.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
All evidence below was executed.
Tests added: three cases in
src/dotnet/ManagedMemberInspector.test.ts, next to the existing local-signature offset cases. Each builds a fixture whose Field, MethodDef or MemberRef signature ends inCLASS 0x07. The test finds the blob's artifact offset through the production row cursor andreadMetadataBlob, checks that the byte there is0x07, and requires the exact issue (code,scope,offset,detail) incoverage.issues.Base reproduction: with only the new tests on
e79ad6ca, the file had 3 failures / 191 passes. Received offsets were2,4,4; expected1221,1226,1230. Scopes and details already matched.User-visible CLI output after the fix, same fixture as above:
{"state":"partial","issues":[ {"code":"invalid-row","scope":"Field:0x04000001.signature","offset":1229,"detail":"TypeDefOrRefOrSpec operand 0x7 is invalid: coded index tag 3 is not defined"}, {"code":"invalid-row","scope":"metadata.StandAloneSig:0x11000001.signature","offset":1238,"detail":"TypeDefOrRefOrSpec operand 0x7 is invalid: coded index tag 3 is not defined"}]}The fixture's bytes at 1226..1229 are
03 06 12 07(length prefix, FIELD, CLASS, operand), so 1229 is the invalid operand.Remaining proof gaps: Windows only; synthetic fixtures only, no real compiler output with a malformed signature. MCP was exercised only through the existing managed MCP suites. Hosted CI is pending.
For boundary fixes: this is a metadata blob parser boundary; the new cases sit beside the existing StandAloneSig offset regressions.
For evidence-bearing changes:
Validation performed
Windows 11 x64 (10.0.26200), Node 24.22.1, npm 11.19.1, base
e79ad6ca. The Windows native addon and manifest came from the[email protected]tarball, as CONTRIBUTING describes.npm run test:focused -- src/dotnet/ManagedMemberInspector.test.ts: base 3 failed / 191 passed; with the fix 194/194 passed.npm run test:focused --with everysrc/dotnet/*.test.tsfile plusmanagedCliOutput,managedMetadataDelta,managedMemberSummaryCliandmanagedStaticProvider: 556/556 passed across 20 files.npm run test:focused --withmanagedMemberComparisonCli,managedMcp,managedMemberSummaryMcp,managedMemberComparisonandmanagedMemberComparisonFromMetadata: 141/141 passed.node scripts/rea.mjs inspect-managed-members both-signatures.dll --jsonon the issue fixture, base and fixed builds: output shown above.npm run check:fast: typecheck and lint 2/2 passed.npx oxfmt --checkon the changed files: passed.Compatibility, safety, and release
offsetvalue of affected signature issues changes.Author readiness
Human owner: @Plastic-time
Before merge
type(scope): outcome.