VB -> C#: wrong result for empty char comparisation
VB.Net input code
Dim testChar As Char = Nothing
Dim testResult = testChar = ""
Assert.That(testResult, "comparing null character with empty string should be true")
Erroneous output
bool testResult = Conversions.ToString(testChar) == "";
Expected output
bool testResult = testChar == char.MinValue;
Details
- Product in use: VS extension
- Version in use: 9.0.0.0
- Did you see it working in a previous version, which? no
@KunzeAndreas are you sure that testResult should be true?
Running the input code on my machine results in testResult being False:
https://ideone.com/usf5f6
SharpLab.io shows that there is actually a call to Conversions.ToString generated by vb compiler.
Something like that is also converted correctly:
Dim testChar As Char = Nothing
Dim testResult = testChar = Microsoft.VisualBasic.ControlChars.NullChar
char testChar = default;
bool testResult = testChar == ControlChars.NullChar;
Am I missing something?
@Yozer Yes, I am sure. The test ist running in Visual Studio. Maybe there is a difference between .Net and mono?

in dotPeek I see this
private static void CharTest() { bool condition = Operators.CompareString(Conversions.ToString(char.MinValue), "", true) == 0; Debug.Print(condition.ToString()); NUnit.Framework.Assert.That(condition, "comparing null character with empty string should be true"); }
Thanks @KunzeAndreas, now I see what's happening and how to reproduce it. You need to set:
Option Compare Text
Which then will yield: bool flag = Operators.CompareString(Conversions.ToString(c), "", true) == 0;
and this returns True