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

"Save Code" in ILSpy results in different source compared to the code shown in UI #1674

Closed
an-dr-eas-k opened this issue Aug 27, 2019 · 5 comments

Comments

@an-dr-eas-k
Copy link

ILSpy allows configuration of DecompilerSettings in the options dialog and this settings are applied in the UI text editor.

When calling the "Save Code" function from the menu bar, or the assembly context menu, different code is generated. Here the ILSpy DecompilerSettings are not respected, neither do the variable names follow those from the debug symbols in pdb files. Here new instances of ICS.Decompiler are created with hard coded DecompilerSettings and lost DebugInfoProvider.

Also the pwsh cmdlets have no possibility to specify DecompilerSettings. Again, the debug symbols are not respected when generating cs code.

This issue was already brought up in #1328 and #1426 where it was vaguely described and thus rejected.

Especially the feature to preserve the DebugInfoProvider is painful as it means making the PortableDebugInfoProvider and MonoCecilDebugInfoProvider available for ICS.Decompiler.

In my opinion, these two providers are no UI features, but technically required for proper csharp code, thus the transfer to ICS.Decompiler is consistent. Talking about the referenced Mono.Cecil: The final compile output contain this libraries anyhow.

@christophwille
Copy link
Member

For this discussion there is one important distinction to make: between the ICS.Decompiler NuGet package and the ILSpy frontend. ICS.D was specifically re-architected in v4 to move from Cecil to System.Reflection.Metadata. Frontends like ILSpy on the other hand can take those dependencies, that is why there is a PDB Provider interface that does take a Cecil dependency.

@siegfriedpammer
Copy link
Member

I guess there are a few misunderstandings here:

One part of this issue discusses the debug info:

  • IDebugInfoProvider and its implementations are meant to be independent from the UI and the other decompiler frontends and of course the decompiler itself, as there are multiple PDB formats.
  • IDebugInfoProvider is not connected to the decompiler settings in any way: be887d0 adds the relevant setting to the WholeProjectDecompiler.

The other part is about the missing option to allow passing decompiler settings to the powershell and cmdline frontends.

@an-dr-eas-k
Copy link
Author

Yes. That is a valid point. Actually I really was afraid of this changes in project references.

Perhaps the provider are again refactored to a new assembly that is subsequently available to the powershell frontend and ILSpy. I somehow liked the idea of this LoadSymbols method in PEFile and was relying on this.

Currently my solution fits my needs but I confess, I was not digging in the project history.

@siegfriedpammer
Copy link
Member

Talking about the referenced Mono.Cecil: The final compile output contain this libraries anyhow.

No, the Nuget distribution of ICSharpCode.Decompiler does NOT contain Mono.Cecil. The nuget is used by Roslyn and many other users. We want to keep the nuget distribution as small as possible.

@siegfriedpammer
Copy link
Member

be887d0 fixes one problem mentioned in this issue. I have created #1676 and #1677 for the missing features.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 19, 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

3 participants