Skip to content

feat(managed): name the declaring type of call and field targets - #2163

Merged
morluto merged 12 commits into
morluto:mainfrom
Nelglor:feat/managed-call-target-types
Oct 13, 2026
Merged

morluto merged 12 commits into
morluto:mainfrom
Nelglor:feat/managed-call-target-types

Conversation

@Nelglor

@Nelglor Nelglor commented Oct 12, 2026 •

Copy link
Copy Markdown

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

Summary

Fixes #2160.

Call edges named external targets by member name alone, method-spec edges had no name, and field accesses through MemberRefs had no name either. This names the declaring type of every edge target and of each MemberRef parent. Callers can now tell UnityEngine.JsonUtility.ToJson from Newtonsoft.Json.JsonConvert.ToJson, and find every use of a type, without a decompiler.

Problem and expected behavior

Smallest trigger: any call to a MemberRef. target_name is Join, and member_refs[].parent_token points at a TypeRef that no output names. A call to a MethodSpec reports target_name: null. An ldsfld of a MemberRef field reports field_name: null, because the field path only consulted FieldDef rows.

Expected:

  • Each target carries its declaring type in the namespace-qualified form TypeDef full_name already uses.
  • Unknown stays null.
  • Malformed rows stay visible as partial coverage.

Change and scope

  • Type naming: new src/dotnet/ManagedTypeNames.ts. typeNameLookup names a TypeDef from the existing ranges, a TypeRef from its row, and a GENERICINST TypeSpec by its generic type, once per token. TypeSpec blobs are decoded whole with the existing signature grammar through a new specSignature. A GENERICINST base must be a TypeDef or TypeRef (ECMA-335 II.23.2.12), so naming never recurses. Malformed or unsupported blobs and out-of-range rows are reported against their row. TypeRef ResolutionScope chains are checked transitively with cycle detection (morluto, e59217c and a78f3b4). An invalid or cyclic scope is reported as invalid-row and the readable name is kept. A null scope is valid. Type operands inside spec blobs, including nested arguments and custom modifiers, are validated against the metadata tables, and a failure is reported under the owning TypeSpec or MethodSpec row. Other well-formed TypeSpec forms stay null without an issue.
  • Member refs: parseMemberRefs records parent_name and uses it as the MemberRef's declaring type, with its decoded signature kind.
  • One lookup: MethodCore, FieldCore and MemberRefCore were three shapes of the same fact. They merge into one MemberCore with a declaring type and a kind. edgeTargets indexes fields, member refs and methods by token, then adds each MethodSpec an inspected body calls under the generic method it instantiates. MethodSpec reading lives in src/dotnet/ManagedMethodSpecs.ts. It validates the Method column and the Instantiation blob, and checks that the method's signature decodes completely as a generic method with as many parameters as the instantiation supplies. The arity comes from the signature the target's owner already decoded (MemberCore.genericArity for MemberRefs and selected MethodDefs). Only a target nothing decoded, such as a MethodDef outside a --type selection, falls back to a transient raw decode, cached per target method. A readable Method keeps its name beside a malformed instantiation or an arity mismatch, with partial coverage. edges resolves every target through that single map instead of methodCore ?? refCore and a separate field map.
  • Signature headers: every method signature goes through readMethodSignatureHeader, which now checks the header against its context. MethodDef and MemberRef rows accept only MethodDefSig/MethodRefSig headers (ECMA-335 II.23.2.1-2): DEFAULT, VARARG, or GENERIC with DEFAULT, plus HASTHIS/EXPLICITTHIS. FNPTR keeps the unmanaged C, STDCALL, THISCALL, FASTCALL and UNMANAGED conventions that compilers emit. A field signature must be exactly FIELD (II.23.2.4). Any other header is malformed. That includes PROPERTY, LOCAL_SIG, GENERICINST, a flagged FIELD, the reserved bit, and EXPLICITTHIS without HASTHIS. Such a member never passes the MethodSpec arity check and never names a field.
  • Kind guard: a field operand is named only by a field or a field-signature MemberRef. A call operand is named by a method, or by a MemberRef whose signature does not decode, which keeps the previous call-edge behavior. For example, a call on a FieldDef token and an ldsfld on a method MemberRef stay unnamed.
  • Schema: member_refs[].parent_name, call_edges[].target_declaring_type and field_accesses[].field_declaring_type are added as nullable().default(null), so older Evidence reads them as unknown.
  • Fixture: gains optional TypeSpec rows, MethodSpec rows and a MemberRef name. Default fixture bytes are unchanged.

Not included:

  • Cross-assembly resolution. AssemblyRef scopes are not followed.
  • Type-forwarder resolution.
  • Names for ModuleRef or MethodDef MemberRef parents.
  • Array or other non-generic TypeSpec names.
  • Any change to nested type naming. Bare nested names stay, matching TypeDef full_name.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/dotnet. Type naming has one owner, typeNameLookup, and edge target resolution has one owner, edgeTargets.
  • CLI and MCP/tool-catalog contract: three additive output fields on inspect_managed_members. For method-spec edges, target_name changes from always null to the generic method's name when the MethodSpec row resolves. A member signature whose header is neither an exact FIELD nor a MethodDefSig/MethodRefSig header, such as PROPERTY, C, or a flagged FIELD, now reports kind: unknown and parse_status: malformed instead of decoding as a method or field.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: additive and nullable. Older Evidence parses with the new fields null. Tokens, anchors and digests are unchanged.
  • Process execution, authorization, cleanup, or containment impact: none. Static parsing only.
  • Generated metadata, package, or installation impact: none committed.

Evidence and regression coverage

  • Tests added or updated, all in src/dotnet/ManagedMemberInspector.test.ts:

    • The existing end-to-end test now asserts parent_name, target_declaring_type and field_declaring_type.
    • MethodSpec calls are named after their MemberRef and MethodDef generic methods.
    • A generic TypeSpec parent names its generic type. An SZARRAY TypeSpec stays null with complete coverage.
    • Four malformed generic TypeSpecs give partial coverage and a null name: a TypeSpec base, a missing argument count, and out-of-range TypeRef and TypeDef rows.
    • A malformed MethodSpec instantiation keeps its method's name with partial coverage. An invalid Method coded index is reported and unnamed.
    • A MethodSpec on a non-generic method, with the wrong argument count, or on a field reference is reported as invalid-row.
    • Unsupported TypeSpec and MethodSpec forms raise unsupported-signature instead of reading as unknown.
    • A MethodSpec on a PROPERTY-header, C-convention, or truncated generic MemberRef signature is reported as invalid-row. Member signatures with a PROPERTY, C, or GENERIC|VARARG header, or with EXPLICITTHIS but no HASTHIS, are malformed.
    • A MemberRef with a flagged FIELD header stays unnamed under ldsfld, with partial coverage.
    • A TypeRef with an out-of-range ResolutionScope keeps its name, with an invalid-row issue and partial coverage.
    • A MethodSpec over a field-signature MemberRef stays unnamed under both ldsfld and call.
    • A field-signature MemberRef is named under ldsfld. A method-signature MemberRef under ldsfld, and a call with a FieldDef operand, stay unnamed.
    • Legacy Evidence without the fields parses them as null.
  • Base reproduction: on main, PEAK's Peak.Quicksave (Unity Mono Assembly-CSharp.dll, --type Peak.Quicksave) shows SaveNow -> ToJson, WriteAllText and LoadSaveData -> ReadAllText, plus method-spec 0x2b0002a5 null.

  • User-visible CLI output, same command on this branch, with complete coverage:

    get_SavePath -> UnityEngine.Application.get_persistentDataPath  [member-ref]
    get_SavePath -> System.IO.Path.Join                             [member-ref]
    SaveNow      -> UnityEngine.JsonUtility.ToJson                  [member-ref]
    SaveNow      -> System.IO.File.WriteAllText                     [member-ref]
    LoadSaveData -> System.IO.File.ReadAllText                      [member-ref]
    LoadSaveData -> UnityEngine.JsonUtility.FromJson                [method-spec]
    

    3,830 of 3,841 member refs get a parent_name, and every field access in the class is named, for example Zorro.Core.BuildVersion.MinorVersion. The other 11 have multidimensional-array TypeSpec parents, which stay null by design.

  • Remaining proof gaps: no real-provider lane applies. Fixtures are source-built. The PEAK assembly is a third-party game binary and is not committed.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

All runs used Node 24.18.0 and npm 11.16.0, per .nvmrc and packageManager.

  • npm run check: passed, including architecture guards. Lint has no new warnings against main. Existing size and complexity warnings in touched files moved by a few lines, and ManagedMemberInspectorCore.ts got shorter.
  • npm run docs:check: passed.
  • npm run verify:test-discovery: passed.
  • npm run test:focused -- on the same 26 managed test files as the sibling PR: 322 passed.
  • Built CLI across real assemblies (a whole 247 KB Unity Assembly-CSharp.dll, PEAK and Valheim type selections, Mono mscorlib.dll List1, Unity.InputSystem.dll): complete coverage, with all 247 method-spec` edges named and arity-checked.
  • Built CLI against PEAK Assembly-CSharp.dll with --type Peak.Quicksave: complete coverage, output above.
  • Type selections whose MethodSpec edges target MethodDefs outside the selection stay complete, and every method-spec edge is named. Mono mscorlib with List`1 and Array selected has at least 16 such edges out of 56. Valheim with Player and ZNet has at least 22 of 137. PEAK Peak.Quicksave has 1 of 2.
  • Signature header check: decoded every FieldDef, MethodDef and MemberRef signature in seven real assemblies (Mono mscorlib, System.Xml, UnityEngine.CoreModule, Unity.InputSystem, and three game assemblies). That is 170,725 signatures: 61,620 fields and 109,105 methods and member references. The header checks reject none of them, and every one still decodes. Member headers seen were only 0x00, 0x05, 0x10, 0x20, 0x30 and exactly 0x06.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Fields are additive and nullable. method-spec target_name goes from null to a value when resolvable.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable. Linux x64 only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: names come from the caller's artifact metadata. Nothing is executed. TypeRef rows read through metadataRowCursor are charged to the existing budget, and each type is named once.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

#2162 is a sibling PR that touches the same schema, fixture and docs section. Whichever merges second will need a small rebase.

🤖 Generated with Claude Code

Call edges named external targets by member name alone (Join, ToJson,
WriteAllText), and method-spec edges had no name at all, so an analyst could
not tell which library a method calls or find every use of a type without a
decompiler. Field accesses through MemberRefs had no name either.

Name each TypeDef, TypeRef, and generic-instantiation TypeSpec once, in the
namespace-qualified form TypeDef full_name uses, and add member_refs
parent_name, call_edges target_declaring_type, and field_accesses
field_declaring_type. A method-spec target reports the generic method it
instantiates. Fields, member references, methods, and method specs now
resolve through one token-keyed MemberCore lookup instead of three maps.
Evidence recorded before these fields reads them as null.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T13:20:29.578050Z cbd7755 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c1cc9055b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedTypeNames.ts Resolved
Comment thread src/dotnet/ManagedMemberRows.ts Resolved
Comment thread src/dotnet/ManagedTypeNames.ts Resolved
Comment thread src/dotnet/ManagedMemberRows.ts Resolved
Comment thread src/dotnet/ManagedTypeNames.ts Resolved
Address review findings on declaring-type naming:

- A generic instantiation must name a TypeDef or TypeRef, so a TypeSpec
  base is reported as malformed instead of followed. Naming no longer
  recurses.
- TypeSpec and MethodSpec instantiation blobs are decoded with the
  member-signature grammar. Malformed blobs and out-of-range TypeDef rows
  are reported against their owning row and make coverage partial.
- A MethodSpec reads both columns. An invalid Method coded index is
  reported; a readable Method keeps its name beside a malformed
  instantiation.
- MemberCore carries its signature kind, so a field operand is named only
  by a field or field-signature MemberRef. This replaces the token-table
  guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Nelglor

Nelglor commented Oct 12, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

Review findings are addressed in the latest commit, with replies on each thread. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ace5cd00be

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedMemberRows.ts Resolved
…lobs

- A MethodSpec now checks that its method signature is generic and that
  the instantiation supplies as many type arguments as it declares. A
  non-generic target, a field reference, or a count mismatch is reported
  as invalid-row; the readable method keeps its name.
- Unsupported TypeSpec and MethodSpec forms raise an owner-scoped
  unsupported-signature issue instead of reading as an intentional
  unknown.
- MethodSpec reading moves to ManagedMethodSpecs.ts, and its tests get
  their own describe block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Nelglor

Nelglor commented Oct 12, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

The arity and unsupported-form findings are addressed in 02bad95, with replies on each thread. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02bad95bee

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedTypeNames.ts Resolved
… scopes

The method signature header reader now owns the calling-convention rule
that only FNPTR applied: FIELD, LOCAL_SIG, PROPERTY, and GENERICINST
headers, the reserved bit, and EXPLICITTHIS without HASTHIS are malformed.
A MethodSpec whose method has a PROPERTY header is no longer accepted as a
generic method, and member signatures with such headers no longer decode
as methods.

The type-name lookup validates a TypeRef's ResolutionScope coded index and
reports an out-of-range scope as invalid-row, keeping the readable name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Nelglor

Nelglor commented Oct 12, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

The header and ResolutionScope findings are addressed in 6fef3ea, with replies on each thread. The description is updated. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fef3eaabe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedMemberRows.ts Resolved
Method signature headers are now checked in context. MethodDef and
MemberRef rows accept only the MethodDefSig/MethodRefSig headers: DEFAULT,
VARARG, or GENERIC with DEFAULT. FNPTR keeps the unmanaged conventions
compilers emit for function pointers. A field signature must be exactly
FIELD, so a flagged FIELD header is malformed and never names a field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Nelglor

Nelglor commented Oct 12, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

The member-convention and FieldSig header findings are addressed in 35eaa30, with replies on each thread. The description is updated, including a corrected count for the real-assembly signature scan. @codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35eaa3062d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedTypeNames.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issue remains.

Summary

Adds declaring-type names to member references, calls, and field accesses. MethodSpec calls now name their generic method.

  • Managed call and field targets now show their declaring type.
  • Generic method calls now show the method they instantiate.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Fields, methods, and member references] --> B[Target lookup]
  C[Decoded method signatures] --> D[Stored generic arity]
  D --> E[Check MethodSpec arguments]
  F[Target outside selected types] --> G[Decode full target signature]
  G --> E
  E --> B
  B --> H[Call and field edges with declaring types]
Loading

Reviews (7) · Last reviewed commit: "fix(managed): reuse owner-decoded signat..." · Reviewed by Greptile

Comment thread src/dotnet/ManagedMethodSpecs.ts Resolved
…ture

The arity check read only the target's signature header, so a truncated
generic method signature passed. Under type selection a MethodDef target
outside the selection is never decoded elsewhere, so coverage stayed
complete. The arity now comes from a transient full decode, and only a
decoded method signature supplies it. signature() keeps its raw length
and digest around the shared decodeSignature.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/dotnet/ManagedMethodSpecs.ts Resolved
Nelglor and others added 3 commits October 13, 2026 07:02
edgeTargets caches the generic arity, including a failed decode, by
target method token, so many instantiations of one generic method share
a single signature decode. Unity.InputSystem has 472 distinct MethodSpecs
over about 133 target methods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
e59217c validates spec type operands inside specSignature, so a
malformed generic TypeSpec base is now invalid-row under its owning
TypeSpec row; the three stale expectations follow that. New cases cover
a TypeSpec argument and a MethodSpec argument that name a missing TypeRef,
and a TypeRef whose ResolutionScope names itself. The scope cases move to
their own describe block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Nelglor

Nelglor commented Oct 13, 2026

Copy link
Copy Markdown
Author

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

Thanks for e59217c and a78f3b4. They supersede my earlier replies on the operand and scope-chain threads.

They changed three existing expectations in ManagedMemberInspector.test.ts, which would fail once CI runs. A malformed generic TypeSpec base is now invalid-row under its owning metadata.TypeSpec row. Before, it was reported against the TypeRef or TypeDef row, or as invalid-blob for a TypeSpec base. 2cc6fee updates those expectations and adds coverage for the new checks:

  • a TypeSpec generic argument and a MethodSpec type argument that name a missing TypeRef
  • a TypeRef whose ResolutionScope names itself (the cycle path)

All of them fail on 9b76dd0 and pass on a78f3b4.

On a78f3b4 with these tests, npm run check, docs:check, test discovery and the 26-file managed suite (321) pass. The operand and scope checks flag nothing in the real assemblies I use. A whole Unity.InputSystem, a whole Unity game assembly, and type selections in Valheim, PEAK, Mono mscorlib and System.Xml all stay complete, with the same member-ref and method-spec naming counts as before.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cc6feeddb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/dotnet/ManagedMethodSpecs.ts Outdated
});
const generic = metadataCodedToken(methodRaw, 1, [6, 10], layout.rowCounts);
const target = generic === null ? undefined : members.get(generic);
if (target !== undefined) members.set(token, { ...target, token });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep field-like MethodSpecs out of field target maps

Fresh evidence after the prior member-kind fix is an ldsfld whose operand is a MethodSpec targeting a field-signature MemberRef: this assignment installs the MethodSpec with inherited kind: "field" before the later arity check reports invalid-row, and namedTarget therefore emits its field_name and declaring type. A MethodSpec is not a valid field operand (and the documented guard permits only FieldDefs or field MemberRefs), so malformed IL now receives positive field evidence instead of unknown; retain any readable method fact without inserting a field-kind MethodSpec.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

