dotPeek 2022.2 Help

View High-Level and Low-Level C# Code

The more features for simplifying source code appear in new C# versions, the more compiler-generated code is produced under the hood. dotPeek allows you to study the differences having both the original version in the code viewer and C# with different levels of syntax sugar in the IL Viewer window simultaneously with proper synchronization.

View low-level or high-level C# for a document

  1. Select Windows | IL Viewer from the menu.

  2. Select Low-level C# or High-level C# on the IL Viewer toolbar.

In the example below, you can see code generated by the compiler for a simple record as well as the synchronized highlighting of primary constructor:

dotPeek: Comparing original and decompiled C# code

Here are some differences and use cases for the Low-Level C# and High-Level C# presets.

Low-Level C#

High-level compiler transformations are off and compiler-generated code is shown. This allows you to see what code is produced for different syntax-sugar features.

For example, you can see lambdas and iterators in the code viewer and compare them with corresponding generated nested classes, state machines, and captured local variables in the IL Viewer.

High-level C#

High-level compiler transformations are on according to settings in the Code style and formatting sections on the Decompiler page of dotPeek options Ctrl+Alt+S.

Here are some use cases for the High-Level C# view:

  • Some tool for code generation (such as Fody) are used in the codebase and the original source code form PDB is displayed in the code viewer. In this case, you can switch to High-Level C# in the IL Viewer and see what was added or changed by this tool.

  • The code viewer displays Metadata view (method signatures without bodies). In this case, High-Level C# in the IL Viewer will display decompiled bodies of the methods.

Last modified: 01 August 2022