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

ilspycmd to support the option for omitting token export #3206

Closed
RaenonX opened this issue May 10, 2024 · 1 comment
Closed

ilspycmd to support the option for omitting token export #3206

RaenonX opened this issue May 10, 2024 · 1 comment
Labels
Enhancement Areas for improvement ILSpyCmd

Comments

@RaenonX
Copy link

RaenonX commented May 10, 2024

Is your feature request related to a problem? Please describe.

I am tracking the metadata change because of version bump of a DLL. I am not interested in the token address of these methods. However, the token/addresses of these metadata seems always getting exported.

Consulted both the help of ilspycmd at v8.2.0.7535 and https://www.nuget.org/packages/ilspycmd/8.2.0.7535, but doesn't seem like I have any option to remove this token export.

Since any update could cause a massive shift on these tokens, it will generate tons of useless diff, which contains token change and nothing else.

Describe the solution you'd like

A --no-token option should be enough.

Additional context

image

@RaenonX RaenonX added the Enhancement Areas for improvement label May 10, 2024
@siegfriedpammer
Copy link
Member

siegfriedpammer commented Aug 20, 2024

It does not make sense to add a --no-token option, simply because the attribute you are seeing in your code is not a standardized custom attribute or pseudo attribute (like FieldOffset for example).

A possible solution would be to add something like a --omit-attribute Fully.Qualified.NameOf.Attribute option to filter certain custom attributes from the output, but where do we stop? The next person wants to only remove attributes from certain methods... how many options are we going to add?

There are two easier solutions:

  1. Use the ICSharpCode.Decompiler package directly to decompile the code in question and add your own IAstTransform to the decompiler pipeline, just like we do in our unit tests, see https://github.com/icsharpcode/ILSpy/blob/master/ICSharpCode.Decompiler.Tests/Helpers/RemoveCompilerAttribute.cs
  2. Use a simple regex to filter out those lines, tools like WinMerge let you even specify such filters/regexes on the fly without having to post-process the files yourself. A possible regex would be something like ^\s*\[Token\(Token\s*=\s*"0x[A-Fa-f0-9]{1,8}"\)\]$.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Areas for improvement ILSpyCmd
Projects
None yet
Development

No branches or pull requests

3 participants