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

How should we handle funcs? #154

Open
JohanLarsson opened this issue Jan 29, 2019 · 2 comments
Open

How should we handle funcs? #154

JohanLarsson opened this issue Jan 29, 2019 · 2 comments
Labels

Comments

@JohanLarsson
Copy link
Collaborator

public static void M(Func<Stream> factory)
{
    var stream = factory(); // As it is now IDISP001 warns here
}
public static void M(Func<IDisposable> factory)
{
    var stream = factory(); // Should this be handled differently?
}
@Maverik
Copy link

Maverik commented Feb 18, 2019

In my mind I'd expect to clean up the IDisposable I received from Func because the intent IMHO is to pass ownership to us of the final result and thus responsibility of cleanup.

@Bouke
Copy link
Contributor

Bouke commented Jun 30, 2022

Is this behaviour changed at some point? The example provided no longer generates IDISP001 for me with version 4.0.1. I have a constructor taking a factory dependency (e.g. Func<Stream>), and I would expect IDISP001 to be raised whenever I use that factory method without a using.

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

No branches or pull requests

3 participants