Siegfried Pammer bbe41b841a Add pretty tests for C# 13 ref/unsafe in iterators and async methods
C# 13 allows ref locals, ref-struct (Span) locals, and unsafe blocks
inside iterators and async methods as long as they do not cross a
suspension point. Two suites, both gated on Roslyn 4.14/latest (whose
-langversion:latest is C# 13/14; C# 12 rejects every case with CS9202):

RefLocalsInIteratorsAndAsync is green and pins what already works:
stackalloc and array-backed Span locals in async methods and async
iterators, ReadOnlySpan in iterators, ref locals in iterators, and
local functions (async with stackalloc, iterator with ref local,
static with ref local) nested in such methods. Ref locals whose uses
are all foldable (generic ref, ref readonly, ref reassignment, ref
into a span) decompile to equivalent direct element accesses; those
cases pin the folded form via EXPECTED_OUTPUT.

UnsafeInIteratorsAndAsync is Assert.Ignore'd; the fixture is the
desired output. The decompiler currently emits the raw pinned-local
lowering (int[]/*pinned*/ plus Unsafe.AsPointer, or a GetPinnableReference
sequence for fixed over string) instead of reconstructing fixed
statements inside MoveNext, and marks the methods unsafe instead of
wrapping the pointer region in an unsafe block. That output does not
recompile: unsafe async methods fail with CS4004 (cannot await in an
unsafe context), and pointer code in iterator bodies fails with CS0214
because an iterator body remains a safe context in C# 13 even when the
method is declared unsafe. All four Roslyn 4.14/latest debug/opt
configs compile the fixture and fail only at the output comparison.

Assisted-by: Claude:claude-fable-5:Claude Code
2026-07-29 07:19:30 +02:00
2026-07-22 21:10:41 +02:00
2026-07-10 17:18:57 +02:00
2025-07-04 19:08:07 +02:00
2014-04-06 11:37:14 +08:00
2026-07-05 21:09:46 +02:00
2026-07-09 08:49:58 +02:00
2026-04-11 12:57:53 +02:00
2026-04-11 12:57:53 +02:00
2025-01-03 14:40:27 +01:00

ILSpy NuGet Build ILSpy Mastodon Bluesky ILSpy VS extension

ILSpy is the open-source, cross-platform .NET assembly browser and decompiler. The desktop UI runs on Windows, Linux, and macOS (built on Avalonia).

Download: latest release | latest CI build (master) | Microsoft Store (RTM versions only)

Decompiler Frontends

Aside from the cross-platform desktop UI ILSpy (downloadable via Releases, see also plugins), the following other frontends are available:

  • Visual Studio 2022/2026 ship with decompilation support for F12 enabled by default (using our engines v8.2 and v9.1 respectively).
  • Our Visual Studio 2022 extension marketplace (works with VS 2026 as well)
  • Our Visual Studio Code Extension repository | marketplace | open-vsx
  • Our dotnet tool for Linux/Mac/Windows - check out ILSpyCmd in this repository | dotnet tool install
  • C# for Visual Studio Code ships with decompilation support as well. To enable, activate the setting "Enable Decompilation Support".
  • In Visual Studio 2019, you have to manually enable F12 support. Go to Tools / Options / Text Editor / C# / Advanced and check "Enable navigation to decompiled source"
  • Our Visual Studio 2017/2019 extension marketplace
  • Our ICSharpCode.Decompiler NuGet for your own projects
  • Our Linux/Mac/Windows PowerShell cmdlets in this repository

Features

  • Decompilation to C# (check out the language support status)
  • Whole-project decompilation
  • Search for types/methods/properties (learn about the options)
  • Hyperlink-based type/method/property navigation
  • Base/Derived types navigation, history
  • Assembly metadata explorer (feature walkthrough)
  • BAML to XAML decompiler
  • ReadyToRun binary support for .NET Core (see the tutorial)
  • Extensible via plugins
  • Additional features in DEBUG builds (for the devs)

License

ILSpy is distributed under the MIT License. Please see the About doc for details, as well as third party notices for included open-source libraries.

How to build

Windows:

  • Make sure Windows PowerShell (at least version) 5.0 or PowerShell 7+ is installed.
  • Clone the ILSpy repository using git.
  • Execute git submodule update --init --recursive to download the ILSpy-Tests submodule (used by some test cases).
  • Install Visual Studio (documented version: 18.0/2026). You need the following workload components:
    • Workload ".NET Desktop Development". This workload includes the .NET Framework 4.8 SDK and the .NET Framework 4.7.2 targeting pack, as well as the .NET 10.0 SDK (ILSpy.csproj targets .NET 10.0, but we have net472 projects too). Our unit tests require .NET 11.0 SDK.
    • Workload "Visual Studio extension development" (Note: ILSpy.VSExtensions.slnx is separate from ILSpy.sln and thus this workload is optional)
    • Individual Component "MSVC v143 - VS 2022 C++ x64/x86 build tools" (or similar)
      • The VC++ toolset is optional; if present it is used for editbin.exe to modify the stack size used by ILSpy.exe from 1MB to 16MB, because the decompiler makes heavy use of recursion, where small stack sizes lead to problems in very complex methods.
  • Open ILSpy.sln in Visual Studio.
    • NuGet package restore will automatically download further dependencies
    • Run project "ILSpy" for the ILSpy UI
    • Use the Visual Studio "Test Explorer" to see/run the tests
    • If you are only interested in a specific subset of ILSpy, you can also use
      • ILSpy.Desktop.slnf: for the cross-platform Avalonia UI and its tests
      • ILSpy.XPlat.slnf: for the cross-platform CLI (ilspycmd) or PowerShell cmdlets
      • ILSpy.VSExtensions.slnx: for the Visual Studio extensions

Note: Visual Studio includes a version of the .NET SDK that is managed by the Visual Studio installer - once you update, it may get upgraded too. Please note that ILSpy is only compatible with the .NET 11.0 SDK and Visual Studio will refuse to load some projects in the solution (and unit tests will fail). If this problem occurs, please manually install the .NET 11.0 SDK from here.

Unix / Mac:

  • Make sure .NET 10.0 SDK (for run) and .NET 11.0 SDK (for tests) is installed.
  • Make sure PowerShell is installed (formerly known as PowerShell Core)
  • Clone the repository using git.
  • Execute git submodule update --init --recursive to download the ILSpy-Tests submodule (used by some test cases).
  • Use dotnet build ILSpy.Desktop.slnf to build the cross-platform Avalonia desktop UI; run it with dotnet run --project ILSpy.
  • Use dotnet build ILSpy.XPlat.slnf to build only the CLI tool (ilspycmd) and PowerShell cmdlets.

How to contribute

Current and past contributors.

Privacy Policy for ILSpy

ILSpy does not collect any personally identifiable information, nor does it send user files to 3rd party services. ILSpy does not use any APM (Application Performance Management) service to collect telemetry or metrics.

S
Description
.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
Readme MIT
72 MiB
Languages
C# 98.8%
JavaScript 0.4%
PowerShell 0.4%
Visual Basic .NET 0.2%