Add Guard statements for OS-specific APIs
This is a soft prerequisite to #1044. That is, we could work around it in somewhat complicated ways... but let's not!
Our .NET 5.0 builds contain unguarded calls to Windows-specific apis like Registry.GetRegistryKey. They work because we don't actually call those APIs unless we have verified that we are running on Windows.
Once we introduce .NET 6.0 builds, the default settings will result in errors for those calls. While we could suppress those checks, it makes more sense to go ahead and start using guard statements like if (OperatingSystem.IsWindows()) before such calls.
In addition, we should probably isolate such code in separate methods and apply SupportedOSPlatformAttribute to them.
After fixing #1115, my test build using net6.0 no longer gives errors due to windows-specific apis, so I'm removing this from the 3.15.0 milestone.
We'll still need to look at this issue for 4.0.