$ show icsharpcode/ILSpy
ILSpy is a production-grade .NET assembly browser and decompiler, serving as the open-source successor to SharpDevelop's decompiler. It is architected as a hybrid monolith with a clear plugin system (MEF), separating the core decompilation engine (`ICSharpCode.Decompiler`) from the cross-platform GUI (`ILSpy`, built on Avalonia) and the command-line interface (`ICSharpCode.ILSpyCmd`). The core engine implements a full .NET type system, an intermediate language (IL) with a comprehensive transform pipeline, and a C#/VB syntax tree generator, enabling it to faithfully reconstruct high-level source code from compiled bytecode. The primary data flow begins with loading binary assemblies (PE, ELF, bundles) through a registry of file loaders. The `ILReader` parses bytecode into IL instructions, which undergo a series of transforms (control flow analysis, pattern matching, type inference) before being built into a C# AST. This AST is then processed by output visitors to produce formatted source code, debug information, or project files. The GUI provides a dockable workspace, syntax-highlighted editor, metadata table viewers, analyzers for code navigation (find usages, overrides), and a search engine. The codebase exhibits high craftsmanship, particularly in its utility libraries and AST pattern matching. Self-contained, extractable components include a generic Union-Find data structure (`UnionFind.cs`), an immutable interval-based map for 64-bit keys (`LongSet.cs`/`LongDict.cs`), a declarative AST pattern matching DSL (`Pattern.cs`), and thread-safe lazy initialization utilities (`LazyInit.cs`). These components solve non-trivial problems (efficient range queries, backtracking tree matching) and are isolated from the rest of the codebase. The project is actively maintained, with recent commits, extensive CI/CD pipelines (CodeQL, Scorecard, Dependabot), and a large test suite covering decompilation correctness and UI behavior. Technical drift is low; the codebase targets modern .NET versions and has successfully migrated from WPF to Avalonia. While the sheer size introduces complexity, the architecture is sound, making it a strong reference for decompiler design, .NET internals, and cross-platform desktop application architecture.
The LLM identified 5 files worth highlighting for reuse:
A generic, thread-safe Union-Find (Disjoint Set Union) data structure implementing path compression and union by rank. It is fully self-contained, demonstrating a classic algorithm with optimal asymptotic complexity, and can be extracted for any project requiring efficient equivalence class management.
An immutable set for `long` keys backed by an interval-based structure. It solves the problem of efficient range queries, deduplication, and memory-efficient storage for sparse 64-bit key spaces. Self-contained and highly optimized.
The core of a declarative AST pattern matching DSL. It supports wildcards (`AnyNode`), choices (`Choice`), repetitions (`Repeat`), and back-references (`Backreference`). This system allows complex tree queries to be expressed declaratively and is extractable for any tree-structured data analysis tool.
An efficient, dynamically-sized bit set using `long[]` backing. It supports standard set operations (union, intersect, difference, complement) and iteration over set bits. Self-contained and ideal for high-performance flag management.
A thread-safe lazy initialization utility ensuring a value is computed exactly once. It uses atomic operations for correctness and is fully self-contained, applicable to any concurrent application needing deferred, cached initialization.