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

Crash on Quick Actions menu call #132

Closed Cassandra-d closed 5 years ago

Cassandra-d commented 5 years ago

Prerequisites

Description

Call Quick actions menu Actual: exception. Expected: no exceptions.

Source Code

class Program
{
    static async Task Main(string[] args)
    {
        HttpResponseMessage resp;

        using (var client = new HttpClient())
        {
            using (var stringContent = new StringContent("data"))
            {
                resp = await client.PostAsync("Url", stringContent);
            }
        }
    }
}

Screenshot

dispose2

BADF00D commented 5 years ago

Thanks for reporting.

My stacktrace on the bug:


System.InvalidOperationException : Sequence contains no matching element
   at System.Linq.Enumerable.Last[TSource](IEnumerable`1 source,Func`2 predicate)
   at DisposableFixer.Extensions.BlockSyntaxExtension.TryFindLastStatementThatUsesVariableWithName(BlockSyntax block,String variableName,StatementSyntax& lastUsageStatement)
   at async DisposableFixer.CodeFix.DisposeLocalVariableAfterLastUsageCodeFixProvider.Apply(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.PreviewChangesSuggestedAction.CreateAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.GetPreviewChangesFlavor(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.CreateAllFlavors(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
Cassandra-d commented 5 years ago

@BADF00D Thanks for improving your awesome Disposable helper.

Is my stack trace important in reporting issues? It isn't mentioned in template for newly created issues so I wasn't sure is it helpful to add it to issue or will it only take space.

BADF00D commented 5 years ago

It was more a kind of note to myself. Within the test I often have to reimplement the api I'm writing test for ( In this case System.Net.Http). Therefor I use the stacktrace in order to check if the bug occures at the same location, after my hacking. But if you have a stacktrace, I'm always glad to get it.