Pass undefined to .Net object property/metod

using System;
using System.Collections.Generic;
using System.Text;

namespace ToRemObjects
{
public class RemObjectsConsole
{
public RemObjectsConsole()
{ }

    public object propObject
    {
        get { return 1.2D; }
        set { Console.WriteLine("propObject:{0}", value); }
    }

    public void writeObject(object value)
    {
        Console.WriteLine("writeObject:{0}", value);
    }
}

class Program
{
    static void Main(string[] args)
    {
        using (var esc = new RemObjects.Script.EcmaScriptComponent())
        {
            esc.Include("test1", @"

function testPropObject(cc) {
cc.propObject = undefined;// result to null
cc.writeObject(undefined);// result to null
cc.writeObject();// result to null
}
");

            RemObjectsConsole cc = new RemObjectsConsole();
            var o = esc.RunFunction("testPropObject", cc);
            Console.ReadLine();
        }
    }

}

}

Hello

Both undefined and null are passed to .NET as null (because there is no native .NET representation for null)

Yes, I understand that, but this will allow you to understand how is called method,
when you have string as type of parameter you pass null but this can’t be mark for parameter less call,
When I have general type as object I always need to check what I receive from script engine, I can receive anything from it (EcmaScriptObject, EcmaScriptArrayObject and etc)

There’s a class called “indefined” with an instance property, that’s the value of “undefined” in the engine.

Yes, I now it, test it against version 2.0.65.1067 and you can see
how method writeObject receive instance of RemObjects.Script.EcmaScript.Undefined,
but now that functionality is missing

ah got it. Fixed in https://github.com/remobjects/script/commit/0b53848514135f91fd6d5e2aad3a56d46b005dae.

Thanks

I too quickly posted

You check in this (but this code will break other cases like convert to double, string and etc.)

if (value = Undefined.Instance) and (&type = typeof(Object)) then

May be it need to be
if (value = Undefined.Instance) then
begin
if (&type = typeOf(Object)) then
exit Undefined.Instance
else
exit nil
end;

I saw how methods are called can I propose some which will allow default value for method parameters, I will attach file Wrappers.zip

Wrappers.zip

I’ll apply your change, they look good (Btw Oxygene does not reevaluate the Count each iteration, I’ll remove that stuff)

Ok, Thanks