I am building a c# scripting window in my app. It will be used to write small scripts that will operate on a predefined set of global variables. I want to add a couple of namespaces so that the user does not have to write full class names. I used this code:
CsParser csParser = new CsParser();
documentTextSource.Lexer = csParser;
But I don’t see any effect… am I doing sth wrong? what should I do to achieve what I want?
RegisterNamespaces only works for Visual Basic, in a similar way to Imported Namespaces in the Visual Basic Project Options- >References in Visual Studio - this allows to skip listing all imports in the Visual Basic code.
Similar feature has not been implemented for C#, so RegisterNamespaces for C# does not do anything really.
if you need to skip listing some using in the code but still be able to use types from these namespaces, you would need to use approach demonstrated in the Snippets Parser quick start project, where code displayed in the editor is a sub-set of code which is sent to the Roslyn parser for code analysis.
Hope this helps,