Unused variables and usings

4 posts, 0 answers
  1. Carlos
    Carlos avatar
    2 posts
    Member since:
    May 2014

    Posted 04 Jan Link to this post

    Hi all,

    Is there a way to have JustDecompile show unused usings and unused variables for C#?

    I can see them with ILSpy but not with JustDecompile.

    Thanks!

  2. Tsviatko Yovtchev
    Admin
    Tsviatko Yovtchev avatar
    544 posts

    Posted 04 Jan Link to this post

    Hi,

    In general the compiler would remove any unused variables and they won't make it to the binary for the decompiler to see them. So it is pretty weird you see an unused variable. The code produced by both decompilers also differs. This makes me think there is a deeper problem with the decompilation here. If you could send us the binary we could take a deeper look.

    Regards,
    Tsviatko Yovtchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Carlos
    Carlos avatar
    2 posts
    Member since:
    May 2014

    Posted 04 Jan in reply to Tsviatko Yovtchev Link to this post

    Sure thing, you'll be able to find it here.

    Cheers!

  4. Tsviatko Yovtchev
    Admin
    Tsviatko Yovtchev avatar
    544 posts

    Posted 12 Jan Link to this post

    Well the MSIL of this assembly looks somewhat weird. I guess it's compiled in Debug configuration with no optimizations. Rather unfortunately, JustDecompile is not really optimized for cases like this.

    The unused variable is actually present in the assembly and JustDecompile removes it as part of the decompilation process. The reason for that happening is that quite some variables get created in the initial stages of the decompilationthat didn't exist in the original code. Then they get aggressively inlined to make the code prettier. This process does not take into account the actual presence of the variable in the assembly. It is aimed at brevity. Sadly, this behavior cannot be changed at present.

    Regards,
    Tsviatko Yovtchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top