public async Task ComputeRefactoringAsync(RefactoringContext context, StatementListSelection selectedStatements) { SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo(selectedStatements.FirstOrDefault() as LocalDeclarationStatementSyntax); if (!localInfo.Success) { return; } ExpressionSyntax value = localInfo.Value; if (value == null) { return; } if (value.Kind() == SyntaxKind.DefaultExpression) { return; } if (value is LiteralExpressionSyntax) { return; } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); var typeSymbol = semanticModel.GetTypeSymbol(localInfo.Type, context.CancellationToken) as INamedTypeSymbol; if (typeSymbol?.Implements(SpecialType.System_IDisposable, allInterfaces: true) != true) { return; } context.RegisterRefactoring( $"Using '{localInfo.IdentifierText}'", cancellationToken => RefactorAsync(context.Document, selectedStatements, cancellationToken)); }