I stumble upon a strange behaviour when calling c# functions from a x# project:
I have a c# function having an optional string parameter with a default value:
Code: Select all
public static void DefaultParameterTest(string defautvalue = "default")
{
Console.WriteLine($"DefaultParameterTest: {defautvalue}");
}
If I call this function from x# without a parameter, all good it prints the default string value
Now if I call the function with a null variable, when debugged on the c# side, a empty string is provided !
To be noted, I'm not using the "initialize string" compilation otion (/vo2)
Also having the same behaviour when using a USUAL parameter, directly passing null !
Code: Select all
LOCAL nullString := NULL AS STRING
LOCAL nullUsual := NULL AS USUAL
DefaultParmeterValue.Class1.DefaultParameterTest("this is expected")
DefaultParmeterValue.Class1.DefaultParameterTest()
DefaultParmeterValue.Class1.DefaultParameterTest(nullString)
DefaultParmeterValue.Class1.DefaultParameterTest(nullUsual)
DefaultParmeterValue.Class1.DefaultParameterTest(NULL)
==>
DefaultParameterTest: this is expected
DefaultParameterTest: default
DefaultParameterTest:
DefaultParameterTest:
DefaultParameterTest: