-
Notifications
You must be signed in to change notification settings - Fork 731
Description
Environment data
dotnet --info output:
.NET Command Line Tools (2.1.200)
Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1
_Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.200_
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
VS Code version:
1.23.1
d0182c3417d225529c6d5ad24b7572815d0de9ac
x64
C# Extension version:
1.15.2
Steps to reproduce
Rethrow an exception in a catch block wrapped in an if preprocessor directive.
catch (Exception ex)
{
#if DEBUG
throw ex;
#endif
//this line gives "Unreachable code detected" warning
Console.WriteLine($"An unhandeled exception has occured. {ex.Message}");
Console.ReadKey();
}
Expected behavior
I would think that no "Unreachable code detected" warning should be given in this case. But the compiler seems to give this error as well?
Actual behavior
Code after the rethrow will give an "Unreachable code detected" warning.