Skip to content

Transfer ownership (IDISP007) #213

@Bouke

Description

@Bouke

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions