The Microsoft Shared Source CLI Implementation


David Stutz
Microsoft Corporation

March 2002

Download the Shared Source CLI from the MSDN Download Center.

The Microsoft® Shared Source CLI Implementation is a file archive containing working source code for the ECMA-334 (C#) and ECMA-335 (Common Language Infrastructure, or CLI) standards. These standards together represent a substantial subset of what is available in the Microsoft .NET Framework. In addition to the CLI implementation and the C# compiler, the Shared Source CLI Implementation contains a cornucopia of tools, utilities, additional Framework classes, and samples. It will build and run on the Microsoft Windows® XP and the FreeBSD operating systems.

Wondrous Machine

The Microsoft Shared Source CLI Implementation, affectionately known as "Rotor" to those of us on the team building it, is a complete implementation of the ECMA-334 (C#) and ECMA-335 (CLI) standards in source code form. It's an amazing piece of software for those who love browsing or tinkering with programming language infrastructure. In its million-plus lines of source code, you will find compilers, tools, techniques for automatically managing memory, just-in-time (JIT) code generators, component and Web services infrastructure, globalization know-how, security protocols, and all sorts of other intriguing realizations of abstract concepts.

Microsoft has built the Shared Source CLI so that researchers, students, professors and other interested developers can teach, learn, and experiment with advanced computer language infrastructure. To achieve this goal, the source code to both the Windows XP and FreeBSD versions of the software has been released using the shared source approach to source code access. The license for the Shared Source CLI Implementation permits anyone to use or modify its code for non-commercial purposes.

Flexibility Is Standard

The ECMA-335 (CLI) standard describes a language-agnostic runtime engine that is capable of converting lifeless blobs of metadata into self-assembling, robust, and type-safe software systems. The managed components that populate these software systems can be written in any of a number of different computer languages, yet still interact robustly, and with high fidelity. The secret to this spirit of cooperation is the shared runtime infrastructure of the CLI, which includes not only low-level capabilities such as standardized metadata and intermediate language representation, but also high-level, productivity-related capabilities such as universally available class libraries. For the benefit of existing codebases, the CLI standard also takes pains to describe in detail how unmanaged software can co-exist safely with managed components, enabling seamless sharing of computing resources and responsibilities.

The authors of the CLI standard anticipate a world in which there will be multiple implementations of that standard, each supporting the same base set of features, but each also exposing unique capabilities such as additional frameworks, services, utilities, or language features. This is akin to the philosophy of C#'s progenitor, the C language and runtime. In a well-known set of papers and books from the early 1970s, Brian Kernighan and Dennis Ritchie documented their quest to strike the right balance between portability and type safety on the one hand, and expressive access to underlying hardware and software on the other. Like the C runtime, the CLI has been designed to exploit the power of diverse platforms, as well as to complement existing tools, languages, and runtimes.

The specification that describes the interface to this interoperability engine is voluminous; approaching it as an implementer can be daunting. Going beyond the standard, Microsoft realized that there needed to be at least one sample that shows how to create a working instance of this engine. The Shared Source CLI fills this gap, providing an implementation that demonstrates one way (but certainly not the only way) to build a portable, programming language-independent version of the CLI standard.

CLI Foundations

Please remember when you download the Shared Source CLI that it is an experimental and non-commercial implementation! The source code, although fairly stable, is of beta quality. We will be updating this drop, although we do not yet have dates for when updates might be expected. The development team will be lurking on NNTP at the microsoft.public.shared_source.cli newsgroup, and your feedback is desired. In addition, a Shared Source CLI-moderated discussion list has been created by the University of Pisa, and DevelopMentor is hosting a Shared Source CLI discussion group.

Let's look at a few of the likely ways that the Shared Source CLI Implementation might interest you:

  • There are significant differences in implementation between this code and the code for Microsoft's commercial CLR implementation, both to facilitate portability and to make the codebase more approachable. Nonetheless, if you are a developer who is interested in the gory details of virtualized object systems, of how to design object frameworks, of how JIT compilers and garbage collectors work, or of how Microsoft Visual Studio® works on your behalf under the covers, this distribution will definitely hold your attention!
  • If you are a teacher who is interested in creating courseware around interesting topics that can be illustrated by this codebase, or a researcher who is engaged in research or prototyping that would benefit from being built upon the foundation of this source code, this distribution will delight you. For example, individuals working with program-guided optimizations, such as data and code layout or code compaction, might use the reflection capabilities of the runtime to their advantage. Alternatively, a compiler internals course might reference the C#, Microsoft JScript®, or runtime JIT compilers as examples. The list of potential topics is literally huge.
  • Finally, if you are thinking about implementing your own version of the CLI, or if you need to understand more about the ways that compilers and tools can target Common Intermediate Language or the Base Class Libraries, this distribution will be an indispensable guide for you. The completeness of the offering, along with its liberal licensing terms, will make the Shared Source CLI both a valuable example and a test case for everyone.

As a member of the Rotor development team at Microsoft, I invite everyone to download this code, poke around, and have fun with it. The CLI standard will be important for years to come, and there is no better way to understand it fully than browsing and building these sources. We also hope that the availability of this code to researchers and teachers will provide a foundation for future innovation. The possibilities here are very broad—please share your ideas and results with us!

Additional Resources

You can read more about the Microsoft Shared Source CLI in MSDN Magazine.