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

Better heuristics for if a disposable is created #96

Closed
JohanLarsson opened this issue Aug 17, 2018 · 2 comments
Closed

Better heuristics for if a disposable is created #96

JohanLarsson opened this issue Aug 17, 2018 · 2 comments

Comments

@JohanLarsson
Copy link
Collaborator

For binary references where we can't walk the source we need to make a best guess about if a method returns a new instance that we now own and should dispose.

public static class Extensions
{
    /// <summary>
    /// Test method that returns a different type than the in parameter. We assume that the method creates a new disposable then.
    /// </summary>
    public static ICustomDisposable AsCustom(this IDisposable disposable) => default(ICustomDisposable);

    /// <summary>
    /// Test method that returns the same type as the in parameter. We assume that the method does not create a new disposable then.
    /// </summary>
    public static IDisposable Fluent(this IDisposable disposable) => disposable;
}
@JohanLarsson
Copy link
Collaborator Author

There are more cases we should list.

@JohanLarsson
Copy link
Collaborator Author

#126

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

1 participant