You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Analyzer suggestion: Prefer SafeHandle over IntPtr #42404
After working on some Interop analyzers I thought about SafeHandle and how known api's could suggest using the corresponding safehandle, such as SafeFileHandle or SafeWaitHandle. This could also more broadly be applied based on the method name, e.g. methods contains alloc/free could offer a warning when an IntPtr is used instead of a custom safehandle.
I'd be concerned with false positives with any attempt to use the method name. For known APIs, this seems reasonable, however we have #42550, where marshalling SafeHandle doesn't allow null. We would need to address that issue before adding an analyzer like this.
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
Dotnet-GitSync-Bot commentedon Sep 17, 2020
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
jeffschwMSFT commentedon Sep 21, 2020
@elinor-fung can you take a look?
elinor-fung commentedon Sep 21, 2020
I'd be concerned with false positives with any attempt to use the method name. For known APIs, this seems reasonable, however we have #42550, where marshalling
SafeHandledoesn't allow null. We would need to address that issue before adding an analyzer like this./cc @AaronRobinsonMSFT @jkoritzinsky
AaronRobinsonMSFT commentedon Sep 21, 2020
@elinor-fung Let's make sure we fold this into #37039.
dotnet-policy-service commentedon Dec 23, 2025
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
dotnet-policy-service commentedon Jan 6, 2026
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.