Files
rea/docs/guides/managed/feature-inventory.md
Ysopwnableandgensokyo-dev c2ed07fdc0 feat(dotnet): inventory a managed assembly's enums, enum arguments and GUID literals (#17366)
Add inventory_managed_features across CLI and MCP to report enum definitions, direct constant enum arguments, and GUID literals with CIL sites and retained summary views.

Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
2026-12-06 16:16:33 +08:00

3.0 KiB

Feature inventory of .NET assemblies

An application's feature surface often shows in a few places in its metadata and CIL, even when type and member names are obfuscated:

  • enums of kinds, such as a MenuType, BuiltinCommandType or SearchBarType, list a subsystem's features in a few lines;
  • localization keys, often an enum such as LocKey, lead to the code that owns each piece of text;
  • hard-coded GUIDs identify default items, COM classes and interfaces.

Use rea inventory-managed-features App.exe --json or MCP inventory_managed_features to list them without loading or running the assembly. The inventory identifies and lists for orientation; it offers no way to modify, patch or enable anything.

The report has three lists:

  • enums: every enum the assembly defines, with its underlying_type and its members' names and values (decimal text). kind_name marks names that end in Type, Kind, Mode or Category. argument_sites counts the enum_arguments rows that pass one of its values.
  • enum_arguments: each constant pushed directly before a call for a value-type parameter. In verifiable CIL only an enum value is pushed that way, so each row names:
    • the parameter's enum and its position (parameter);
    • the callee;
    • the value, and the member it names when the enum is defined in the same assembly (defined_here);
    • the calling method, its method_token and the constant's il_offset.
  • guid_literals: ldstr literals in GUID form, with or without braces, normalised to lower case, with their method and IL offset.

For example, on a WPF application whose localization keys live in a separate assembly, enum_arguments lists each Loc.Get(LocKey, …) call with the key's value. Running the inventory on the localization assembly gives the LocKey members to name those values.

The scan reads every method body once and keeps only the rows it reports. What it does not attribute is listed in limitations:

  • a value that is computed, loaded from a field or local, or merged from two branches: a branch target between the constant and the call stops attribution;
  • members of an enum defined in another assembly: the row keeps the enum's name, and member is null;
  • GUIDs built from integers or byte arrays.

A method whose CIL cannot be decoded completely is counted in undecoded_methods, and coverage is then partial.

The per-call budgets are:

  • max_entries: enum members, enum argument sites and GUID literals together, 65,536 by default, up to 1,048,576;
  • max_text_bytes: the reported names and literals, 16 MiB by default, up to 256 MiB;
  • max_snapshot_bytes and max_metadata_representation_bytes, as for inspect_managed_artifact.

An exhausted budget fails without partial success and names the parameter to raise. A large result returns its summary: kind-named enums first, enum arguments grouped by enum with the most sites first, and a sample of the GUID literals. Page the complete record with inspect_analysis_view kind evidence-json.