Skip to content

Host methods with void return type should return undefined #372

@KurtGokhan

Description

@KurtGokhan

If a host method has void return type, an object typed Microsoft.ClearScript.VoidResult will be returned when the method is called from script side. For example:

// C# side

public void MyMethod() { }

// Javascript side

var result = myClass.MyMethod();
var isUndefined = result === undefined; // false
var isNullish = result == null; // false

As discussed in issue #298, toFunction can be used or the function can be wrapped to basically customize this behavior. But I am questioning if there is any use case where returning VoidResult to script side is useful.

Maybe it can return undefined or Microsoft.ClearScript.Undefined (I don't know if those two would be the same thing). Or there could be a configuration for this like VoidExportValue, like how there is a configuration for UndefinedImportValue (which is a life-saver for me tbh).

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions