-
Notifications
You must be signed in to change notification settings - Fork 306
Isolate POSIX-specific native calls in PythonNT into separate file #1870
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
Conversation
| } | ||
|
|
||
| if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { | ||
| if (!isWindows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really an issue since we're not calling native APIs here, but any idea if the platform analyzer would pick up on an isWindows variable and guard against Windows calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it is written now, no platform-specific calls are allowed in CheckFileAccessAndSize, regardless whether they are conditioned by isWindows in any way. .NET has SupportedOSPlatformGuardAttribute, but it cannot be applied to a parameter.
The reason why I replaced the platform check with a parameter is because having the platform test in this function was invalidating the platform context after the first call site, and I needed to make a call to PythonNT.dupUnix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, didn't know (or forgot) that SupportedOSPlatformGuardAttribute existed.
Weird that iy breaks the platform check. Alternatively the parameter could be called allowGrow or something.
slozier
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Src/IronPython.Modules/_winapi.cs
Outdated
| public static class PythonWinApi { | ||
| #region Public API | ||
|
|
||
| [SupportedOSPlatform("windows")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the attribute on both the class and method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's redundant.
This adds platform guards to relevant functions in
PythonNT. By keeping them in a separate file I hope it will be easier to prevent omissions and inadvertent loads ofMono.Unixon Windows. Also, it makesnt.csjust a little bit smaller, which is always a good thing.