I've been working with the RoslynCodeEditor control and attempting to find a way to pass my globals object to the RoslynCodeEditor and have intellisense within my scripts.
Does anyone know how I can grant access to the context object properties or methods when editing my script using RoslynCodeEditor control?
MyContext context = new MyContext();
context.Data = data;
ScriptOptions scriptOptions = ScriptOptions.Default;
scriptOptions = scriptOptions.WithReferences(ReferencesAndImports.References);
scriptOptions = scriptOptions.WithImports(ReferencesAndImports.Imports);
var scriptState = await CSharpScript.EvaluateAsync<string>("int i = 0;", scriptOptions, context, typeof(MyContext));
You need to add the globals type to the design-time compilation. To do that, you'll need a custom
RoslynHost
(supported in version 2.4 and up):Then add a reference to the assembly the type resides in. For example: