- Notifications
You must be signed in to change notification settings - Fork178
Closed
Description
Hi,
I am trying to using the CompilationDependencyResolver for my own script runner but the scripts don't compile due to it not knowing whatSystem.Object orSystem.Void is.
I naively tried:
Dotnet.Script.DependencyModel.Logging.LogFactorylogFactory=(t)=>(l,m,e)=>Log.WriteLine(m);dependencyResolver=newCompilationDependencyResolver(logFactory);//...usingvarfile=File.Open(scriptFileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);usingvarloader=newInteractiveAssemblyLoader();vardependencies=dependencyResolver.GetDependencies(path,new[]{scriptFileName},true,"netcoreapp3.1");varassemblyReferences=dependencies.SelectMany(d=>d.AssemblyPaths).ToArray();varscriptOptions=ScriptOptions.Default.WithFilePath(scriptFileName).WithMetadataResolver(newNuGetMetadataReferenceResolver(ScriptOptions.Default.MetadataResolver)).WithReferences(assemblyReferences)//.WithReferences(AssemblyReferences) - I was manually adding assemblies in the past.WithEmitDebugInformation(enableDebugging);varscript=CSharpScript.Create<SkiaPadScript>(file,scriptOptions,assemblyLoader:loader);ScriptState<SkiaPadScript>result=awaitscript.RunAsync();
My application targetsnetcoreapp3.1.
The script I am testing with is:
#! "netcoreapp3.1"#r"nuget: SkiaPad.Scripting,1.0.0"#r "nuget:Newtonsoft.Json,12.0.3"usingSystem;usingSkiaSharp;usingSkiaPad.Scripting;usingSkiaPad.Scripting.Mathematics;usingNewtonsoft.Json;varpaint=newSKPaint();paint.Color=SKColors.Purple;publicvoidStart(ScriptContextcontext,SKCanvascanvas,SKRectbounds){Console.WriteLine(JsonConvert.SerializeObject(paint));}publicvoidDraw(ScriptContextcontext,SKCanvascanvas,SKRectbounds){canvas.Clear(SKColors.Yellow);}publicvoidDispose(){}
Any help would be greatly appreciated.
Thanks,
Daniel
Metadata
Metadata
Assignees
Labels
No labels