Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Disposed Exceptions #287

Open
wjdavis5 opened this issue Jun 16, 2020 · 0 comments
Open

Disposed Exceptions #287

wjdavis5 opened this issue Jun 16, 2020 · 0 comments

Comments

@wjdavis5
Copy link

Currently the clients implement IDisposable, which indicates to the user that they should be disposing of these objects after they have been used.

However doing so causes you to start receiving ObjectDisposedExceptions on further attempts to get a new client and then use it. Here is code to reproduce

static async Task Main(string[] args)
        {
            var creds = new VssBasicCredential("", "PAT");
            var conn = new VssConnection(new Uri("https://org.visualstudio.com"),creds);
            using (var git1 = await conn.GetClientAsync<GitHttpClient>())
            {
                var item = await git1.GetItemAsync("PROJECT", "REPO", "/File.json", null, null,
                    null, null, true, new GitVersionDescriptor() {Version = "master"}, true);
            }

            using (var git2 = await conn.GetClientAsync<GitHttpClient>())
            {
                var item = await git2.GetItemAsync("PROJECT", "REPO", "/File.json", null, null,
                    null, null, true, new GitVersionDescriptor() { Version = "master" }, true);
            }

        }

I see this mentioned in #266 - but to me this is either a bug or a design flaw.

Can you please clarify when these objects should be disposed?

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

No branches or pull requests

1 participant