-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Audit CoreLib for members that stay safe under unsafe-v2 #131719
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
base: main
Are you sure you want to change the base?
Changes from all commits
7dc6b06
7362e2c
b6a95f5
e5a0743
6a3b04b
02e1cf8
323ae82
3adb897
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,14 +19,16 @@ public static int CurrentManagedThreadId | |
| } | ||
|
|
||
| // Terminates this process with the given exit code. | ||
| /// <safety>QCall that passes the integer exit code to the runtime to terminate the process; it accesses no caller-supplied memory.</safety> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we going to require every LibraryImport to have a safety comment, even ones with trivial signatures?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It is not really required, but for consistency it's nice to have an explanation why something needed an explicit caller- But all LibraryImport (just like all |
||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Environment_Exit")] | ||
| [DoesNotReturn] | ||
| private static partial void _Exit(int exitCode); | ||
| private static safe partial void _Exit(int exitCode); | ||
|
|
||
| [DoesNotReturn] | ||
| public static void Exit(int exitCode) => _Exit(exitCode); | ||
|
|
||
| public static extern int ExitCode | ||
| /// <safety>Runtime FCall get/set of the process-wide exit code (an int); it accesses no caller-supplied memory.</safety> | ||
| public static safe extern int ExitCode | ||
| { | ||
| [MethodImpl(MethodImplOptions.InternalCall)] | ||
| get; | ||
|
|
@@ -116,8 +118,9 @@ private static unsafe void InitializeCommandLineArgs(char* exePath, int argc, ch | |
| } | ||
| } | ||
|
|
||
| /// <safety>QCall that returns the available processor count as an int; it accesses no caller-supplied memory.</safety> | ||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "Environment_GetProcessorCount")] | ||
| internal static partial int GetProcessorCount(); | ||
| internal static safe partial int GetProcessorCount(); | ||
|
|
||
| [UnmanagedCallersOnly] | ||
| private static unsafe void GetResourceString(char* pKey, string* pResult, Exception* pException) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Is this one even relevant anymore? Wasn't it entirely replaced by IDE0036, which is more powerful and stays up to date with new language keywords?
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.
I don't know, but it does still kick in. I've got an impression that stylecop is not actively maintained?
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.
I'm not sure if it is maintained anymore either, its not had an update in over 8 months.
Certainly many of the rules have been replaced by in-box ones as well, so it might be worth considering what's adding value still (and what can be removed or disabled).