Professional C# 6 and .NET Core 1.0. Christian Nagel
Чтение книги онлайн.
Читать онлайн книгу Professional C# 6 and .NET Core 1.0 - Christian Nagel страница 8
With .NET 3.0, the class count of the Framework increased from 8,000 types in .NET 2.0 to about 12,000 types.
NOTE In this book, WPF is covered in Chapters 29, 30, 31, 34, 35, and 36. You can read information about WCF in Chapter 44, “Windows Communication Foundation.”
C# 3 and .NET 3.5 – LINQ
.NET 3.5 came together with a new release of C# 3. The major enhancement was a query syntax defined with C# that allows using the same syntax to filter and sort object lists, XML files, and the database. The language enhancements didn’t require any change to the IL code as the C# features used here are just syntax sugar. All of the enhancements could have been done with the older syntax as well, just a lot more code would be necessary. The C# language makes it really easy to do these queries. With LINQ and lambda expressions, it’s possible to use the same query syntax and access object collections, databases, and XML files.
For accessing the database and creating LINQ queries, LINQ to SQL was released as part of .NET 3.5. With the first update to .NET 3.5, the first version of Entity Framework was released. Both LINQ to SQL and Entity Framework offered mapping of hierarchies to the relations of a database and a LINQ provider. Entity Framework was more powerful, but LINQ to SQL was simpler. Over time, features of LINQ to SQL have been implemented in Entity Framework, and now this one is here to stay. (Nowadays it looks very different from the first version released.)
Another technology introduced as part of .NET 3.5 was the System.AddIn namespace, which offers an add-in model. This model offers powerful features that run add-ins even out of process, but it is also complex to use.
NOTE LINQ is covered in detail in Chapter 13, “Language Integrated Query.” The newest version of the Entity Framework is very different from the .NET 3.5 release; it’s described in Chapter 38, “Entity Framework Core.”
C# 4 and .NET 4 – Dynamic and TPL
The theme of C# 4 was dynamic – integrating scripting languages and making it easier to use COM integration. C# syntax has been extended with the dynamic keyword, named and optional parameters, and enhancements to co- and contra-variance with generics.
Other enhancements have been made within the .NET Framework. With multi-core CPUs, parallel programming had become more and more important. The Task Parallel Library (TPL), with abstractions of threads using Task and Parallel classes, make it easier to create parallel running code.
Because the workflow engine created with .NET 3.0 didn’t fulfill its promises, a completely new Windows Workflow Foundation was part of .NET 4.0. To avoid conflicts with the older workflow engine, the newer one is defined in the System.Activity namespace.
The enhancements of C# 4 also required a new version of the runtime. The runtime skipped from version 2 to 4.
With the release of Visual Studio 2010, a new technology shipped for creating web applications: ASP.NET MVC 2.0. Unlike ASP.NET Web Forms, this technology required programming HTML and JavaScript, and it used C# and .NET with server-side functionality. As this technology was very new as well as being out of band (OOB) to Visual Studio and .NET, ASP.NET MVC was updated regularly.
NOTE The dynamic keyword of C# 4 is covered in Chapter 16, “Reflection, Metadata, and Dynamic Programming.” The Task Parallel Library is covered in Chapter 21, “Tasks and Parallel Programming.”
Version 5 of ASP.NET and Version 6 of ASP.NET MVC are covered in Chapter 40, “ASP.NET Core,” and Chapter 41, “ASP.NET MVC.”
C# 5 and Asynchronous Programming
C# 5 had only two new keywords: async and await. However, they made programming of asynchronous methods a lot easier. As touch became more significant with Windows 8, it also became a lot more important to not block the UI thread. Using the mouse, users are accustomed to scrolling taking some time. However, using fingers on a touch interface that is not responsive is really annoying.
Windows 8 also introduced a new programming interface for Windows Store apps (also known as Modern apps, Metro apps, Universal Windows apps, and, more recently, Windows apps): the Windows Runtime. This is a native runtime that looks like .NET by using language projections. Many of the WPF controls have been redone for the new runtime, and a subset of the .NET Framework can be used with such apps.
As the System.AddIn framework was much too complex and slow, a new composition framework was created with .NET 4.5: Managed Extensibility Framework with the namespace System.Composition.
A new version of platform-independent communication is offered by the ASP.NET Web API. Unlike WCF, which offers stateful and stateless services as well as many different network protocols, the ASP.NET Web API is a lot simpler and based on the Representational State Transfer (REST) software architecture style.
NOTE The async and await keywords of C# 5 are discussed in detail in Chapter 15, “Asynchronous Programming.” This chapter also shows the different asynchronous patterns that have been used over time with .NET.
Managed Extensibility Framework (MEF) is covered in Chapter 26, “Composition.” Windows apps are covered in Chapters 29 to 33, and the ASP.NET Web API is covered in Chapter 42, “ASP.NET Web API.”
C# 6 and .NET Core
C# 6 doesn’t involve the huge improvements that were made by generics, LINQ, and async, but there are a lot of small and practical enhancements in the language that can reduce the code length in several places. The many improvements have been made possible by a new compiler engine code named Roslyn.
NOTE Roslyn is covered in Chapter 18, “.NET Compiler Platform.”
The full .NET Framework is not the only .NET Framework that was in use in recent years. Some scenarios required smaller frameworks. In 2007, the first version of Microsoft Silverlight was released (code named WPF/E, WPF Everywhere). Silverlight was a web browser plug-in that allowed dynamic content. The first version of Silverlight supported programming only via JavaScript. The second version included a subset of the .NET Framework. Of course, server-side libraries were not needed because Silverlight was always running on the client, but the Framework shipped with Silverlight also removed classes and methods from the core features to make it lightweight and portable to other platforms. The last version of Silverlight for the desktop (version 5) was released in December 2011. Silverlight had also been used for programming for the Windows Phone. Silverlight 8.1 made it into Windows Phone 8.1, but this version of Silverlight is also different from the version on the desktop.
On the Windows desktop, where there is such a huge framework with .NET and the need for faster and faster development cadences, big changes were also required. In a world of DevOps where developers and operations work together or are even the same people to bring applications and new features continuously to the user, there’s a need to have new features available in a fast way. Creating new features or making bug fixes is a not-so-easy task with a huge framework and many dependencies.
With several smaller .NET Frameworks available (e.g. Silverlight, Silverlight for the Windows Phone), it became important to share code between the desktop version of .NET and a smaller version. A technology to share code between different .NET versions is the portable library. Over time, with many different .NET Frameworks and versions, the management of the portable library has become a nightmare.
With all