2

ILspy is a amazing tool, but when I use it decompile dll, I have result like this:

this.lastOrientation = base.get_Orientation();

but what it should be is like this:

this.lastOrientation = base.Orientation;

how can I get the better result?

more examples like this:

It shall be:

battery_logo.Visibility = System.Windows.Visibility.Visible;

but what we get is:

battery_logo.set_Visibility(System.Windows.Visibility.Visible);

When we build will get error like:

'System.Windows.UIElement.Visibility.set': cannot explicitly call operator or accessor
nikis
  • 11,166
  • 2
  • 35
  • 45
gnemoug
  • 467
  • 1
  • 5
  • 21
  • but `get_Orientation()` is also readable and explains how properties are implemented internally btw – nikis Mar 31 '15 at 13:01
  • Yes, but it is not the recommended way. – gnemoug Mar 31 '15 at 13:03
  • It doesn't happen to me (and it would be wrong, because if `Orientation` is a property, there is no way in C# to directly call the getter method) – xanatos Mar 31 '15 at 13:11
  • @xanatos, did you config the ilspy? what I get always make the property to a getter or setter method. – gnemoug Mar 31 '15 at 13:15
  • @gnemoug what are you trying to achieve by calling `battery_logo.set_Visibility(System.Windows.Visibility.Visible);`? – nikis Mar 31 '15 at 13:15
  • 1
    Are you sure you aren't using a prehistoric version of ILSpy? For comparison, I'm using 2.3.0.1827 – xanatos Mar 31 '15 at 13:15
  • @xanatos, it is the current version, I download it from http://ilspy.net/ – gnemoug Mar 31 '15 at 13:21
  • @xanatos, what I decompile is a windows phone dll, Is this the reason? – gnemoug Mar 31 '15 at 13:22
  • @gnemoug https://github.com/icsharpcode/ILSpy/issues/380 There seems to be some problems if some dependencies are missing. Connected to the fact that you are decompiling something for Windows Phone (so you are probably missing the base libraries) could create the problem – xanatos Mar 31 '15 at 13:22
  • why don't you use DotPeek? – Daniel A. White Mar 31 '15 at 13:24

2 Answers2

4

There is a bug report here: https://github.com/icsharpcode/ILSpy/issues/380

Someone wrote:

It turns out the issue was related to missing dependency assembly an the base type. I no longer see that issue. I am stymied on some obfuscated code though, not sure if you'd be interested in helping me work through that but I'd sure appreciate the help.

You said that you are decompiling an app for Windows Phone. What you could try is loading the referenced assemblies of Windows Phone in ILSpy

xanatos
  • 109,618
  • 12
  • 197
  • 280
1

ILspy is a amazing tool, but when I use it decompile dll, I have result like this:

this.lastOrientation = base.get_Orientation();

but what it should be is like this:

this.lastOrientation = base.Orientation;

Orientation is probably a property and Properties in c# are actually kind of syntactic sugar and they internally simply translated to getter & setter methods under the hood - This is why you see the decompiled code as if it was a call to a method and a read of a regular property.

Yair Nevet
  • 12,725
  • 14
  • 66
  • 108