chapter two

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. This was the pre-cursor to .NET 5. The original use-case for the .NET Framework was developing enterprise Windows applications. In fact, we use the .NET Framework to examine exactly such a code base in chapters 3 and 4. The .NET Framework ties together with a large collection of libraries. Whilst the .NET Framework and C# are frequently used together, there are use cases for the .NET Framework without C# (most notably, using a different .NET language). The two most important pillars of what makes up 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 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 multi-platform development.

2.1      What is the .NET Framework?

2.2      What is .NET 5?

2.2.1      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)

2.3.4      Exercises

2.4      Summary