You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This check fails, even when the call status is 'completed':varincomingCall= CallResource.Fetch(call.CallSid);if(incomingCall.Status == CallResource.StatusEnum.Completed)){// call is completed}// This works:varincomingCall= CallResource.Fetch(call.CallSid);if(incomingCall.Status.Equals(CallResource.StatusEnum.Completed)){// call is completed}
Explanation
One would expect this to work if normal C# enum types were used (value types), the so-called "enums" in this library are actually classes, and thus "==" does a reference comparison. Fetch is creating the .Status value on its result in a way that does not reference the same instance of Status.Enum.Completed exposed by the library; so the camparison fails. While I would prefer to see actual C# enum types used rather than these custom classes, this problematic issue can be worked around by adding '==' and '!=' operators to the StringEnum class. C# developers expect something named 'enum' to be a value type, and this could cause problems in production code (which is how I found the problem).
I have made the appropriate modification, with associated test, if someone is willing to accept a pull request (or I can paste in the code here if you'd prefer).
The text was updated successfully, but these errors were encountered:
Version: 5.5.1
Code Snippet
Explanation
One would expect this to work if normal C# enum types were used (value types), the so-called "enums" in this library are actually classes, and thus "==" does a reference comparison. Fetch is creating the .Status value on its result in a way that does not reference the same instance of Status.Enum.Completed exposed by the library; so the camparison fails. While I would prefer to see actual C# enum types used rather than these custom classes, this problematic issue can be worked around by adding '==' and '!=' operators to the StringEnum class. C# developers expect something named 'enum' to be a value type, and this could cause problems in production code (which is how I found the problem).
I have made the appropriate modification, with associated test, if someone is willing to accept a pull request (or I can paste in the code here if you'd prefer).
The text was updated successfully, but these errors were encountered: