SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
784 stars 226 forks source link

Fix S2931 FN: Support interop resources #2009

Open loic-joly-sonarsource opened 5 years ago

loic-joly-sonarsource commented 5 years ago

The RSPEC mentions native resources, such as IntPtr, UIntPtr, and HandleRef, but the implementation does not care about them (either before or after #2008).

Should the rule be extended to them (it's not always clear if native resources systematically need to be Disposed...)?

sebastien-marichal commented 4 months ago

When using HandleRef, it is a strong indicator of usage interop resources that should be disposed. This can also be the case for IntPtr and UIntPtr, but it might generate some FP based on how users are using it.