From c4ffd7fadc8b56cdb91c180fbc308a4b50baacdd Mon Sep 17 00:00:00 2001 From: Semih Okur Date: Fri, 22 Jan 2021 11:19:48 -0800 Subject: [PATCH] Release v1.5.1 --- AsyncFixer.Test/UnnecessaryAsyncTests.cs | 50 +++++++++++++++++++ AsyncFixer.Vsix/source.extension.vsixmanifest | 2 +- AsyncFixer/AsyncFixer.csproj | 2 +- CHANGELOG.md | 3 ++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/AsyncFixer.Test/UnnecessaryAsyncTests.cs b/AsyncFixer.Test/UnnecessaryAsyncTests.cs index 8c6bc19..2b9a2cc 100644 --- a/AsyncFixer.Test/UnnecessaryAsyncTests.cs +++ b/AsyncFixer.Test/UnnecessaryAsyncTests.cs @@ -663,6 +663,56 @@ int streamOperation() VerifyCSharpDiagnostic(test); } + [Fact] + public void UsingStatementWithDataflow2() + { + var test = @" +using System; +using System.Threading.Tasks; + +class Program +{ + async Task foo() + { + using var stream = new MemoryStream(); + int streamOperation() + { + var stream2 = new MemoryStream(); + return stream2.Read(null); + } + + stream.Read(null); + var t = Task.Run(() => streamOperation()); + await t; + } +}"; + var expected = new DiagnosticResult { Id = DiagnosticIds.UnnecessaryAsync }; + VerifyCSharpDiagnostic(test, expected); + + var fixtest = @" +using System; +using System.Threading.Tasks; + +class Program +{ + Task foo() + { + using var stream = new MemoryStream(); + int streamOperation() + { + var stream2 = new MemoryStream(); + return stream2.Read(null); + } + + stream.Read(null); + var t = Task.Run(() => streamOperation()); + return t; + } +}"; + + VerifyCSharpFix(test, fixtest); + } + [Fact(Skip = "TODO: fix the dataflow analysis to analyze all locations of the symbol, not only the definitions")] public void NoWarn_UsingStatementWithDataflowComplicated() { diff --git a/AsyncFixer.Vsix/source.extension.vsixmanifest b/AsyncFixer.Vsix/source.extension.vsixmanifest index 8575ba4..1b46596 100755 --- a/AsyncFixer.Vsix/source.extension.vsixmanifest +++ b/AsyncFixer.Vsix/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + AsyncFixer for Visual Studio 2019 Advanced async/await Diagnostics and CodeFixes for C#. http://www.asyncfixer.com diff --git a/AsyncFixer/AsyncFixer.csproj b/AsyncFixer/AsyncFixer.csproj index c9b7b20..9ab7439 100755 --- a/AsyncFixer/AsyncFixer.csproj +++ b/AsyncFixer/AsyncFixer.csproj @@ -9,7 +9,7 @@ AsyncFixer - 1.5.0 + 1.5.1 Semih Okur AsyncFixer: Advanced async/await Diagnostics and CodeFixes for C# diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f217b9..cf0a6ff 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release History +## 1.5.1 (2021-01) +- 01.UnnecessaryAsync: Implemented a dataflow analysis for disposable objects to fix false-negatives and false-positives + ## 1.5.0 (2021-01) - 01.UnnecessaryAsync: Fix false-negatives to cover more cases - 02.BlockingCallInsideAsync: Stop suggesting async calls for virtual calls and Dispose methods