官术网_书友最值得收藏!

Compatibility mode

Although more than 33K APIs have been added into .NET Standard 2.0, many of the NuGet packages still target .NET Framework, and moving them to .NET Standard is not possible, since their dependencies are still not targeted at .NET Standard. However, with .NET Standard 2.0, we can still add packages which show a warning but don't block adding those packages into our .NET Standard library.

Under the hood, .NET Standard 2.0 uses compatibility shim, which solves the third party library compatibility issue and makes it easy in referencing those libraries. In the CLR world, the identity of the assembly is part of the type identity. This means that when we say System.Object in .NET Framework, we are referencing [mscorlib]System.Object and with .NET Standard, we are referencing [netstandard]System.Object, so if we are referencing any assembly which is part of .NET Framework, it cannot be easily run on .NET Standard and so compatibility issues arise. To solve this problem, they have used type forwarding which provides a fake mscorlib assembly that type forwards all the types to the .NET Standard implementation.

Here is a representation of how the .NET Framework libraries can run in any of the .NET Standard implementations using the type forwarding approach:

On the other hand, if we have a .NET Framework library and we wanted to reference a .NET Standard library, it will add the netstandard fake assembly and perform type forwarding of all the types by using the .NET Framework implementation:

To suppress warnings, we can add NU1701 for particular NuGet packages whose dependencies are not targeting .NET Standard.
主站蜘蛛池模板: 西城区| 河曲县| 曲阜市| 茂名市| 慈利县| 定州市| 阿鲁科尔沁旗| 台前县| 泰兴市| 保定市| 永福县| 石城县| 洪洞县| 自治县| 东海县| 彝良县| 金乡县| 甘肃省| 湄潭县| 龙游县| 阿勒泰市| 万宁市| 交城县| 东山县| 额敏县| 郓城县| 盐亭县| 墨玉县| 五家渠市| 全南县| 牡丹江市| 昭平县| 措勤县| 大荔县| 吉木萨尔县| 临泉县| 齐齐哈尔市| 文登市| 固始县| 正阳县| 闵行区|