Inherited Class Skeleton Generator (ICSG)
Author: Ivan Zderadicka (ivan.zderadicka@seznam.cz see also http://www.sweb.cz/ivan.zderadicka  (or http://ivanz.webpark.cz) for latest info and more stuff
Version: 1.0 
Date: March 12, 2002          

Intro
This tool was created to help to create a skeleton for a class which inherits from a base class and/or interfaces. I was not happy with the way, how Visual Studio support this through Class View, where you must click on individual members (with exception to implementing interfaces) and basically it is not very clear which members are abstract and which virtual, unless you click through all of them (and VS has a bug in Class View, which enable you to override final members, of course added code will not compile and  this only complicates all stuff).
So this is the tool which should speed up this process aggressively.
I also don’t like the typical wizard interface, when you have to go through several screens and in the end you forgot, what you’ve filled on first screen. So here it is – everything is on the one screen, the way I like it.
Also this was great learning exercise for Reflection and CodeDom.
I hope somebody else may find it useful, if yes, you may let me know, this will make me happy. Also any comments, found bugs, improvements etc. are welcomed.
And finally I like to apologize myself to those of you, who has English as their native language, or those, who are upset by my English grammar. Sorry guys, probably  I can make it better, but I don’t have time and strength to do it. 

Features
Try it and you will see. Here are only few things I’d like to mention:
•	Compact interface – tree view enables you to quickly choose, which members you want to include/ exclude
•	Using of short type names – it enables to generate code with short type names and include necessary namespaces. That is the style of code I usually write, so I wanted this generator to create the code in way I create it manually.
•	Can be easily integrated into exiting IDEs – I tried to make it easy to attach this tool to existing IDEs/ Editors – all you need to do is change the ProjectInfo class to get a list of all referenced assemblies and a project assembly. I’ve included an example standalone app, which reads project info from XML file. I’ve also included Visual Studio Wizard adapter.
Installation
ICSG comes with complete installation, created in VS.NET  as Deployment Project. To install it you need .NET Framework (1.0.3705) and Windows Installer 2. For installation into MS Visual Studio .NET obviously you need Visual Studio (7.0.9466). If you have all this,  just run setup.msi.  If the tool is not be used in VS.NET, files are simply copied to destination folder.
If tool should be installed as wizard into VS.NET, situation is little bit more complicated, there is an Installer class which does following actions:
•	Registers wizard adapter assembly (IvanVSWizard) for COM interoperability 
•	Includes two assemblies into GAC (IvanVSWizard, SubClassing) (this is needed for wizard to run in new AppDomain – see chapter Integration with IDE for reasons why to do it)
•	Create .vsz files in C# and VB.NET project items directories
•	Add line referring to previously created .vsz file to following .vsdir files (both for C#  and VB): Local Project Items, Local Project Items / Code, Web Project Items, Web Project Items/  Code
Installer class also contains code for uninstallation and rollback. 

Stand Alone Application
Part of installation package is the stand alone ICSG tool (StandAlone.exe), which can be used to test capabilities of the tool, or to use  it with some editor or IDE that enables to run external programs.
Stand alone tool takes two command line parameters (both are optional):
1st parameter is a path, where generated class code is saved – file is named after class name plus appropriate extension (cs or vb or js). Default is current directory.
2nd parameter is name of project info file – it is a XML file, which contains information about all assemblies, that the tool loads and thus it knows all types contained in these assemblies. If you want to use types from some assemblies, you have to add assembly reference to the XML file. Structure of file used by standalone tool is very straightforward – see ProjectInfo.xml in installation directory – each assembly reference must have name and can have assembly path. If path is present, assembly is loaded from indicated file; otherwise tool tries to load assembly from GAC or current directory using its name. Default value for project info file is ProjectInfo.xml in current directory.   
Integration with IDE
ICSG tool can be easily integrated with existing IDEs. Current version includes integration with Microsoft Visual Studio .NET. 
To integrate with IDE the tool needs to know, which assemblies are used (referenced) in the project, so you can choose from all types, that are available in the project. ICSG code has two types,  which deal with assembly references:
IProjectInfo interface serves as definition of an adapter between the way how references are stored or presented in your IDE and how they consumed in the tool.  Standalone tool implements simple project info class (SampleProjectInfo) that reads project references from a XML file.
AssemblyMgr  abstract class is used to get list of all assemblies, that the tool works with. Especially important is the concrete class ProjectAssemblyMgr, which uses IProjectInfo to load ant then present assemblies. AssemblyMgr derived classes are singletons, right AssemblyMgr  instance should be initialized before starting ICSG tool main form. 
So to make ICSG tool work with your IDE, you just need to write a class that implements IProjectInfo interface and lists all assemblies in your project uses. And then you need to initialize your new class and use it in ProjectAssemblyMgr - AssemblyMgr.InitInstance(new ProjectAssemblyMgr(yourProjectInfoClassInstance)). IProjectInfo basically defines two properties – ProjectAssembly, which should return name and path to assembly, which will be output of current project, and ReferencedAssemblies, which should return all other assemblies used in the project. Reason why ProjectAssembly has its own property is because it is treated little bit differently, than other assemblies – tool allows to list also internal types from this assembly. 
As you already saw, the tool uses Reflection and type information is gained from compiled assemblies – that means that project assembly and other solution assemblies referenced, have to be first compiled in order to be used for creation of new type by the tool.
Other important issue to consider, when integrating with IDE, is usage about loading assemblies in the tool. In order to get type information from assembly, the assembly must be loaded into the process (more exactly into the AppDomain) and file from which assembly was loaded is locked - it cannot be overwritten until the process ends. This may be an issue, when tool runs in the same process as your IDE, because than you cannot compile project/solution after you’ve used the tool. There are two solutions for this problem (at least two I know, if somebody has other solution I am really interested to hear about it):
1.	Load tool into new AppDomain and unload all assemblies in this domain after tool is done. This is the approach I’ve taken in integration with Visual Studio – see source of VSWizard adapter to see more.
2.	Use Load function overload,  which loads assembly from its memory image (in byte array) and use own function to load assembly files into memory images.

Known Issues
•	Inherited events do not have override or  new attributes – this is now feature of CodeDom and Code provider – everything is set-up in the CodeDom, but Code provider just do not include them in resulting code. This may make resulting source not compileable
•	Some virtual methods in Framework assemblies, which show in Reflection Family or Assembly access, cannot be overridden with the same access modifiers. 
•	When using additional mapping to keywords options, the program tries to replace some type names with their language keywords equivalents(works only for C# now), but the problem is, that if I do so, in resulting code  keywords are escaped using @ before each keyword. I’ve found some workaround. If I put a space before keyword, it is not changed and resulting code is OK, but it spoils little bit formatting of the code.
•	The tool does not support explicit interface implementation, which may in some cases generate code that is not compileable (Like in interface System.Resources.IResourceWriter – this interface inherits form IEnumerable, but also defines its own GetEnumerator method – both methods requires explicit interface implementation).
•	When inheriting from a class, that has method, which hides a method of its base class, you will see both methods in tree view – you have to chose only one, otherwise, code will not compile. 
•	For VB.NET  if you only implement interface and do not inherit from base class the resulting code in incorrect (it uses keyword inherits for first type in BaseTypes collection, which is in this case interface type).
•	In some cases there is problem with overridden methods which are also overloaded, it requires VB keyword overloads, which is not in there. Generally spoken I’ve did not tested VB too much, cause it is not issue for me.
•	Assembly names are handled in very relaxed manner, I either load assembly from given path or use just simple name, not full name. I suspect this may cause problems in some situations. Use of full assembly names (name, version, culture, pub. key) will be more appropriate and may be implemented sometime in future.
Ideas for future improvement
Here are some ideas, I’ve got during development, but didn’t have time to include them in. If anybody likes to do it or otherwise improve the tool, he or she is more than welcomed.
•	When implementing events add automatically OnEvent Method
•	Add option, which can add automatically call to base member into member body (for methods and properties
•	Show tooltip with details member/type info (or use right click and context menu?)

Versions history
1.00.999.00 – is initial version

License
The ICSG tool is provided free under GPL license of Free Software Foundation. See license included in distribution or you can look at the license at http://opensource.org/licenses/gpl-license.html.