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

IDISP004 should warn when using property returning created #163

Open
JohanLarsson opened this issue Feb 20, 2019 · 3 comments
Open

IDISP004 should warn when using property returning created #163

JohanLarsson opened this issue Feb 20, 2019 · 3 comments

Comments

@JohanLarsson
Copy link
Collaborator

    public static class C
    {
        public static Stream Stream => File.OpenRead(string.Empty);

        public static long? M() =>Stream?.Length;
    }
@JohanLarsson JohanLarsson changed the title IDIsp004 should warn here IDISP004 should warn here Feb 20, 2019
@jeremyVignelles
Copy link

Not sure that's a correct example. When you have a property, the classic expectation is that the getter doesn't create anything, it only "gets" the value.

@JohanLarsson JohanLarsson changed the title IDISP004 should warn here IDISP004 should warn when using property returning created Mar 23, 2020
@JohanLarsson
Copy link
Collaborator Author

In the example above the getter returns a created disposable that is then not disposed in the method.
Agreed a property returning an instance that the caller is supposed to dispose is nasty.

@jeremyVignelles
Copy link

Yes, but it's doable with the IDisposable annotations ;)

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