Collection Templates

The Collection Templates were designed for C# 1 and CodeSmith by Eric J. Smith, a commercial code generation utility for the .NET Framework. Note that I never used the CodeSmith plug-in for Visual Studio so I don’t know if or how my templates will cooperate with it.

All templates and their documentation are © 2003–2004 by Christoph Nahr, except as otherwise noted. They are available for free download and no restrictions are placed on their use or redistribution, except that my copyright notice should be left intact and any changes to the original distribution should be documented.

Important Note — As of 30 October 2005, the entire functionality of the Collection Templates has been added to the Tektosyne library (version 3.0.0 or later) in the form of generic collection classes. The Collection Templates are therefore discontinued. Anyone is welcome to take up their maintenance.

System Requirements

CodeSmith 2.5 (build 2.5.10 or later) is required to perform the template expansion, and CodeSmith in turn requires a Microsoft Windows system capable of running the Microsoft .NET Framework 1.1. This includes most Windows systems with Internet Explorer 5.01 and a Pentium class CPU, except for the unsupported Windows 95 and NT 3.x. To write programs that use the generated C# source code, you also need either Microsoft Visual Studio .NET 2003 or the free Microsoft .NET Framework 1.1 SDK (106 MB).

Download Files

  • Template & Test Package: version 2.0.0, released on 12 July 2004

Template (68.4 KB, ZIP archive)

This archive includes C# templates for strongly typed versions of ArrayList, DictionaryEntry, DictionaryList, Hashtable, Queue, SortedList, Stack, and all interfaces used by these classes. Synchronized wrappers are not supported. Some templates were originally based on Chris Sells’ CollectionGen files that shipped with version 2.0 of CodeSmith.

The Collection Templates should perform at least as well as the standard collection classes. Benchmarking showed a speedup of up to 1,600% for the ArrayList template. Please refer to the enclosed ReadMe file for more details.

Test Package — If you are interested in designing your own collection templates, you might want to download the complete unit test and benchmark package, (240 KB).

This archive contains a Visual Studio .NET 2003 solution with two projects. The first project holds all template files in the archive. The second project holds my unit testing and benchmarking code with pregenerated test collections.

Additionally, the archive contains the XML property files for all test collections and for all Hexkit and Tektosyne collections; a small C# script that recreates all collections from these XML property files; and a NAnt build file that recreates the distribution packages.

Note — The test package requires an obsolete version of my Tektosyne library, and will therefore not compile. You must change or remove all references to that library.