[release/7.0] Use platform runtime check for ProtectedData #80196
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #80158 to release/7.0
Description
Reported by a customer in #78875. The System.Security.Cryptography.ProtectedData package erroneously throws a
PlatformNotSupportedException
on Windows for non .NETCoreApp targets, like UWP, which use the .NETStandard targets.This changes the package from using target platform identifiers to using runtime checks to determine if the platform is Windows. Using target platform identifiers with .NET Standard was removed in .NET 7, so the checks are now performed at runtime.
Customer Impact
Customers are unable to use version 7.0.0 of this package on Windows in a UWP project, or other .NET platforms that are not a .NETCoreApp target.
Regression
This is a regression from the 6.0.x version of the package, which works correctly on Windows with .NET Standard.
Testing
Manually verified the package contents and that it can be used from a UWP project.
Risk
Medium-low. The tests verify the code is behaving as-expected both on Windows and non-Windows systems, but the change also simplifies the target framework of the package, which may have unexpected consequences in build-over-build validation tools.
Package authoring signed off?
Required. This services System.Security.Cryptography.ProtectedData.
IMPORTANT: If this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.