Problem with reflector and auto properties

I just parsed the project to debug it with Reflector but it seems it refuses to decode "compilation results", automatic properties, for example the following line gives me a syntax error. I tried to fix it manually, but every time I fix it, more appears.

private string <GLDescription>k__BackingField;

      

What can I do about it?

0


a source to share


2 answers


Ha! Silly to me: all I had to do was set the disassembler optimization in the Reflector parameters to .NET 3.5. Mine was at 2.0.



+2


a source


The compiler generates fields with "Untold Names", that is, those that are illegal in C # itself, but are valid IL.

There is no exact translation of IL in "normal" C # (no automatic properties). You can replace <

it >

with _

which will give the legal code, but then, of course, it won't be exactly the same code. However, if you are only after the possibility of debugging, this will not be a problem.

If you decompile iterators (i.e. methods with operators yield

), you will find more of the same, including the use of blocks fault

, which are similar to blocks finally

, but they only execute when an exception is thrown (but not excluding an exception). Various other constructs also generate non-expressible names, including anonymous methods, lambda expressions, and anonymous types.



On a broader note, do you have permission to decompile this code? If the author doesn't mind this, they'll probably want to give you the source code to start off with something that makes your life easier. If they don't want you to debug the source code to begin with, you should consider the ethical (and potentially legal) implications of decompiling your code. This may vary by location: check with a real lawyer for clearer guidance.

EDIT: After seeing your own answer, it makes a lot of sense. I'll leave it here for reference.

+2


a source







All Articles