Skip to content
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

Transfer ownership (IDISP007) #213

Open
Bouke opened this issue Apr 8, 2020 · 1 comment
Open

Transfer ownership (IDISP007) #213

Bouke opened this issue Apr 8, 2020 · 1 comment

Comments

@Bouke
Copy link
Contributor

Bouke commented Apr 8, 2020

Let's say I want to transfer ownership of an IDisposable to another class by injecting the instance. This raises IDISP007 warning (don't dispose injected). However in some designs it makes sense to transfer ownership. For example the design of ZipArchive(Stream, ZipArchiveMode, Boolean, Encoding), which takes a stream and will (optionally) take ownership over that stream.

Now I could sprinkle my code with [SuppressMessage], but that feels like a workaround. Is there a good way to communicate the transferring of ownership?

@jeremyVignelles
Copy link

Hi,

In my opinion, this is something that should be provided by .net core itself, so I did a proposal here, but did not get any reply yet:
dotnet/runtime#29631

In the absence of reply of the dotnet folks, we will be forced to implement our own in this project
Please join the discussion here:
#130

or on gitter:
https://gitter.im/DotNetAnalyzers/IDisposableAnalyzers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants