From 64d961ada6785b18052a853ad2ebb9ed48404f9e Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Wed, 1 Nov 2017 09:42:41 +0100 Subject: [PATCH] Interactive Workbook intended to make https://github.com/icsharpcode/ILSpy/wiki/Getting-Started-With-ICSharpCode.Decompiler testable You need https://developer.xamarin.com/guides/cross-platform/workbooks/install/ --- DecompilerNuGetDemos.workbook | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 DecompilerNuGetDemos.workbook diff --git a/DecompilerNuGetDemos.workbook b/DecompilerNuGetDemos.workbook new file mode 100644 index 000000000..bb61c933a --- /dev/null +++ b/DecompilerNuGetDemos.workbook @@ -0,0 +1,34 @@ +--- +uti: com.xamarin.workbook +id: de255e90-ba7b-4070-be45-65e544ae8219 +title: DecompilerPackageDemos +platforms: +- DotNetCore +packages: +- id: ICSharpCode.Decompiler + version: 3.0.0.3214-beta1 +--- + +Load the references required to work with the decompiler + +```csharp +#r "ICSharpCode.Decompiler" +#r "Mono.Cecil" + +using ICSharpCode.Decompiler; +using ICSharpCode.Decompiler.CSharp; +using ICSharpCode.Decompiler.TypeSystem; +``` + +You must have compiled frontends.sln first - please adapt basePath accordingly so that the console assembly is found + +```csharp +string basePath = @"D:\GitWorkspace\ILSpy"; +string fileName = basePath + @"\ICSharpCode.Decompiler.Console\bin\Debug\netcoreapp2.0\ilspycmd.dll"; +var decompiler = new CSharpDecompiler(fileName, new DecompilerSettings()); +``` + +```csharp +var types = decompiler.TypeSystem.Compilation.MainAssembly.GetAllTypeDefinitions(); +Console.WriteLine(types.Count()); +``` \ No newline at end of file