sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

Bump minimum .NET Framework target to 4.6.2.

Open SimonCropp opened this issue 2 years ago • 3 comments

so v7 of System.Text.Json drops support for net461 https://www.nuget.org/packages/System.Text.Json/7.0.0-preview.4.22229.4

So i assume we need to change the min target to 462?

SimonCropp avatar May 22 '22 23:05 SimonCropp

Looks like it still is being built for netstandard2.0, so net461 should still work - no?

mattjohnsonpint avatar May 23 '22 19:05 mattjohnsonpint

officially yes. in reality no

  • https://github.com/dotnet/standard/issues/404
  • https://andrewlock.net/stop-lying-about-netstandard-2-support/
  • https://github.com/dotnet/roslyn/issues/22903

the caveat is here https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version

image

2 The versions listed here represent the rules that NuGet uses to determine whether a given .NET Standard library is applicable. While NuGet considers .NET Framework 4.6.1 as supporting .NET Standard 1.5 through 2.0, there are several issues with consuming .NET Standard libraries that were built for those versions from .NET Framework 4.6.1 projects. For .NET Framework projects that need to use such libraries, we recommend that you upgrade the project to target .NET Framework 4.7.2 or higher.

SimonCropp avatar May 24 '22 01:05 SimonCropp

Given that Microsoft recently ended support for .NET Framework 4.6.1 on April 26, 2022, I would be ok bumping that to 4.6.2 at the same time we add a net7.0 target in the next major release.

mattjohnsonpint avatar May 24 '22 17:05 mattjohnsonpint

Thinking this through more over time, I think we need to keep the net461 target. The main reason is that dropping it would go aginst Sentry's stated philosophy:

https://develop.sentry.dev/sdk/philosophy/#compatibility-is-king

Since we would still be offering a netstandard2.0 target, then an app using net461 would get that target installed, potentially opening them up to bugs that we wouldn't be able to resolve.

Also, it doesn't do much for us really. As long as we have to build for netstandard2.0 and any version of .NET Framework, most of the workarounds we have today will need to remain in place.

As for the STJ concern, this is the only place we take a hard dependency.

https://github.com/getsentry/sentry-dotnet/blob/7260dff98edf2ab0148dafed0234977cb0caf7d6/src/Sentry/Sentry.csproj#L60-L63

So .NET Framework and .NET Standard targets will use a minimum STJ of 5.0.2, which won't change unless there's a big problem, such as a security vulnerability. Applications can install a newer STJ if they want or need to. Most newer targets (.NET Core 3.0+) will by default get the version of STJ bundled with the runtime (6.x for .NET 6, 7.x for .NET 7, etc.).

Thus there's nothing special we need to do for continued STJ support across all our targets.

If in the future we find that one of our dependencies dropped NET461 and that became an issue, we could always pin NET461 to the dependencies last working version and create a separate NET462 target. But that's not warranted at this time.

Thanks.

mattjohnsonpint avatar Oct 27 '22 20:10 mattjohnsonpint