Cannot compare Guid to Guid.Empty
Target name(s)
ESP32-S3
Firmware version
1.12.4.187
Was working before? On which version?
No response
Device capabilities
No response
Description
Cannot compare a Guid to Guid.Empty
None of the following work for various reasons. some are compile errors, some generate System.NullReferenceException: Exception was thrown: System.NullReferenceException
_CurrentTripGUID == Guid.Empty _CurrentTripGUID.Equals(Guid.Empty) _CurrentTripGUID.Equals((object)Guid.Empty _CurrentTripGUID.CompareTo((object)Guid.Empty) == 0
We desperately need a method to see if a Guid is == Guid.Empty
How to reproduce
Try any of these lines of code
private static Guid _CurrentTripGUID;
_CurrentTripGUID == Guid.Empty _CurrentTripGUID.Equals(Guid.Empty) _CurrentTripGUID.Equals((object)Guid.Empty _CurrentTripGUID.CompareTo((object)Guid.Empty) == 0
Expected behaviour
I would expect all of these lines to function:
_CurrentTripGUID == Guid.Empty _CurrentTripGUID.Equals(Guid.Empty) _CurrentTripGUID.CompareTo(Guid.Empty) = 0
Screenshots
No response
Aditional information
No response
A workaround for now: Convert both Guids to strings first and then compare the strings.
_CurrentTripGUID.ToString() == Guid.Empty.ToString()
But, if you need to compare 2 Guids and either one could be Empty ... it gets complicated. Since "G1.CompareTo(G2)" will generate a "Null reference error" if either Guid is Empty, you must compare them both using the ToString() equivalent of each Guid to the string equivalent to Guid.Emtpy first !!
Comparing two Guids, G1 & G2
if ((G1.ToString() == Guid.Empty.ToString()) || (G2.ToString() = Guid.Empty.ToString()) || (G1.CompareTo(g2) != 0))
Fully fixed in develop branches. Available in preview nuget and fw.