Describe the bug in detail:
Prepare two U# class. Let the one has a string variable with null value.
When the another class access the variable the value becomes empty string.
Provide steps/code to reproduce the bug:
Referenced class:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class OtherClassNullStringBecomesEmpty_Sub : UdonSharpBehaviour
{
public string foo;
void Start()
{
foo = null;
}
void Interact()
{
string s = foo;
Debug.Log("Sub: eqNull=" + (s == null) + " isEmpty=" + string.Empty.Equals(s));
}
}
Refering class:
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class OtherClassNullStringBecomesEmpty : UdonSharpBehaviour
{
public OtherClassNullStringBecomesEmpty_Sub other;
void Interact()
{
string s = other.foo;
Debug.Log("Main: eqNull=" + (s == null) + " isEmpty=" + string.Empty.Equals(s));
object o = other.foo;
Debug.Log(" obj: eqNull=" + (o == null) + " isEmpty=" + string.Empty.Equals(o));
}
}
Describe the bug in detail: Prepare two U# class. Let the one has a string variable with null value. When the another class access the variable the value becomes empty string.
Provide steps/code to reproduce the bug: Referenced class:
Refering class:
Expected behavior: Actual result:
I expected: eqNull=True isEmpty=False at least "object o" case.
For comparing, the result of accessing from declaring class:
It is surely that the variable value is null in referenced class.
Additional Information: Generated assembly of accessing part:
It uses
Convert.ToString(Object)
. The API reference of that: https://docs.microsoft.com/en-us/dotnet/api/system.convert.tostring?view=netframework-4.0#System_Convert_ToString_System_Object_The document says the return value is
So, the issue happens.