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
Do one of the following:
Right-click anywhere in the code viewer and choose
Invoke Navigate To Control+Shift+G and choose Low-level C# Code.
Right-click a symbol in the code viewer and select IL Code.
Select Low-level C# or High-level C# on the IL Viewer toolbar if you want to change code presentation.
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:
Here are some differences and use cases for the Low-Level C# and High-Level C# presets.
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 compiler transformations are shown according to settings in the Code style and formatting sections on the 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) is used in the build process , 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.