XC 10 - Tip #6: When the docs fails -ILSpy
The best documentation is the code. And the code you need, especially when replacing for example a pipeline block where you have to ensure it keeps working as expected. Especially with Sitecore Commerce, I live in ILSpy.
For code to be the documentation, the code must be readable! We are so lucky that Sitecore did not obfuscate its code so tools like DotPeek (free) and ILSpy (free and open-source) can be used. So actually Sitecore is kind of "open source" :-) I personally prefer ILSpy because my machine is getting really slow when running Sitecore Commerce, and ILSpy keeps doing its job. DotPeek seems more powerful but almost unusable on my laptop. I should have gone for the 32GB Dell laptop I was offered, but I did fall for the shiny Microsoft Surface Book 2. But back then I didn't know I was going to do Sitecore Commerce development, I was just hacking away in React:-)
Just like with NDepend as described in XC 10 - Tip #5, I load the complete set of assemblies of:
- CommerceEngine - with the assemblies of my Sitecore.Commerce.Engine main project in the folder Sitecore.Commerce.Engine\bin\Debug\netcoreapp3.1.
- Storefront - with the assemblies of the XP website in the folder c:\inetpub\wwwroot\<XC10storefrontSite>\bin.
ILSpy does not support projects, so I have to switch by deleting all assemblies and loading the new set. If anyone once a trick to start ILSpy with a given folder to load assemblies from I would be really helped!
Some small tips when using ILSpy:
- I get the best results if I select C# 9.0 in the language selector
- You can decompile to a new tab (right-click on class/method and select Decompile to new tab, or press the middle mouse button (press the scroll-wheel on my mouse)
- You can analyze a class/method/property/... by a right-click on it and select Analyze, or press CTRL-R. In the Analyze window you can search for the Uses, Used By, and Instantiated By to navigate through the code-base
- ILSpy has a powerful and fast search through all assemblies. Press the search icon in the top or press CTRL-SHIFT-F.
- To search in the current tab press CTRL-F.