vl-acad-defun and vl-acad-undefun together with .NET no longer work correctly since BricsCAD V23

I created a Visual Studio project (BricsCadTemplate.zip) with which you can easily reproduce the error and a video showing the issue (2023-02-10-09-47-44.mp4). You can start the project from any location. For this you need Visual Studio and a German or English installation of BricsCAD V21, V22 or V23.
In my example, the "TEST_INVOKE_LISP" command runs correctly only once under V23. Each time after that, the "get_a_string_from_lisp" function is no longer visible to .NET, which is why calling "get_a_string_from_lisp" from .NET returns a null. However, this only happens on BricsCAD V23. This does not happen under V22 and V21. There "vl-acad-undefun" works correctly. It seems that on V23 "vl-acad-undefun" makes the function name "get_a_string_from_lisp" unusable during a session. From there (vl-acad-defun "get_a_string_from_lisp") runs into nothing.

This is the code of the project:

Lisp part:
(defun c:test_invoke_lisp ( / get_a_string_from_lisp)
;;
(defun get_a_string_from_lisp ( / )
"Hello World!"
)
;;
(vl-acad-defun "get_a_string_from_lisp")
(princ (Net:RetrieveSomeText))
(vl-acad-undefun "get_a_string_from_lisp")
(princ)
)

C# part:
[LispFunction("Net:RetrieveSomeText")]
public static object RetrieveSomeText(ResultBuffer resBuf)
{
var pars = new ResultBuffer(new[] { new TypedValue((int)LispDataType.Text, "get_a_string_from_lisp") });
var result = Bricscad.Global.Editor.Invoke(pars);

return result?.AsArray() is TypedValue[] args
&& args.Length > 0
&& args[0] is TypedValue arg
&& arg.TypeCode == (short)LispDataType.Text
&& arg.Value is string textFromLisp
? new TypedValue((int)LispDataType.Text, "Text from invoke Lisp: " + textFromLisp + "\n")
: new TypedValue((int)LispDataType.Text, "No result from invoke Lisp.\n");
}

Comments