CS: Fix representation of Infinity and NaN

This commit is contained in:
Katy Coe
2020-06-20 21:26:29 +02:00
parent e0fe7fa1b9
commit 9c51e72cc2

View File

@@ -88,7 +88,19 @@ namespace Il2CppInspector.Reflection
if (value is bool) if (value is bool)
return (bool) value ? "true" : "false"; return (bool) value ? "true" : "false";
if (value is float) if (value is float)
return value + "f"; return value switch {
float.PositiveInfinity => "1F / 0F",
float.NegativeInfinity => "-1F / 0F",
float.NaN => "0F / 0F",
_ => value + "f"
};
if (value is double)
return value switch {
double.PositiveInfinity => "1D / 0D",
double.NegativeInfinity => "-1D / 0D",
double.NaN => "0D / 0D",
_ => value.ToString()
};
if (value is string str) { if (value is string str) {
return $"\"{str.ToEscapedString()}\""; return $"\"{str.ToEscapedString()}\"";
} }