Switch over type throws null ref exception #16293
Labels
Area-Compilers
Bug
New Language Feature - Pattern Matching
Pattern Matching
Resolution-Duplicate
The described behavior is tracked in another issue
Milestone
Reporting the unexpected behavior seen in this question: http://stackoverflow.com/questions/41504414/c-sharp-7-pattern-matching-semantics
Version Used:
Microsoft Visual Studio Professional 2017 RC
Version 15.0.26014.0 D15REL
Microsoft .NET Framework
Version 4.6.01038
Installed Version: Professional
Visual C# 2017 RC 00369-50000-00000-AA365
Microsoft Visual C# 2017 RC
Steps to Reproduce:
I have this block of code:
https://github.com/AsynkronIT/protoactor-dotnet/blob/master/src/Proto.Remoting/EndpointManager.cs#L21
Which works as expected.
This block however, https://github.com/AsynkronIT/protoactor-dotnet/blob/master/src/Proto.Remoting/EndpointManager.cs#L45
Throws Null reference exception.
I have narrowed it down to the
case MessageEnvelope env:
line.Replacing that with:
Fixes the issue.
Expected Behavior:
I would expect the above to work just like the original if based code.
Actual Behavior:
Null reference exception on the
case MessageEnvelope env:
line.Or rather it throws null reference exception directly on the
switch(context.Message)
before I am able to step into any of the case blocks. but the above mentioned fix removes the issue.The text was updated successfully, but these errors were encountered: