CODE COMPLETION (INTELLISENSE) FROM CUSTOM CLASSES

I have a question about getting Intellisense from custom classes added to the debugger. I have just started to evaluate this product - I would be usig VB.Net for the scripting language. I used the main demo project, and added a very simple test class, and made a few changes to make the scripting language VB.Net. My test class "keyword" shows up in teh code editor, but not any of the methods within the class.

The simple test class is:

public class clsTest
{

public static int AddTwoNumbers(int number1, int number2)
{
return number1 + number2;
}

}


This is "attached" to the script editor with this code.

clsTest MyTest = new clsTest();

ScriptGlobalItem item = new ScriptGlobalItem("Test", typeof(clsTest), MyTest);
scriptRun.GlobalItems.Clear();
scriptRun.GlobalItems.Add(item);
RegisterScriptCodeForEditor();

where:

private void RegisterScriptCodeForEditor()
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
foreach (var item in scriptRun.GlobalItems)
{
builder.AppendLine(string.Format(ScriptConsts.VisualBasicGlobalField, item.Name, item.Type.FullName));
}

string code = string.Format(ScriptConsts.VisualBasicGlobalCode, builder.ToString());

foreach (TabPage tabPage in tcEditors.TabPages)
{
var edit = editors[tabPage] as IScriptEdit;
if (edit != null)
edit.RegisterCode("global.cs", code);
}

}


In the script editor, I see the "Test." object in the Intellisense dropdown. Hoever I do not see the "AddTwoNumbers" function

The VB script I am testing is shown below. The script works OK - I get the correct answer from the AddTwoNUmbers" functions, but want to know how to get tmy custom functions in the dropdown listbox.

Imports Microsoft.VisualBasic

Class clsScript

Public shared Sub main

Dim IntResult As Integer

IntResult = Test.AddTwoNumbers(3,4)

Debug.Print("The result is: " & intresult)
MsgBox(IntResult.ToString, MsgBoxStyle.OkOnly, "Title")


End Sub

End Class

Do I need code in a CodeCompletion event for the editor, or should my methods show up automatically in the dropdown list?
Hi Kevin,
For code editor code completion you either need to register assembly that contains a class with all the methods, or just a source code of the file you'd like to include for code completion.
So instead of registering VisualBasicGlobalCode, which only contains definitions of global objects passed to the script, you can pass the code itself to RegisterCode:

string code = @"public class clsTest
{
public static int AddTwoNumbers(int number1, int number2)
{
return number1 + number2;
}
}";
edit.RegisterCode("global.cs", code);
Then clsTest. will show AddTwoNumbers method.
regards,
Andrew