Fixed in c0f0bdd. A MethodSpec now borrows its target's name and declaring type only when the target is not a field (kind is method, or unknown for a MemberRef whose signature does not decode). A MethodSpec over a field-signature MemberRef is no longer in the target map. An ldsfld or call on it stays unnamed, and the arity check still reports invalid-row. The docs now say a readable MethodSpec method column keeps its name only when it names a method.

Test: "never names a field through a MethodSpec" puts an ldsfld and a call on a MethodSpec over a FIELD string MemberRef. It expects both to stay unnamed with partial coverage, and it fails on 2cc6fee. npm run check and the managed suite (322) pass. Real assemblies keep every method-spec edge and field access named, with complete coverage.

A MethodSpec over a field-signature MemberRef inherited kind "field", so
an ldsfld on that MethodSpec published a field name and declaring type
for malformed IL. A MethodSpec now borrows its target's name only when
the target is not a field; the arity check still reports it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0f0bdd451

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (!arities.has(generic))
arities.set(
generic,
methodGenericArity(layout, methodSignatureBlob(bytes, layout, generic)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reuse parsed signatures for MethodSpec arity

When a MethodSpec targets a MemberRef or a selected MethodDef, that row's signature has already been fully decoded and retained, but this call rereads and re-renders the same blob. With a large valid generic signature that passed its first blob.length * 256 transient admission, later retained metadata can leave less than that amount in the 64 MiB budget; this duplicate admission then raises resource-limit and makes the outer inspection unavailable even though generic_parameter_count and parse_status are already known. Carry those parsed facts into the target index and only fall back to raw decoding when no owner-parsed signature is available.

AGENTS.md reference: AGENTS.md:L17-L17

Useful? React with 👍 / 👎.

@Nelglor Nelglor Oct 13, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Note

🤖 Claude Opus 5.5 responding on behalf of Nick

Fixed in cbd7755. MemberCore now carries genericArity from the owner's decoded signature. parseMemberRefs sets it for every MemberRef, and parseMethods sets it for each MethodDef in the selection, both from the signature they already decode. One signatureGenericArity rule (a decoded method signature's generic count, else null) serves both and the raw path. readMethodSpec uses that value and reads the raw signature only when no owner decoded it, as for a MethodDef outside the type selection. The per-token cache still covers that fallback.

Behavior is unchanged. The existing MethodSpec arity tests (MemberRef and in-selection MethodDef targets) now go through the owner facts, and the managed suite passes at 322. Real assemblies keep complete coverage with every method-spec edge named, including Mono mscorlib with List`1 and Array selected. That run uses the raw fallback for at least 16 targets outside the selection.

MemberRef signatures, and MethodDef signatures in the type selection, are
already fully decoded, but the MethodSpec arity check decoded them again
and admitted a second transient allocation, which could exhaust the
budget. MemberCore now carries the owner's genericArity, and only a target
nothing decoded, such as an unselected MethodDef, falls back to the raw
signature. signatureGenericArity is the one rule for both paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto
morluto merged commit 91830f1 into morluto:main Oct 13, 2026
1 check passed
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The current producer no longer recursively resolves TypeSpec bases. specSignature uses an iterative type grammar, and generic bases are limited to TypeDef/TypeRef coordinates. Referenced TypeRef scopes now also use a separately bounded iterative traversal with cycle detection and cached examination. This removes the stack-depth failure instead of adding a recursion threshold.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The shared MemberCore retains parsed signature kind, and field-edge resolution requires kind field. A method-signature MemberRef can therefore no longer be presented as an accessed field; malformed signatures remain unknown and partial.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

TypeSpec naming calls specSignature before interpreting its generic base. The owning iterative grammar consumes all type arguments and rejects missing counts, truncation and trailing data. The new owner-aware pass also validates every encoded type coordinate in nested arguments and modifiers.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

readMethodSpec reads both columns, maps any readable Method fact, and validates the complete Instantiation through specSignature. Failures remain associated with metadata.MethodSpec:, so a readable name survives as partial evidence rather than silently making unread metadata complete.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

TypeDef naming checks the row through metadataRowOffset before indexing ranges. In addition, the owner-aware spec parser now rejects null, reserved and out-of-range coded type operands before naming their base. Missing rows therefore retain an explicit failure rather than collapsing into ordinary unknown.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

readMethodSpec validates its target through methodGenericArity and compares that parsed arity with the complete instantiation argument count. Non-method targets, undecodable/non-generic signatures and mismatched counts report invalid-row while preserving any readable method fact.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

specSignature propagates unsupported-signature under its owning TypeSpec/MethodSpec scope instead of returning an ordinary null. Its owner-scoped catch now also preserves coded-operand invalid-row failures. Well-formed unsupported naming shapes stay distinguishable from unvalidated blobs.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The shared readMethodSignatureHeader validates the header for its grammar context before reading counts. Metadata member headers cannot use FIELD, PROPERTY, LOCAL_SIG or GENERICINST, reserved bits or EXPLICITTHIS without HASTHIS, so MethodSpec arity cannot authenticate those forms.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

TypeRef ResolutionScope validation now follows reachable TypeRef scopes iteratively, validates each coded coordinate against the layout, and detects cycles. Null scopes remain legal. Failures are retained against the offending TypeRef row while readable type names are kept as partial evidence.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The producer separates metadata-member header rules from function-pointer conventions. MethodDef/MemberRef signatures accept only DEFAULT, VARARG or GENERIC-with-DEFAULT (plus valid instance flags); FNPTR retains its separate unmanaged conventions. Invalid member headers cannot pass generic method eligibility.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

FieldSig decoding requires the exact 0x06 FIELD byte. Flag-bearing FIELD headers flow into header validation and become malformed/unknown, so MemberCore never marks them as field targets and field-edge names remain unknown with partial coverage.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The gap was at the shared grammar operand boundary: syntax decoding rendered coded coordinates without validating referenced rows. readTypeOperand now receives layout during the spec pass and validates class/value-type operands, generic bases and custom modifiers against row counts, including nested arguments. Generic parameter indexes remain indexes rather than metadata tokens. specSignature re-scopes invalid-row failures to the owning TypeSpec/MethodSpec. Rendering and public member contracts remain unchanged.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

  1. thread 1

Addressed / current-source confirmation in a78f3b4.

The immediate-row check missed malformed reachable identities. validateScopeChain now walks TypeRef scopes without recursion, records the offending parent row for missing/reserved coordinates or cycles, and caches examined scopes for this lookup. Its visited/cache bookkeeping is admitted to the layout-owned decode budget. Null and terminal local scopes stop traversal, and readable names survive even an unreadable reachable scope row as partial evidence; this does not introduce cross-assembly resolution or nested-name rewriting.

Validation: inspected the producing boundary and affected consumers. Tests, builds, checks and CI approvals were skipped at the maintainer's explicit request; no real-assembly verification was rerun. No directly related code cleanup remains outstanding.

Nelglor added a commit to Nelglor/rea that referenced this pull request Oct 13, 2026
Brings in morluto#2163 (declaring types on call and field targets) and later
main commits. Conflicts in ManagedMemberInspector.ts, ManagedMemberRows.ts
and docs/managed-code-analysis.md keep both features: user strings and
edge-target naming run side by side, and every issue list, including
edge-target issues, is appended with appendManagedParseIssues.
parseUserStrings moves to ManagedUserStrings.ts so ManagedMemberRows.ts
stays under the max-lines limit with both features.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbd77550c4

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

token,
name,
declaringType: parentName,
kind: decoded.kind,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject field MemberRefs parented by MethodDefs

Fresh evidence beyond the prior signature-kind fix is an ldsfld operand naming a MemberRef whose Class selects an existing MethodDef and whose blob is a valid FIELD signature: the parent range check succeeds and this assignment advertises kind: "field", so namedTarget emits the member name with complete coverage. MethodDef parents are reserved for vararg method call-site MemberRefs and cannot parent field references; validate the parent/signature combination and leave the malformed target unknown/partial.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

return ranges[row - 1]?.fullName ?? null;
}
const cursor = metadataRowCursor(bytes, layout, 1, row);
cursor.readIndex(layout.codedIndexSize("ResolutionScope"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate namespaces on nested TypeRefs

Fresh evidence beyond the scope-chain checks is a used TypeRef whose in-range ResolutionScope selects another TypeRef while TypeNamespace is non-empty: this discards the scope and returns namespace.name, so parent_name and target declaring types carry a qualified name with complete coverage. Nested TypeRefs require a null namespace, so validate that relation and record invalid-row while retaining readable text only as partial evidence.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto mentioned this pull request Oct 14, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Name the declaring type of call-edge and field-access targets in inspect_managed_members

2 participants