Skip to content

Test projects for C# to know how the language works for different non-obvious cases.

Notifications You must be signed in to change notification settings

SergeyNesteruk/csharp_experiments

 
 

Repository files navigation

CSharp Experiments

While working with C# recently without having a decent experience in it, I am sometimes wondering how one or another case is working in the language.

Without having the ability to alter any production project just for the sake of science, I created this project for experimenting. Feel free to contribute or fix any issues you find valuable.

Experiment 1. Throw an exception in a non-awaited method.

You can find the experiment details in AwaitException.Project and AwaitException.Test.

Turns out if just run an async method without await and an exception occurs in the method - it gets lost in the void.

Experiment 2. Throw an exception and then rethrow it.

The question is: how the stack trace is affected if we throw an exception, catch it for logging and then rethrow.

The answer:

  1. If the exception is rethrown explicitly via throw exception; the stack trace is erased.
  2. If the exception is rethrown via throw; the stacktrace is preserved.

About

Test projects for C# to know how the language works for different non-obvious cases.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%