.NET Standard Flashcards
What is the difference between portable class libraries and .net standard?
PCL requires recompilation for each intersection profile (target) you want to be compatible with. .net standard you compile once.
How does .net standard ensures backwards compatibility?
Because it only ADDS new apis every version, therefore the previous existing implemented api still work
What is the golden rule to define a .net std class lib?
target the lower version as possible since it’ll reach more platforms.
What does versioning in .net std look like?
1 - the higher the std version the more api but less plat.
2 - the lower the std ver the less apis but more plat.
how to create a .net std class lib that follows the golden rule?
create the lib using the latest version, then downgrade it until it doesn’t compile. choose the lowest
How to find what each version of .net standard implements?
on docs.microsoft.com or github. github has a diff between versions.
how to see the intermediate language code generated by a std class lib?
by using ILDasm
What is type forwarding in the .net standard ecosystem?
Is a technique used to allow the .net std class lib to instead of using its own contract to use the target contract (the one that the concrete application is using)
What is a concrete application?
is a application that targets anything but .net standard (runnable).
Details here: https://pasteboard.co/Jyc1W2q.png
What happens when you open .netstandard.dll in the concrete app folder in IL DASM?
It shows all the type forwardings to the concrete platform and no implementations.
What is Compatibility Shim (aka Compat Shim)? How it improves the interop of different targets on .net?
Compatibility Shim brings the .net standard interoperability with .net framework class libs, meaning .net std 2.0 can depend on a .net framework lib (4.6.1). Details at: https://pasteboard.co/JydsVmD.png
What happens when the referenced .net framework library uses non-supported-.net std apis?
a file not found exception will be thrown at runtime
What is .net portability analyzer extension? where to find it?
checks if the .net ptroject is portable to a target platform. find it in the online extensions of visual studio.
What are the 4 steps to convert a simple .net framework project to standard?
unload the project, edit the csproj and copy a .net std content project sdk, prop group and target framework, then remove the assembly info and property folders, then add back the dependencies as nuget packages.
Why do we need to install the newtonsoft.json lib twice (one in the .net std and other in the framework)?
Because the first work with package reference and the latter work with packages.config, therefore the file won’t be found in the assembly output directory.