15

In nuget.org, when you check any package there are 2 types of framework. enter image description here

What is the difference between Compatible target framework and additional computed target framework?

Newbie
  • 563
  • 1
  • 5
  • 16

1 Answers1

15

A compatible target framework is directly derived from the Target Framework Monikers (TFMs) of a NuGet package. In your screenshot, the NuGet package targets net45 and netstandard2.0 - you will find these entries in the corresponding .csproj/.nuspec file.

The additional computed target frameworks are all kind of frameworks which are implicitly supported due API compatibility. For example every project targeting netstandard2.0 is compatible to netstandard2.1, as the APIs of .NET Standard 2.1 completely contain all APIs of .NET Standard 2.0.
The same is true for net45: an application/assembly targeting .NET Framework 4.5 will automatically be supported on .NET Framework 4.6, 4.7, etc.

Microsoft announced this here.

mu88
  • 4,156
  • 1
  • 23
  • 47
  • For example, I don't understand why https://www.nuget.org/packages/IdentityServer4#supportedframeworks-body-tab supports .net 5. Code written for .net 3.1 is not de facto compatible with .net 5 because of the many breaking changes : cf. https://learn.microsoft.com/en-us/dotnet/core/compatibility/5.0. So why is nuget saying that this lib is compatible with .net 5 ? – Yanal-Yves Fargialla Sep 21 '22 at 16:02
  • Well, I think that focusing on breaking changes has a certain bias because it doesn't take into account the sheer mass of APIs that remained stable/untouched/compatible. Doing such a fine-grained decision cannot be done without proper analysis. Just think about a .NET Core 3.1 assembly using a deprecated API in an unused method. When referencing and running this assembly in a .NET 5 context, the JIT compiler will not call the deprecated API (because the method is unused), so there won't be a problem. – mu88 Sep 22 '22 at 06:17
  • 1
    Thank you for your answer. I am not sure to understand. Does "Computed additional target framework(s)", means "you can try this package with that target framework and see if it works" ? So for exemple, without testing IdentityServer4 with net 60, there's no way to be sure it works fine with net 60. Is that correct ? – Yanal-Yves Fargialla Sep 23 '22 at 19:20