The "CodeManager" is a plug-in for VS.NET that stores code snippets in a database. From the plug-in you can add code, search the database for code snippets to insert into your code. That is really the core of it. The reason why I took all the effort of creating this, was that we (the developer collective) needed a way to share code in our organization. Hence, one very misspent vacation, writing this! In an attempt to justify the time spent on it, I am now inflicting it upon you.
Having done some analysis on what was out there (looking to buy a third party solution - turns out they were overpriced), I thought I could get similar results in just a few days, at a fraction of the cost. I built this during a short vacation over an year ago, hence the code quality is not something I would be proud of, but it does the job it was designed to. To me its a good example of re-use, and leveraging code/classes that already exists, and was able to reduce the development time by orders of magnitude.
This would be interesting to you if;
- You want to learn how to create a real world VS.NET plug-in.
- You need a shared code library that you can maintain and extend internally.
Here are a couple of screenshots of it in action:
Adding code to the library
Searching for code
This book gave me some crucial tips in order to get this done quickly: Writing Add-ins for Visual Studio .NET.
I have used and extended the code from Julijan's add-in to include a versioning controlled build in the project, as detailed in the article Versioning Controlled Build.
Using the code
You can either use the installation and DB script to set up a working installation, or set up the code in your IDE. I recommend the latter, though it requires more effort it gives you the opportunity to really examine what is going on.
The overall concept is the same for using ToolWindows in .NET. The
VSUserControlHost DLL needs registering (if you don't go through the installer). This is then used to host a usercontrol, which contains all the functionality for the ToolWindow (as seen in the main screenshot). This user control presents an interface to SQL Server database which contains code snippets. Other integration points are the main menu entries, the toolbar entries, an Options dialog and the output windows (all are displayed below in images). Users are validated using Windows Authentication/Active Directory and added dynamically. I have also included an updated version of the version updater (sorry about that sentence), as listed in the references by Julijan Sribar.
The Context Menu
The Main Menu
The Output window
- You need a SQL DB server to use. Create a database, call it RADDev, and install the supplied script there.
- You also need to register
VSUserControlHostLIb - the project is provided with the code. Open a command prompt, navigate to the folder where the VSUserControlHost.dll is, and type in
- Now, open the solution, and you will see three projects.
WinUserControlTestProject - this is the project used to test the functionality in the main user control during development. It is convenient while testing add-ins to have a separate test application to test the core functionality, as reloading the add-in becomes a drain on debugging time.
RadDevSetup - this is the setup program, which builds the redistributable. Nothing remarkable about this.
RadDev - this is the add-in project itself, which does have lots of interesting things about it.
Points of interest
clsCodeDBFunctions – this interfaces with the data accessor class below
clsDBTier – this is an accessor block type class. It is quite out of date now, but it still does the job.
clsNodeTag: This stores the information for a tree node, it is just a holder class (should probably be a struct, but who knows what more needs to be added in the future).
clsRegistration – handles registration of licenses, new users, and decrypts licenses for checking. The registration isn't being checked anymore in the current code set. The build I made for the company was limited to the company's domain.
clsWinAuthentication – this class authenticates the user against their Windows domain and user, then checks against the database to see if they have been already added. If they are a new user, they are prompted to enter more details, and subsequently added to the database. It is important to know who is adding articles, as only the user who has added can delete it. Also I have written controls in ASP.NET applications that create content based on the contents of the database, so you need names for the articles.
- Crypto.vb – this is used for encryption/decryption of license keys. All credit for this goes to Stan Schultes.
- I am not going into greater details of the code as it is a lot interesting, but nothing in particular stands out to me. You really need to pick out the things that interest you the most from the code set itself.
It really needs a thorough cleaning up in terms of removing unused code. What it needs the most is someone who really needs this tool, to take ownership of it (I have too many other projects/commitments), and do a cleaning and rinsing on it. Hence I am freeing it to the world. There are lots and lots of areas where it can be improved. There are some redundant classes, like VSS integration and maintain database versioning, which are still good ideas, but could not make it into this version. My plan was to create a tool that also did integrated change management, linking to a web based system that I was already using. I think there is a call for an open source plug-in that covers these areas. I believe the market prices of the commercial options are over-priced.
Spent my whole life developing, having worked in C++, Delphi, ASP, then finally settling down to working solely in ASP.Net. Also a forex day trader.