Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ILSpy on linux with Mono #416

Closed
hajdbo opened this issue Aug 9, 2013 · 45 comments
Closed

use ILSpy on linux with Mono #416

hajdbo opened this issue Aug 9, 2013 · 45 comments

Comments

@hajdbo
Copy link

hajdbo commented Aug 9, 2013

I'd like to use ILSpy on Linux, if it could be run by Mono.

Mono does not support WPF and I guess it's how ILSpy GUI is built.

@lextm
Copy link
Contributor

lextm commented Aug 13, 2013

I am a Mono user, but I don't think ILSpy should attempt to support Mono, because

  • It is obvious that Mono's WPF won't come soon.
  • ILSpy is built on WPF and highly related to SharpDevelop, which is also Windows only.

The core of ILSpy is highly portable, and dependencies such as Mono.Cecil, NRefactory, and ICSharpCode.Decompiler are already Mono compatible.

I think the efforts should be focused on bringing the portable parts to Mono and integrated with MonoDevelop/Xamarin Studio where you can get assistance from a huge group of users. That should be more of a joy ride.

@andreif
Copy link

andreif commented Apr 17, 2016

Could you recommend a strategy to make a cli application for OS X? I don't need GUI, just a tool to decompile .Net dll and it feels possible with today's code.

@andreif
Copy link

andreif commented Apr 17, 2016

From what I see, one would need to exclude AvalonEdit and run DecompileNodes with proper arguments. Am I on the right track?

@dgrunwald
Copy link
Member

Those "nodes" are still WPF tree nodes. Pretty much all the code in ILSpy is WPF-dependent UI code.
The decompiler logic itself is already in a separate assembly: ICSharpCode.Decompiler.

MonoDevelop already uses ICSharpCode.Decompiler on OS X and Linux.

@andreif
Copy link

andreif commented Apr 17, 2016

I have not found a sane way to decompile a large library to source files in MonoDevelop/Xamarin. If you know how, please tell. Otherwise it's just infinite manual copy-pasting from GUI to text files.

@andreif
Copy link

andreif commented Apr 17, 2016

What about CSharpLanguage.DecompileAssembly?

Edit 1:

// ICSharpCode.ILSpy.AssemblyList
public LoadedAssembly OpenAssembly(string file, bool isAutoLoaded=false);

// ICSharpCode.ILSpy.CSharpLanguage
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, 
                                       DecompilationOptions options);

DecompileAllCommand gives a nice example.

@andreif
Copy link

andreif commented Apr 18, 2016

Well, I am slowly getting further. There is no fusion.dll on OS X, so the libs has to be collected manually as I see. Not sure if I have enough time and interest to get it done though. I'll keep posting here for now.

@andreif
Copy link

andreif commented Apr 19, 2016

Ok, so I got it to decompile a library without references (it fails for mscorlib.dll though). I'll try to find some way to include the refs as well whenever I can dedicate more time for it.

@andreif
Copy link

andreif commented Apr 20, 2016

It seems to work well now. I have modified few source files to get it through and now curious if I can avoid modifying the original sources. I'll try to find some time for testing it.

@andreif
Copy link

andreif commented Apr 23, 2016

I made a quick-n-dirty project to build for OS X but I guess it should work for Linux too, see https://github.com/andreif/ILSpyMono

@minexew
Copy link

minexew commented Dec 19, 2016

@andreif This has been very helpful, thanks.

@christophwille
Copy link
Member

@mkrueger prepared a demo project for our SharpDevelop Developer Days in November outlining how a multi-targetting project could look like.

We are leaning towards WPF for Windows, and having one head for Mac/Linux. But note that the core team is working on vNext of the underlying decompiler architecture, so it is a good time to chime in if you have xplat chops especially with xwt.

@andreif
Copy link

andreif commented Feb 19, 2017

Just found one more CLI project https://github.com/aerror2/ILSpy-For-MacOSX
Did anyone try it?

@sbrl
Copy link

sbrl commented Feb 19, 2017 via email

@andreif
Copy link

andreif commented Feb 19, 2017

It's called ILSpy for Mac OS X ,Linux and any mono supported platform

@sbrl
Copy link

sbrl commented Apr 17, 2017 via email

@PoroCYon
Copy link

This fork exists, and the CLI version seems to work just fine on mono. (I'm running Parabola (99% the same as Arch) myself, and it works for me.)

@ghost
Copy link

ghost commented May 13, 2017

@PoroCYon sorry for necro-post, but this is not a fork, it's a completely different code (it's just based on some ilspy code)

@tthiery
Copy link

tthiery commented Aug 28, 2017

Has anyone spent a thought on using VS Code as the UI platform?

@jleclanche
Copy link

That'd be nice.

@christophwille
Copy link
Member

christophwille commented Aug 28, 2017

So far, even /newdecompiler isn't netstandard2 (might work though). When/if that lands, xplat UI should be a lot easier to pull off - re:VSCode, haven't ever looked into what it would take to implement a rather complex UI (in terms of interaction between JS and .NET, think memory, think the left-hand-side tree).

If anyone has infos (eg a "similar" existing extension), that would be welcome. What I found so far and might pertain to an implementation is

https://github.com/Microsoft/vscode-mssql/wiki/architecture

@sbrl
Copy link

sbrl commented Aug 28, 2017

I'd prefer not to have to install Visual Studio Code in order to use it.

@dzmitry-lahoda
Copy link

@jeremymeng
Copy link

