Adding support for postfix/prefix decrement/increment and so on.

Jan 28, 2012 at 2:22 AM

As of changeset 67463 the Code Model has some new properties and new behavior. The reason for this is to make it possible to model statements such as "i ^= j" and "++i" and "i++" in the Code Model. This is desirable because the decompiler has to either introduce locals (as is done in the old one) or expose explicit stack manipulation instructions (as is done in the new one).

The basic idea is that an IBinayOperation may have a LeftOperand value that is an ITargetExpression instance. (The type system has always allowed this, but such operations were never constructed and were not understood by components such as CodeModelToIL.)  In order to distinguish between ++i and i++, IBinaryOperation now has a new property, ResultIsUnmodifiedLeftOperand, that is true when i++ is intended.

Another change is that ITargetExpression and INamedArgument now have properties, GetterIsVirtual and SetterIsVirtual. These come into play when the target binding is an IPropertyDefinition. The Code Model has allowed such targets for a long time, but this was not used and not widely supported. CodeModelToIL can now deal with these. The new properties provide a way to retain information from the setter/getter call instructions when decompiling.

If you use a decompiler to obtain a Code Model, particulary the new one, you'll now have to deal with cases you've not seen before.