Skip to content

ilspycmd: add --member for single-member decompilation - #3924

Merged
siegfriedpammer merged 1 commit into
masterfrom
ilspycmd-member-decompile
Jul 28, 2026
Merged

ilspycmd: add --member for single-member decompilation#3924
siegfriedpammer merged 1 commit into
masterfrom
ilspycmd-member-decompile

Conversation

@siegfriedpammer

@siegfriedpammer siegfriedpammer commented Jul 27, 2026

Copy link
Copy Markdown
Member

Implements item 1 of the ilspycmd automation-workflow wishlist (christophwille/internal-ilspy-backlog#109).

-t is type-granularity; automated callers usually want exactly one member, and on large assemblies decompiling the whole type to answer a one-method question is the biggest source of wasted output. The new option:

ilspycmd System.Private.CoreLib.dll -m "M:System.MathF.Sqrt(System.Single)"
ilspycmd app.dll -m 0x06000005
  • Doc-id form: the XML documentation id syntax (M:/P:/F:/E:/T:), identical to compiler-generated documentation files and the GUI's --navigateto, resolved via IdStringProvider.FindEntity. Output is just the member, including its XML documentation when a documentation file is present.
  • Token form: hexadecimal metadata tokens (0x06000005), bounds-checked against the module's tables.
  • Distinct error messages (exit code EX_DATAERR) for malformed id strings, unknown members, out-of-range tokens, and members resolving into other modules; -t and -m are mutually exclusive (EX_USAGE).

Tests (red-first): six in-process tests driving the real Main via InternalsVisibleTo, covering method/property doc-ids, the token form, both error paths, and the option conflict. They seed a dedicated ICSharpCode.ILSpyCmd.Tests project (added to ILSpy.sln via dotnet sln add, to both the XPlat and Desktop solution filters, and to the per-project CI test steps), giving future ilspycmd features -- the rest of the backlog wishlist implies several -- a proper home for CLI tests instead of piggybacking on the decompiler test project. Verified against System.Private.CoreLib; full decompiler suite green on Linux (2512 passed / 0 failed / 38 skipped).

This PR was prepared by an AI agent (Claude) on behalf of @siegfriedpammer.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new ilspycmd --member/-m option for decompiling a single member (by XML documentation id or metadata token), and introduces a dedicated ICSharpCode.ILSpyCmd.Tests project to host in-process CLI tests for current and future ilspycmd automation features.

Changes:

  • Add --member/-m option and member resolution logic to decompile exactly one entity from an input module.
  • Seed ICSharpCode.ILSpyCmd.Tests with NUnit-based in-process tests driving ILSpyCmdProgram.Main.
  • Wire the new test project into the main solution, solution filters, and CI workflow execution.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ILSpy.XPlat.slnf Adds the new ilspycmd test project to the cross-platform solution filter.
ILSpy.sln Registers ICSharpCode.ILSpyCmd.Tests in the main solution and configurations.
ILSpy.Desktop.slnf Adds the ilspycmd test project to the desktop solution filter.
ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs Implements --member option parsing and member resolution/decompilation flow.
ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj Exposes internals to the new test project via InternalsVisibleTo.
ICSharpCode.ILSpyCmd.Tests/packages.lock.json Introduces lock file for repeatable restores of the new test project.
ICSharpCode.ILSpyCmd.Tests/MemberOptionTests.cs Adds in-process tests validating member decompilation and key error/usage paths.
ICSharpCode.ILSpyCmd.Tests/ICSharpCode.ILSpyCmd.Tests.csproj New net11.0 test project configuration and references.
.github/workflows/build-ilspy.yml Adds a CI step to execute the new ilspycmd tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs Outdated
Comment thread ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs
Decompiling one method or property previously required decompiling its
whole type and searching the output, which is wasteful for scripted and
agent-driven use against large assemblies. The new -m|--member option
accepts an XML documentation id string (the syntax of compiler-generated
documentation files and of the UI's --navigateto option) or a metadata
token in 0x06000005 form, resolves it against the main module (with a
bounds check for tokens and distinct error messages for malformed ids,
unknown members, and members of other modules), and prints just that
member through the engine's single-member decompilation path.

The tests seed a new ICSharpCode.ILSpyCmd.Tests project (part of the
XPlat and Desktop solution filters and of the per-project CI test
steps), driving the real Main in-process via InternalsVisibleTo, so
future ilspycmd features have a dedicated home for CLI tests.

Assisted-by: Claude:claude-fable-5:Claude Code
@siegfriedpammer
siegfriedpammer force-pushed the ilspycmd-member-decompile branch from 13ed5df to e714088 Compare July 28, 2026 11:26
@siegfriedpammer
siegfriedpammer merged commit 74bc61b into master Jul 28, 2026
13 checks passed
@siegfriedpammer
siegfriedpammer deleted the ilspycmd-member-decompile branch July 28, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants