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 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/AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache b/AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache deleted file mode 100644 index 85adb4b..0000000 Binary files a/AwaitException.Project/obj/Debug/Project.csprojAssemblyReference.cache and /dev/null differ diff --git a/AwaitExpception.Test/Tests.cs b/AwaitExpception.Test/Tests.cs index 186e172..142fb15 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,28 @@ 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 void 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 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 diff --git a/AwaitExpception.Test/obj/Debug/Test.csprojAssemblyReference.cache b/AwaitExpception.Test/obj/Debug/Test.csprojAssemblyReference.cache deleted file mode 100644 index 8d4c680..0000000 Binary files a/AwaitExpception.Test/obj/Debug/Test.csprojAssemblyReference.cache and /dev/null differ