Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to run a script using CompilationDependencyResolver? #515

Closed
@dfkeenan

Description

@dfkeenan

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp