.NET Standard Flashcards

1
Q

What is the difference between portable class libraries and .net standard?

A

PCL requires recompilation for each intersection profile (target) you want to be compatible with. .net standard you compile once.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does .net standard ensures backwards compatibility?

A

Because it only ADDS new apis every version, therefore the previous existing implemented api still work

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the golden rule to define a .net std class lib?

A

target the lower version as possible since it’ll reach more platforms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does versioning in .net std look like?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to create a .net std class lib that follows the golden rule?

A

create the lib using the latest version, then downgrade it until it doesn’t compile. choose the lowest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to find what each version of .net standard implements?

A

on docs.microsoft.com or github. github has a diff between versions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how to see the intermediate language code generated by a std class lib?

A

by using ILDasm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is type forwarding in the .net standard ecosystem?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a concrete application?

A

is a application that targets anything but .net standard (runnable).
Details here: https://pasteboard.co/Jyc1W2q.png

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens when you open .netstandard.dll in the concrete app folder in IL DASM?

A

It shows all the type forwardings to the concrete platform and no implementations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Compatibility Shim (aka Compat Shim)? How it improves the interop of different targets on .net?

A
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What happens when the referenced .net framework library uses non-supported-.net std apis?

A

a file not found exception will be thrown at runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is .net portability analyzer extension? where to find it?

A

checks if the .net ptroject is portable to a target platform. find it in the online extensions of visual studio.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 4 steps to convert a simple .net framework project to standard?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why do we need to install the newtonsoft.json lib twice (one in the .net std and other in the framework)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to make a .net framework project use nuget packages referenced in the dependencies’ csproj (.net core style) instead of packages.config file (framework style)?

A

Unload the project, and add a new entry in the property group element: PackageReference

17
Q

How to target multiple platforms in a .net std library?

A

edit the csproj from targetframework to frameworks, then define the frameworks with the proper mnemonic net461;netstandard1.3

18
Q

How to open a source code using a specific target framework?

A

there is a dropdown in the top of the source code screen where you can choose.

19
Q

How to add dependencies for a specific target in the csproj file?

A

add a new item group with a condition to ‘$(TargetFramework) == ‘net461’ then add the reference elements beneath it

20
Q

What to do in old version of visual studio 15 with multi target-reference dependencies? supposed to work on 16… does it apply to nuget references as well?

A

you need to multi target the whole “cascade of dependencies) otherwise it’ll always fallback to the first dependency (which is likely to be std)

nuget package works just fine.

21
Q

What is the microsofr.windows.compatibility nuget package?

A

has several apis, also for platform specific but be aware of PlatformNotFound exceptions in linux environments.

22
Q

can i add local sources for nuget packages?

A

yes.. just click the gear icon and add the new source… then select the source in the nuget screen

23
Q

do all the targets of my nuget package appear in the selected nupkg?

A

YES… check the dependencies section (.netframework section and .netstd section)