tags:

views:

170

answers:

2

I'm using an up-to-date .NET Reflector to disassemble an internal legacy app whose source code is almost impossible to recover. I need to find the cause of a nasty bug, and then possibly patch it. Reflector did a good job as usual in the re-creation of the project's structure, but soon I discovered that some property calls were left "expanded" to its get_() and set_() method signatures, rendering the source code impossible to compile.

At first, I thought that every get/set call had the problem. But at a closer look, several of them are OK, while others (especially OleDbCommand and Forms.Control properties) will be generated as get_() and set_().

A quick Visual Studio "Search/Replace" with regex solved these cases, but it's awkward. Is there a way to make Reflector behave correctly?

EDIT 1 - Sample problematic code below:

/* Generated by .NET Reflector 6.1.0.11 */
/* The variable selectCommand is a OleDbCommand. */
string parameterName = "@P" + Convert.ToString(num);
selectCommand.set_CommandText(selectCommand.get_CommandText() + " WHERE SIGLA = " + parameterName);
/*
   Expected something like this (as ugly as it may seem):
   selectCommand.CommandText = selectCommand.CommandText + " WHERE SIGLA = " + parameterName;
*/

EDIT 2 - The assembly was built in Release mode.

A: 

Where are you viewing the source code in Reflector? In the current version (6.1.0.11 at the time of this writing), disassembling a type then clicking on "Expand Methods" at the bottom yields a full class definition with code, including the correct property syntax (get { ... } and set { ... })

Adam Robinson
Sorry, I meant property calls, not their declaration, which are fine. (I just edited my question.)
Humberto
@Humberto: I'm still not seeing this behavior. In my version, property gets and sets are done using property syntax, not `get_()` and `set_()`.
Adam Robinson
@Humberto: I've also tested using the Export function, and it also generates the correct syntax.
Adam Robinson
@Adam, I'm very puzzled. I did Export too! I just disassembled a sample project and the problem arose in both Debug and Release builds.
Humberto
@Humberto: I've been testing it on .NET framework assemblies.
Adam Robinson
@Adam, same here. Many properties are shown just fine... it's so weird that I've given up for now, and I'm debugging through other means. Great thanks for you all!
Humberto
A: 

This problem appears with disassembling to Managed C++, right? Might want to disassemble to C# code (there is dropdown in the toolstrip) and you will get the usual properties.

Femaref
Not really, it's all C# code. Thanks anyway.
Humberto
In my reflector (6.1.0.11) I see normal properties when disassembling to c#. So your problem is elsewhere.
Femaref
@Femaref, I've included some code to illustrate the issue. Thanks!
Humberto
I tested it with my code, and I get the normal syntax. Do you might have any plugins running?
Femaref
It's a vanilla Reflector, no plugins. Did you compile your test in Debug mode? Mine's a Release mode assembly.
Humberto
tested both, both produce valid properties.
Femaref