Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Guard statements for OS-specific APIs #1113

Open
CharliePoole opened this issue Jan 25, 2022 · 1 comment
Open

Add Guard statements for OS-specific APIs #1113

CharliePoole opened this issue Jan 25, 2022 · 1 comment

Comments

@CharliePoole
Copy link
Contributor

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.

@CharliePoole
Copy link
Contributor Author

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.

@CharliePoole CharliePoole modified the milestones: 3.15.0, 4.0 Jan 26, 2022
@CharliePoole CharliePoole removed their assignment Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant