[PR #1835] [MERGED] fix(managed): decode generic, array, fnptr, and modifier signatures #4846

Closed
opened 2026-10-31 00:55:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1835
Author: @kaoru0822-kitauji
Created: 10/11/2026
Status: ✅ Merged
Merged: 10/11/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/managed-signature-element-types


📝 Commits (6)

  • ab83f7a fix(managed): decode generic, array, fnptr, and modifier signatures
  • 754aec8 fix(managed): bound array rank before rendering dimensions
  • 1ecffcb fix(managed): keep modifier order and reject non-method fnptr headers
  • 144fa3b Merge remote-tracking branch 'origin/main' into fix/managed-signature-element-types
  • 2e0f0e2 fix(managed): reject corrupt fnptr flags and misplaced typed references
  • f013f9f fix(managed): decode signature elements by grammar position

📊 Changes

4 files changed (+478 additions, -67 deletions)

View changed files

📝 src/dotnet/ManagedMemberInspector.test.ts (+184 -5)
📝 src/dotnet/ManagedMemberInspector.ts (+1 -1)
📝 src/dotnet/ManagedMemberInspectorCore.ts (+290 -58)
📝 tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts (+3 -3)

📄 Description

Summary

Fixes #1832.

inspect_managed_members reported ordinary ECMA-335 member signatures as parse_status: "unsupported" when they used:

  • GENERICINST (0x15)
  • ARRAY (0x14)
  • FNPTR (0x1b)
  • CMOD_REQD and CMOD_OPT (0x1f/0x20)
  • TYPEDBYREF (0x16)

Those members got no return_type, parameter_types, or field_type, and the whole inspection dropped to coverage.state: "partial". That happens for any assembly with generic members, such as Dictionary<string, object>.

Change

readTypeSignature now decodes with an explicit continuation stack. These signatures nest (generic arguments, function-pointer parameters), so this keeps the existing guarantee that decoding never recurses; a new test decodes 4,000 nested generic levels.

Element type Rendering
GENERICINST class:113<string>, valuetype:10<var:0,mvar:1>
ARRAY ILAsm bounds: i4[1...4,-1...1], string[5,,], and i4[...] for an unbounded rank-1 array (bare [] stays reserved for SZARRAY)
FNPTR fnptr[<calling convention>](params)->return
CMOD_REQD / CMOD_OPT i4 modreq:9, i4 modopt:13*
TYPEDBYREF typedbyref
  • Class and valuetype operands keep their encoded TypeDefOrRefOrSpec values, as before.
  • raw_length and raw_sha256 are unchanged.

What still does not decode:

  • Malformed shapes report malformed: a generic instantiation with no arguments or a non-class/valuetype head, a zero-rank array, more sizes or lower bounds than dimensions, and truncation.
  • Element types that member signatures don't assign still report unsupported. Vararg sentinels (0x41) are among these; I left them out so parameter_types stays consistent with parameter_count.

The limitation text now lists the decoded forms. One comparison boundary test had used [0x06, 0x15] as its example of an undecodable field. That blob is now a truncated GENERICINST (malformed), so the test uses the unassigned element type 0x7f to keep its intent.

Validation

  • src/dotnet/ManagedMemberInspector.test.ts gains:
    • an inspection test using the method signature from #1832 (20 01 01 15 12 71 01 0e shape) and a generic field signature, which reaches coverage: complete
    • table-driven decode cases for each element type, including combinations
    • malformed cases
    • the 4,000-level recursion test
  • npm run test:focused passes on the managed source, boundary, and MCP suites (20 files, 173 tests).
  • npm run check:fast and npm run docs:check pass.
  • Not run against System.Runtime.Caching.dll or other real framework assemblies; this macOS host has no .NET install.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1835 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/11/2026 **Status:** ✅ Merged **Merged:** 10/11/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/managed-signature-element-types` --- ### 📝 Commits (6) - [`ab83f7a`](https://github.com/morluto/rea/commit/ab83f7a595c5ec7a3625cebb4f1be7c3138c57ec) fix(managed): decode generic, array, fnptr, and modifier signatures - [`754aec8`](https://github.com/morluto/rea/commit/754aec8c74cf2adb44a8031cfd783cdac7298596) fix(managed): bound array rank before rendering dimensions - [`1ecffcb`](https://github.com/morluto/rea/commit/1ecffcb01c8e6c128671394c5c583cd88e780f82) fix(managed): keep modifier order and reject non-method fnptr headers - [`144fa3b`](https://github.com/morluto/rea/commit/144fa3be67bdd308aaeaeb81865f079ff6bbecb3) Merge remote-tracking branch 'origin/main' into fix/managed-signature-element-types - [`2e0f0e2`](https://github.com/morluto/rea/commit/2e0f0e2f62dac50e90f72086efae48ca8964770e) fix(managed): reject corrupt fnptr flags and misplaced typed references - [`f013f9f`](https://github.com/morluto/rea/commit/f013f9f28cb9aaf60aece44ada6b4b66d57d5147) fix(managed): decode signature elements by grammar position ### 📊 Changes **4 files changed** (+478 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `src/dotnet/ManagedMemberInspector.test.ts` (+184 -5) 📝 `src/dotnet/ManagedMemberInspector.ts` (+1 -1) 📝 `src/dotnet/ManagedMemberInspectorCore.ts` (+290 -58) 📝 `tests/boundary/providers/managed/managedMemberComparisonFromMetadata.test.ts` (+3 -3) </details> ### 📄 Description ## Summary Fixes #1832. `inspect_managed_members` reported ordinary ECMA-335 member signatures as `parse_status: "unsupported"` when they used: - GENERICINST (0x15) - ARRAY (0x14) - FNPTR (0x1b) - CMOD_REQD and CMOD_OPT (0x1f/0x20) - TYPEDBYREF (0x16) Those members got no `return_type`, `parameter_types`, or `field_type`, and the whole inspection dropped to `coverage.state: "partial"`. That happens for any assembly with generic members, such as `Dictionary<string, object>`. ## Change `readTypeSignature` now decodes with an explicit continuation stack. These signatures nest (generic arguments, function-pointer parameters), so this keeps the existing guarantee that decoding never recurses; a new test decodes 4,000 nested generic levels. | Element type | Rendering | | --- | --- | | GENERICINST | `class:113<string>`, `valuetype:10<var:0,mvar:1>` | | ARRAY | ILAsm bounds: `i4[1...4,-1...1]`, `string[5,,]`, and `i4[...]` for an unbounded rank-1 array (bare `[]` stays reserved for SZARRAY) | | FNPTR | `fnptr[<calling convention>](params)->return` | | CMOD_REQD / CMOD_OPT | `i4 modreq:9`, `i4 modopt:13*` | | TYPEDBYREF | `typedbyref` | - Class and valuetype operands keep their encoded TypeDefOrRefOrSpec values, as before. - `raw_length` and `raw_sha256` are unchanged. What still does not decode: - Malformed shapes report `malformed`: a generic instantiation with no arguments or a non-class/valuetype head, a zero-rank array, more sizes or lower bounds than dimensions, and truncation. - Element types that member signatures don't assign still report `unsupported`. Vararg sentinels (0x41) are among these; I left them out so `parameter_types` stays consistent with `parameter_count`. The limitation text now lists the decoded forms. One comparison boundary test had used `[0x06, 0x15]` as its example of an undecodable field. That blob is now a truncated GENERICINST (malformed), so the test uses the unassigned element type 0x7f to keep its intent. ## Validation - `src/dotnet/ManagedMemberInspector.test.ts` gains: - an inspection test using the method signature from #1832 (`20 01 01 15 12 71 01 0e` shape) and a generic field signature, which reaches `coverage: complete` - table-driven decode cases for each element type, including combinations - malformed cases - the 4,000-level recursion test - `npm run test:focused` passes on the managed source, boundary, and MCP suites (20 files, 173 tests). - `npm run check:fast` and `npm run docs:check` pass. - Not run against `System.Runtime.Caching.dll` or other real framework assemblies; this macOS host has no .NET install. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:55:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4846
No description provided.