Community编程与开发github.com

ilspy-decompile

通过反编译程序集了解 .NET 代码的实现细节。用于查看 .NET API 内部工作原理、检查 NuGet 包源码、查看框架实现或理解编译后的 .NET 二进制文件。

ilspy-decompile 是什么?

该技能通过 ILSpy 命令行工具反编译 .NET 程序集,帮助开发者深入了解 .NET 代码的内部实现。它支持从 NuGet 包、.NET 运行时库、项目构建输出等常见位置定位并反编译程序集。开发者可以反编译整个程序集、指定类型、输出到文件夹或项目格式,甚至查看中间语言 (IL) 代码。该技能适用于 Cursor、Codex 等 AI 编码助手,但需要 .NET SDK 和 ilspycmd 工具。注意:ReadyToRun 或 AOT 编译的程序集可能影响可读性,且反编译可能受许可证限制。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Aaronontheweb/dotnet-skills/tree/main/skills/ilspy-decompile

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

.NET 程序集反编译(使用 ILSpy)

使用此技能通过反编译已编译的程序集来了解 .NET 代码的内部工作原理。

先决条件

  • 已安装 .NET SDK
  • 可通过以下方式之一使用 ILSpy 命令行工具:
    • dnx ilspycmd(如果您的 SDK 或运行时中可用)
    • dotnet tool install --global ilspycmd

下面给出了两种形式。请使用在您的环境中有效的那一种。

注意:ILSpyCmd 选项可能因版本而异。 请始终使用 ilspycmd -h 验证支持的标志。

快速开始

# 反编译程序集并输出到标准输出
ilspycmd MyLibrary.dll
# 或
dnx ilspycmd MyLibrary.dll

# 反编译到输出文件夹
ilspycmd -o output-folder MyLibrary.dll

常见的 .NET 程序集位置

NuGet 包

~/.nuget/packages/<package-name>/<version>/lib/<tfm>/

.NET 运行时库

dotnet --list-runtimes

.NET SDK 引用程序集

dotnet --list-sdks

引用程序集不包含实现。

项目构建输出

./bin/Debug/net8.0/<AssemblyName>.dll
./bin/Release/net8.0/publish/<AssemblyName>.dll

核心工作流程

  1. 确定您想理解的内容
  2. 定位程序集
  3. 列出类型
  4. 反编译目标

命令

基本反编译

ilspycmd MyLibrary.dll
ilspycmd -o ./decompiled MyLibrary.dll
ilspycmd -p -o ./project MyLibrary.dll

定向反编译

ilspycmd -t Namespace.ClassName MyLibrary.dll
ilspycmd -lv CSharp12_0 MyLibrary.dll

查看 IL 代码

ilspycmd -il MyLibrary.dll

关于现代 .NET 构建的说明

  • ReadyToRun 映像可能会降低可读性
  • 裁剪或 AOT 构建可能省略代码
  • 优先使用非裁剪构建

法律声明

反编译程序集可能受到许可证限制。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

akka-hosting-actor-patterns

Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and ITimeProvider. Supports both local testing and clustered production modes.

akka-net-aspire-configuration

Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.

akka-net-best-practices

Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work distribution patterns, and cluster/local mode abstractions for testability.

akka-net-management

Akka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster formation without static seed nodes.

akka-net-testing-patterns

Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit.

api-design

Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, and versioning for NuGet packages and distributed systems.

aspire-configuration

Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.

aspire-integration-testing

Write integration tests using .NET Aspire

aspire-service-defaults

Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.

crap-analysis

Analyze code coverage and CRAP (Change Risk Anti-Patterns) scores to identify high-risk code. Use OpenCover format with ReportGenerator for Risk Hotspots showing cyclomatic complexity and untested code paths.

csharp-concurrency-patterns

Choosing the right concurrency abstraction in .NET - from async/await for I/O to Channels for producer/consumer to Akka.NET for stateful entity management. Avoid locks and manual synchronization unless absolutely necessary.

database-performance

Database access patterns for performance. Separate read/write models, avoid N+1 queries, use AsNoTracking, apply row limits, and never do application-side joins. Works with EF Core and Dapper.

dependency-injection-patterns

Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.

dotnet-devcert-trust

Diagnose and fix .NET HTTPS dev certificate trust issues on Linux. Covers the full certificate lifecycle from generation to system CA bundle inclusion, with distro-specific guidance for Ubuntu, Fedora, Arch, and WSL2.

dotnet-local-tools

Managing local .NET tools with dotnet-tools.json for consistent tooling across development environments and CI/CD pipelines.

dotnet-project-structure

Modern .NET project structure including .slnx solution format, Directory.Build.props, central package management, SourceLink, version management with RELEASE_NOTES.md, and SDK pinning with global.json.

dotnet-slopwatch

Use Slopwatch to detect LLM reward hacking in .NET code changes. Run after every code modification to catch disabled tests, suppressed warnings, empty catch blocks, and other shortcuts that mask real problems.

efcore-patterns

Entity Framework Core best practices including NoTracking by default, query splitting for navigation collections, migration management, dedicated migration services, and common pitfalls to avoid.

mailpit-integration

Test email sending locally using Mailpit with .NET Aspire. Captures all outgoing emails without sending them. View rendered HTML, inspect headers, and verify delivery in integration tests.

marketplace-publishing

Workflow for publishing skills and agents to the dotnet-skills Claude Code marketplace. Covers adding new content, updating plugin.json, validation, and release tagging.

相关技能