From 09795ae75a14903091c7c3a9b4187bb47ceae951 Mon Sep 17 00:00:00 2001 From: Sergey Nesteruk Date: Mon, 1 Apr 2019 11:57:49 +0300 Subject: [PATCH 1/4] Updated gitignore --- .gitignore | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..71e2457 --- /dev/null +++ b/.gitignore @@ -0,0 +1,132 @@ +# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) +[Bb]in/ +[Oo]bj/ + +# mstest test results +TestResults + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates +*.sln.ide + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.log +*.vspscc +*.vssscc +.builds + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper* + +# Intellij Rider +.idea + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Xamarin.Android Resource.Designer.cs files (Auto-Generated) +**/*.Android.*/**/[Rr]esource.[Dd]esigner.cs + +# Click-Once directory +publish + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +packages + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +[Bb]in +[Oo]bj +sql +TestResults +[Tt]est[Rr]esult* +*.Cache +ClientBin +[Ss]tyle[Cc]op.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects +Thumbs.db + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + +*.userprefs +Components + +.DS_Store +.stversions +.stfolder + +*.orig +*.bak +.nuget/packages.config +/UpgradeLog.htm +/.vs +*.patch + +*.sublime-* \ No newline at end of file From 5b651a734be732b6a8a1d737c235b5d217a7203a Mon Sep 17 00:00:00 2001 From: Sergey Nesteruk Date: Mon, 1 Apr 2019 11:59:17 +0300 Subject: [PATCH 2/4] Removed unesseccary files from tracking --- .../Debug/Project.csprojAssemblyReference.cache | Bin 9303 -> 0 bytes .../Debug/Test.csprojAssemblyReference.cache | Bin 19854 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache delete mode 100644 AwaitExpception.Test/obj/Debug/Test.csprojAssemblyReference.cache diff --git a/AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache b/AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache deleted file mode 100644 index 85adb4bb8c9184b16e4762fdc49cae73a015ceec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9303 zcmeHL&2to05Z~GC?CzT&8w5WPtO|%&eogR zz#@of38)7==s^#9(1RYdEIoM8qn`8%XZ39PFKGYfBbi|bB`{T7_El}qyqTWf?*8@b zey1APBX4O^?Gbz+S&FJf$X_gGVe2BMZ%_UwRDHR5)L)GDGe}84Dpbcm;{%l+He-vAm z&1*$lvpKj}RX4aZ>)PtRA}tJqmu*tPQYSQP(bh@^ht{l%NDAaXSu@0-95%JexK_4J zk@4)wj+wQFCb;N<&@r>ZXN0+|SGdUHK~X=;Q)H2qp3{sbw-Sl2u7oUiXQTdW(wDU( zLg&dg`F|bRvp)^36zIlMATp62+~FpTx5x5_^^(v;D?c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BEiUdZQCdUd020K9fZ|~oXRz5g$2%B@d-7f5^sR9| zf=-LZ!Ec2^;%`V09~UiyvtgWpX5$QSFwSMj>KdnSjq?d~TJ%MiBs1~sDlO8GRnu7e z`4o@DXMo~im`Rw;6m&2Xe`N zvMw2Mf4$?9(bafhTQUl-vkAE7Py()V6mX+W0JpU|*5D>b0XG)~JUXpq?QyS$rg*t! z(NVzdjsmzB&8h=#Omh^#{bzO^aAS#80C$-<3fSx@fLjQx0=6AWzypo~9dtoUW`D`1nv+Ib>S1a{P3X+V8*n0~q%J From 29e22f02f41a8ba1373176725abe1260200ed896 Mon Sep 17 00:00:00 2001 From: Sergey Nesteruk Date: Mon, 1 Apr 2019 15:32:38 +0300 Subject: [PATCH 3/4] Added test case for running async void function --- AwaitException.Project/ExceptionThrower.cs | 9 ++++++ AwaitExpception.Test/Tests.cs | 36 +++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/AwaitException.Project/ExceptionThrower.cs b/AwaitException.Project/ExceptionThrower.cs index 5733a71..7824f3c 100644 --- a/AwaitException.Project/ExceptionThrower.cs +++ b/AwaitException.Project/ExceptionThrower.cs @@ -16,5 +16,14 @@ public async Task DelayAndThrow(int sleepForMilliseconds) throw new AwaitException(); } + + public async void VoidDelayAndThrow(int sleepForMilliseconds) + { + await Task.Delay(sleepForMilliseconds); + + awaitCompleted = true; + + throw new AwaitException(); + } } } \ No newline at end of file diff --git a/AwaitExpception.Test/Tests.cs b/AwaitExpception.Test/Tests.cs index 186e172..6f13d8e 100644 --- a/AwaitExpception.Test/Tests.cs +++ b/AwaitExpception.Test/Tests.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using NUnit.Framework; using Project; @@ -34,5 +35,38 @@ public async Task TestFreeFallExceptionThrow() // make sure we have waited long enough Assert.True(thrower.AwaitCompleted); } + + // This test fails the process with exception, not yet found a way to run it normally as a test. + // Comment that out if need to run other tests + [Test] + public async Task TestExceptionThrowInAsyncVoid() + { + var thrower = new ExceptionThrower(); + AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => + { + // Unfortunately I haven't yet found the way to not fail here. + // Looks like the exception is caught but the process fails despite of that fact + Console.WriteLine("The exception is actually caught globally"); + + // Make sure thrower finished async operation + Assert.True(thrower.AwaitCompleted, "Exception handled globally"); + }; + + // we throw the exception and not awaiting the method + try + { + thrower.VoidDelayAndThrow(5); + } + catch + { + Console.WriteLine("The exception is actually caught locally"); + + // wait for the test to finish + await Task.Delay(10); + + // make sure we have waited long enough + Assert.True(thrower.AwaitCompleted, "Exception handled locally"); + } + } } } \ No newline at end of file From 4f1fea02ac9b2cc07e26933965bb77caddd6bf33 Mon Sep 17 00:00:00 2001 From: Sergey Nesteruk Date: Fri, 5 Apr 2019 17:06:31 +0300 Subject: [PATCH 4/4] Fixed notes from code review. --- AwaitExpception.Test/Tests.cs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/AwaitExpception.Test/Tests.cs b/AwaitExpception.Test/Tests.cs index 6f13d8e..142fb15 100644 --- a/AwaitExpception.Test/Tests.cs +++ b/AwaitExpception.Test/Tests.cs @@ -39,7 +39,7 @@ public async Task TestFreeFallExceptionThrow() // This test fails the process with exception, not yet found a way to run it normally as a test. // Comment that out if need to run other tests [Test] - public async Task TestExceptionThrowInAsyncVoid() + public void TestExceptionThrowInAsyncVoid() { var thrower = new ExceptionThrower(); AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => @@ -51,22 +51,12 @@ public async Task TestExceptionThrowInAsyncVoid() // Make sure thrower finished async operation Assert.True(thrower.AwaitCompleted, "Exception handled globally"); }; - - // we throw the exception and not awaiting the method - try - { - thrower.VoidDelayAndThrow(5); - } - catch - { - Console.WriteLine("The exception is actually caught locally"); - - // wait for the test to finish - await Task.Delay(10); - - // make sure we have waited long enough - Assert.True(thrower.AwaitCompleted, "Exception handled locally"); - } + + // We try to assure exception is thrown here + Assert.Throws(() => thrower.VoidDelayAndThrow(5)); + + // Make sure the thrower worked correctly + Assert.True(thrower.AwaitCompleted, "Exception handled locally"); } } } \ No newline at end of file