1. Basic theory of.net Core

1.1. Important Tools

Projects under.NET FlatForm: github.com/dotnet/

NET Core source: github.com/dotnet/runt…

Asp.net Core source: github.com/dotnet/aspn…

.net Core Extension library: github.com/dotnet/exte…

Most importantly: github.com/dotnet/runt…

The Core and at asp.net. NET Core is two relatively independent technology stacks. Asp.net Core doesn’t absolutely depend on either one. The.net framework. The.net Foundation has not yet decided. When NET Core was open source, ASP.NET MVC was already open source.

Asp.net Core is an upper-level development framework with no underlying framework. NET core. Runtime. Net Core Mono.

The Mac version of VS is not VS, it is a derivative of Xamarin Studio, MonoDevelop.

Migrate from the.NET FrameWork to. How to do NET Core?

Upgrade.net Core version, where incompatible.

.NET migration analysis tool, analyze project source code, and generate analysis report.

1.2. Important Components

.NET Core is not a single open source project, it is a collection of open source projects. Its Core consists of four pillar projects: Core CLR, CoreFx, CLI, and Rolsyn.

(1) Core CLR: It is the most important part. NET Core common language runtime, written by C++ implementation. The JRE equivalent of Java. Core CLR is by and by. CLR of NET FW. Structurally consistent with CLR.

Components or main functions of the Core CLR:

The CLR’s first duty is to execute. NET program. .NET programs differ greatly from programs compiled in languages like C or C++. Native programs (which contain machine code for a particular hardware architecture, call interfaces for a particular system, and can only be executed on a particular platform).

.NET program: intermediate code, independent of platform, can run on different platforms.

The Core CLR parses the intermediate code, translates it into machine code for the target platform, and generates metadata (type information, GC information, exception information) to support various mechanisms.

The part of the CLR that loads the compiled IL into memory is the part of the Class Loader that translates the code called the JIT.

The current code execution path, operating system, hardware situation, compile the most efficient assembly code for the current computer execution.

JIT is the IL(intermediate language, MSIL) compiler, not C# compiler.

CLR to ensure type safety. Type safety refers to. NET program to ensure that the object type must be correct.

The CLR provides an exception handling mechanism. Traditional mechanisms that use function return values for notification and error handling are difficult to implement. This part is also handled in the CLR.

Threading, the CLR wraps native threads and synchronous objects, so multithreading can be done on different platforms in the same way on hosted platforms.

Automatic memory management, garbage collection (GC), is also in the CLR. When we allocate resources, we can ignore it.

The GC keeps an eye on memory changes, starts and destroys invalid objects in memory when appropriate, and reclaims and manages memory. The GC can only auto-destroy CLR managed objects, unmanaged objects (e.g., file handles), and unmanaged resources are wrapped in managed code, so manual handling is generally not necessary. It was released in escrow, packaged… This is not what GC does.

(2)CoreFx and CoreCLR are still two projects, but are merged into the same repository for the convenience of developers. The Core is FX. NET Core’s base class library, written entirely in C#, is a library function project. For example, the system.DateTime type. In.NET 5, the name of the project was changed to Libraries==Core FX.

What the base library does: Reduce. NET developer workload; Data interaction between different modules can be made easier.

Most of the code for Core FX comes from. NET FrameWork BCL porting over.

Core FX makes extensive use of the Parial keyword (partial classes) in order to be compatible with multiple operating systems. Put code common to multiple platforms in one source file, and code specific to a particular operating system in another platform-specific source file.

Different CLR, cross-platform. Different platforms have different CLRS. There are different implementations of Framework, Mono, etc.

The function is different again. NET Standard, that is. NET Standard (.net Standard is not a library, but a Standard). In the original framework class library divided some of the most basic functions, implemented by different CLR. The higher the.NET standard version, the more functions required to support…

.NET Framework 4.6.1 and. NET Core 2.0 supports both. NET standard 2.0. If you are using the.NET standard 2.0 project, you can use the. NET Framework 4.6.1 and. NET Core 2.0. .NET Framework 4.6.1 does not support it. NET standard 2.0, support. NET standard 1.3. In order to be compliant with the.NET standard,.net development teams migrate in accordance with this.

(3) the CLI:

The CLI has two. Common Language Infrastructure; Command Line Interface Command Line Interface

A common intermediate language is a public technical standard that defines an intermediate language independent of the specific operating system and hardware architecture, and the runtime environment required to execute the language. In C#, int is always 4 on any platform!

CLI features: Cross-platform and cross-language.

Instead of writing IL directly, we usually write a high-level language and then use a tool (Roslyn) to switch to an intermediate language.

Intermediate language definition of the standard is some definition specification: int, long, string appearance, what type, the type of instruction, method structure, module structure, binary file format…

When a high-level language is compiled into an intermediate language (IL), it shares this standard.

Universal intermediate language and. NET Core has nothing to do with it.

Command Line Interface Is the same as the Command Line Interface. NET Core. Previously.Net Framework only supported Windows. Win32 GUI tools do not support Linux file systems, executable file formats.

.net Core is designed to be cross-platform. It needs to be unified, efficient and easy to use across multiple platforms. NET Core tools, very difficult things.

CLI is a standalone project.

Does.net Core compile binary files to produce different file formats for different operating systems, or to produce a uniform file format? .NET Core generates a uniform file format.

.net Core cross-platform development, whether Win or Linux,.NET Core compiled binary files are DLL, and are all in PE format.

.NET Core must provide a container that allows all operating system platforms to connect to DLL files in the PE format.

CLI tools are available in. NET Core 2.0 was just fixed.

The entire CLI project consists of several tools developed in different languages, which later became a tool called Dotnet, which can be used for project management, project building, code running, package management.

(4) Rolsyn

It is a high-level language compiler for.NET. Can compile C#, VB.NET, F#.

Specifically, Rolsyn is defined by Microsoft as a next-generation compilation platform, not just a compiler.

Because in addition to code compilation, it also provides code analysis services, rich APIS.

Before Rolsyn, the compiler for C# was CSC. The IL generated by Rolsyn is much more efficient and the compilation time is much shorter.

Starting with VS2017, Rolsyn provides dynamic compilation when code is compiled. The head of the class is referenced by several references

C# is compiled to IL by Rolsyn.

Previously, the four open source projects were independent repositories.

1.3 Analysis of common problems

.NET Core definition: a small, efficient cross-platform framework that can be deployed directly through file replication.

Why is.NET Core so popular?

(1) Open source itself, encouraging more. NET project open source.

For traditional.NET developers, however, this is not something familiar.

Open Source License agreement, open Source agreement.

To get a sense of how much times have changed, Microsoft executives in the early 2000s said that open source was a massive destruction of intellectual property.

Now that Microsoft has acquired GITHUB, this change has nothing to do with. NET Foundation has a lot to do with it.

The.net Foundation is an independent organization that supports. NET community and open source, with the aim of broadening and enhancing. NET ecosystem. Microsoft was founded in 2014 with 6 founders, but none of them are Microsoft employees. Until reelection in 2019, there was not a single Microsoft employee. The rest are MVPS and many other well-known companies (amazon, Google, Samsung).

.net Core source code as well. The open source projects around NET Core are important assets for the foundation.

Open source projects are basically under an MIT license. NET Core is extremely open and portable.

There are four major software licenses: GPL, Apache, BSD and MIT.

The purpose of these agreements: to protect and respect the intellectual property rights of authors, even if it is open source, it does not mean that the source code can be freely used!!

GPL: The most restrictive use of open source software and highly contagious. Core idea: Open source software all over the world! If your software uses even a derivative of it, it must be under the GPL. This poses a big challenge for commercial software. Because this core idea, it’s not developing very well. Hence a variant, LGPL. Commercial software does not need to be open source if it only references software under the LGPL license, but it must be open source if it modifies the LGPL source code. Once China happened an infringement of the event, Android TV version of the software. Other developers stumbled upon it and told the original author who was cited.

Apache Protocol: created by the Apache Foundation. It is widely present in Apache software. The agreement encourages users of open source software to give full respect to the software’s original authors. If you use the Apache protocol, simply state that you use it and the author. If you have made changes to the Apache Western Medicine program, post instructions on the changes you continue to make. He does not mandate open source.

BSD and MIT are the most relaxed protocols, encouraging developers to use, modify, and distribute freely. The difference: BSD provides that if you modify the source code of software under BSD before distributing it, you cannot use the name of the original author of the project to promote it.

The entire family of open source projects in.NET Core use the MIT protocol. It can be modified, ported, packaged, and distributed without limit. This is the biggest driver of.NET Core.

(2) the cross-platform

(3) High performance. Better than the.NET Framework and more efficient than other open source frameworks.