BADF00D / DisposableFixer

This is a Visual Studio Extension and NuGet package that should identify and fix problems as memleaks while using IDisposables.
Other
35 stars 7 forks source link

disposable on awaited object #37

Closed mhamri closed 7 years ago

mhamri commented 7 years ago

Hi, thanks for the amazing extension. i noticed the awaited items is getting a hint about not correctly disposed.

using (var client = new HttpClient())
{       
    using (var httpRequest= new HttpRequestMessage())
    {
        httpRequest.Method = HttpMethod.Get;
        httpRequest.RequestUri = url;

        var headers = GetHeaders();

        foreach (var header in headers)
        {
            httpRequest.Headers.Add(header.Key, header.Value);
        }
        using (var response = await client.SendAsync(httpRequest)) // this line has error:Method return is an anonymous object that is not disposed
        {
            if (response.IsSuccessStatusCode)
            {
                return true;
            }
        }
    }
}
BADF00D commented 7 years ago

Since the responce is wrapped in an using, this looks like an error in the extension. I will have a look on it.

Thanks for reporting the error.

BADF00D commented 7 years ago

Note: Bug #36 is a using detection error two, maybe they are connected.