I am working on a prototype of VSCode extension. The basic idea is to have an omnisharp-roslyn like backend, which takes requests then responds using stdio, and to use some utilities from omnisharp-vscode to handle the request handling in the extension. The back end (in C#) uses ILSpy support to decompile and sends nodes and decompiled code to VS Code extension for display using the TreeDataProvider and the editor.

image

I haven't added support for Linux/OSX. I imagine it should be easy and similar to what omnisharp-vscode is doing: running them using Mono.

@christophwille
Copy link
Member

christophwille commented Aug 30, 2017

We are working hard on netstandard 2.0 (/newdecompiler branch) and it should land very, very soon. That should allow .NET Core and make this a lot more streamlined across platforms (haven't checked what mssql extension is doing - Mono too?).

Related #831

@lextm
Copy link
Contributor

lextm commented Aug 30, 2017

@jeremymeng at least JetBrains Rider runs ReSharper code on Mono on non-Windows platforms. So in your case, your VSCode extension can run some ILSpy code on Mono.

@jeremymeng
Copy link

@lextm I know it's workable, just haven't got time to get to that part. Also with ILSpy netstandard 2.0 work coming, Mono route might become unnecessary. Last time I checked, the biggest obstacle is CodeDOM, which I don't see in the newdecompiler any more.

@PoroCYon
Copy link

@Yardanico Oops, sorry

@sbrl Indeed, my machine can't handle much load, so I don't want to have VS Code running... (Same for Wine, really, so what @asd-and-Rizzo managed is still of no use for me.)


I tried to compile the newdecompiler codebase, but xbuild couldn't parse the .csproj files. Does anyone have pointers on getting it to compile? (Preferably without installing dotnet, as I have some bad experiences with it...)

@ghost
Copy link

ghost commented Aug 30, 2017

@PoroCYon also dnSpy works great with Wine + .net runtime

@PoroCYon
Copy link

I currently use dnSpy in the terminal, running on mono, and it works just fine. (I'm not really a UI person, so maybe some of you mightn't agree.)

@christophwille
Copy link
Member

christophwille commented Aug 31, 2017

@PoroCYon we are definitely not targeting low-end machines, neither on Windows (net461 will be the future min fw) nor for any other platform we might support (.NET Core itself has some requirements). The "average" ILSpy customer does have an above-average computer (as compared to Joe Average).

@sbrl
Copy link

sbrl commented Aug 31, 2017

@christophwille I do have a pretty good laptop (running Ubuntu 17.04), but I'm not about to install wine or VS Code just to decompile C# programs.

@PoroCYon dnSpy looks good! Next time I need to do some decompiling I might use that then 😺

@christophwille
Copy link
Member

Like I said, ILSpy is not a one-size-fits-all app. However, there is no reason why multiple frontends couldn't be built, including a command line version (also interesting for automation scenarios btw).

@PoroCYon
Copy link

@christophwille Same, it's a laptop, but not the best ever (it's 6 years old), so I'd rather avoid as much bloat as possible. FYI, I'm running Parabola (rolling release).

@christophwille
Copy link
Member

Please read #831 (comment) Again, the package is intended for those that want to get started with xplat netcoreapp support. @jeremymeng please test, and @andreif if you want to test for console, that would be great.

@jeremymeng
Copy link

@christophwille my project uses a copy of CSharpLanguage which depends on ICSharpCode.NRefactory. Are there any alternatives? It would be great if non-UI-related code is extract out of ILSpy into a .netsandard library so it can be consumed easily by other projects.

@dgrunwald
Copy link
Member

@jeremymeng: The non-UI-related code is already extracted into ICSharpCode.Decompiler.dll. The main class you're supposed to use is CSharpDecompiler or WholeProjectDecompiler.

CSharpLanguage was never meant to be the entry point for using the decompiler API, it's just the class that corresponds to the "C#" choice in ILSpy's language dropdown.

@jeremymeng
Copy link

it's just the class that corresponds to the "C#" choice in ILSpy's language dropdown.

Yeah, but there are handy helper methods for decompiling methods, fields, etc. into various languages (C#, VB, IL). They are not tied to the WPF UI, but unfortunately within the same project.

@siegfriedpammer
Copy link
Member

siegfriedpammer commented Sep 7, 2017

Soon we'll prepare a small demo command-line application that uses the CSharpDecompiler class. You could use that as a starting point for your own ideas.

@christophwille
Copy link
Member

We have updated https://github.com/christophwille/ilspy-console-netcoreapp/ to "wean everyone off of CSharpLanguage". As you can see in the animated GIF, it can run as a self-contained executable on Mac + it decompiles itself (being a netcoreapp this is new, something that wasn't possible last week)

@PoroCYon
Copy link

@christophwille Is there any way to get it to work without having to install dotnet-cli? I don't really want to install something that requires itself to compile, as I don't like binary packages (especially Microsoft's).

@christophwille
Copy link
Member

Self-contained deployment (scd) is the farthest we will go at the moment (remember: the cmd line uses the -alpha2 package and we haven't yet reached the functionality level of the decompiler for master merge) - there are bigger fish to fry. Having said that: the future might be https://github.com/dotnet/corert

@christophwille
Copy link
Member

Please note that the ilspycmd project is now officially supported in our main repo:

https://github.com/icsharpcode/ILSpy/tree/master/ICSharpCode.Decompiler.Console

@jeremymeng Command line and VS "proper" addin are already part of our main repo - definitely something we'd like for a VS Code addin too.

@jeremymeng
Copy link

@christophwille I planned to publish my projects to github after some cleanup. If any ideas/architecture can be reused by ILSpy team I am happy to continue contributing.

@christophwille
Copy link
Member

@jeremymeng thanks. (side note: ILSpy core devs will meet for the weekend of October 12th in Bad Ischl at our annual developer days)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests