2 .NET and how it compiles

 

This chapter covers

  • Compiling C# to native code
  • Reading and understanding Intermediate Language

In 2020, Microsoft released .NET 5, an all-encompassing software development platform. Before that, in the late 1990s and early 2000s, Microsoft created the .NET Framework, which was the precursor to .NET 5. The original use case for the .NET Framework was developing enterprise Windows applications. In fact, we’ll use the .NET Framework to examine exactly such a codebase in chapters 3 and 4. The .NET Framework ties together a large collection of libraries. Although the .NET Framework and C# are frequently used together, we do encounter use cases for the .NET Framework without C# (most notably, using a different .NET language). The two most important pillars of the .NET Framework are the Framework Class Library (FCL; a humongous class library that is the backbone of the .NET Framework) and the Common Language Runtime (CLR; the runtime environment of .NET that contains the JIT compiler, garbage collector, primitive data types, and more). In other words, the FCL contains all the libraries you are likely to use, and the CLR executes the code. Later on, Microsoft introduced .NET Core, aimed at multiplatform development. See figure 2.1 for where this chapter falls in the book’s scheme.

2.1 What is the .NET Framework?

2.2 What is .NET 5?

Exercises

2.3 How CLI-compliant languages are compiled

2.3.1 Step 1: C# code (high-level)

2.3.2 Step 2: Common Intermediate Language (assembly level)

2.3.3 Step 3: Native code (processor level)

Exercises

Summary