Title: Proposal: Safe pointers by lostmsu · Pull Request #1043 · pythonnet/pythonnet · GitHub
Open Graph Title: Proposal: Safe pointers by lostmsu · Pull Request #1043 · pythonnet/pythonnet
X Title: Proposal: Safe pointers by lostmsu · Pull Request #1043 · pythonnet/pythonnet
Description: What does this implement/fix? Explain your changes. With C# 7.3 ref structs and C# 8.0 using working on any method named Dispose it is possible to track new vs borrowed references at compile time. This proposal introduces BorrowedReference and NewReference types, that are ref-only structs, meaning you can't put them into PyObject directly, so they can implement different ToPyObject methods, one doing IncRef, and the other one not (alternatively, we can have PyObject constructor overloads). Along with Roslyn-based NonCopyableAnalyzer and FxCop after dotnet/roslyn-analyzers#3305 is fixed, this can ensure, that we do reference counting correctly at compile time. We can gradually change return and parameter types in PInvoke methods in Runtime to one of BorrowedReference or NewReference to take advantage of this. Downsides Build system must support C# 8.0, which is currently not supported in all build configurations. Without C# 8.0 one would have to dispose NewReference instances with try ... finally ... block.
Open Graph Description: What does this implement/fix? Explain your changes. With C# 7.3 ref structs and C# 8.0 using working on any method named Dispose it is possible to track new vs borrowed references at compile time. ...
X Description: What does this implement/fix? Explain your changes. With C# 7.3 ref structs and C# 8.0 using working on any method named Dispose it is possible to track new vs borrowed references at compile time. ...
Opengraph URL: https://github.com/pythonnet/pythonnet/pull/1043
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:52922c4e-2c59-783f-eb3e-f243ce67d521 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 9568:14965D:287931C:3807D28:69729CE8 |
| html-safe-nonce | 70edbb6c27988d057812592b1ca3f66d74d86416026b95b06d58ce75b6e15009 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTY4OjE0OTY1RDoyODc5MzFDOjM4MDdEMjg6Njk3MjlDRTgiLCJ2aXNpdG9yX2lkIjoiODc0NDg2MjQ3Nzk3Njc3MTgxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3ac663e5ec8d9168f20c0e0c8a40e4c45b60db9887e1cec4d7771f9c7b443a65 |
| hovercard-subject-tag | pull_request:375142976 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/pythonnet/pythonnet/pull/1043/checks |
| twitter:image | https://avatars.githubusercontent.com/u/239520?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/239520?s=400&v=4 |
| og:image:alt | What does this implement/fix? Explain your changes. With C# 7.3 ref structs and C# 8.0 using working on any method named Dispose it is possible to track new vs borrowed references at compile time. ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72bb1c46bb1ebdc0dc83a0a57b64c3b4d668c125d1125d94898213a4c9db8da2 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e746f1a3ddb5c0a91290ff3d5889b5247e0e519e |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width