0xd4d/de4dot — Issue #6: Suggestions for heuristic auto-renaming guesses
Author: AlexVallat
Created: 2011-10-15 08:29:45+00:00
State: open

The auto-renaming of obfuscated names is good, but I wonder if it could be better? Here are some suggestions for making guesses at better names for specific patterns:

* If an executable, find the entry point. Name that method "Main", and the class it's in "App" if it inherits from System.Windows.Application, or "Program" otherwise.
* If there's a call to System.Windows.Forms.Application.Run, with an object passed to it that inherits from System.Windows.Forms.Form, name the type of that object as "MainWindow".
* If a class inherits from System.Windows.Forms.Form or System.Windows.Window, check to see whether any code calls ShowDialog on it. If it does, name it "Dialog". Otherwise, "Window". Obviously, as with all suggestions, appending a number if required to make it unique.
* If a class inherits from an external reference class that is not abstract, not a Window, and not generic (see other suggestion for those), then name the class as "Custom_ParentClassName_", using the immediate external parent. For example, CustomTextBox, CustomException, CustomObservableCollection, etc.
* Check the constructor of a class. If it calls a method local to that class, name that method "Initialise".
* Check for a static method on a class whose return type is the type of that class. Call it "Create"
* If a class inherits from a generic class, with a specified type parameter, call it "_TypeParametersClassName_", for example WidgetList : List<Widget>, or StringWidgetDictionary : Dictionary<String, Widget>.