scriptcs hosting - Advantages over Roslyn -


if want support scripting in application, scriptcs offer particular advantages on using plain vanilla roslyn script engine?

unfortunately there's not documentation on hosting scriptcs yet, i'll try give short summary.

hosting scriptcs in application provides several features vanilla roslyn doesn't:

pluggable engines

while scriptcs comes roslyn , mono engines default, can replace engine, i.e. f#, lolcode or brainfuck.

pre-processing

scriptcs process scripts , extract things references (#r) , load other scripts (#load). there introduced custom ilineprocessors lets hook pipeline custom processing. example processor this:

public class gistlineprocessor : directivelineprocessor {     protected string directivename     {         return "gist";     }      protected override bool processline(ifileparser parser, fileparsercontext context, string line)     {         var gistid = getdirectiveargument(line);          var gistcontents = downloadgistcontents(gistid);          parser.parsescript(gistcontents, context);          return true;     }      private static string downloadgistcontents(string gistid)     {         // download gist contents...     } } 

this processor download gist , execute part of script, i.e. #gist 12345678.

nuget integration

scriptcs has integration nuget. means if want scripts able use nuget packages, install them , automatically loaded within packages folder.

script packs

script packs scriptcs' way remove boilerplate code. can import namespaces, reference assemblies , expose functionality scripts through require<t>(). see martin doms' excellent blog post building scriptcs script pack. comprehensive list of available script packs, see script packs master list.

repl

as know, scriptcs has repl. can reused in own application provide interactive scripting session.

debugging

using vanilla roslyn script engine, can't debug scripts easily. scriptcs gives ability debug scripts source mapping through #line directives inserted during pre-processing.


i may have forgotten something, these main points choosing scriptcs on vanilla roslyn. when comes actual hosting, have 2 options:

scriptcs.core

this super lightweight library contains core components of scriptcs pipeline. however, doesn't contain implementations iscriptengine (the engine executes code) , iinstallationprovider (the component installs packages, i.e. nuget), these live in scriptcs.hosting , scriptcs.engine.roslyn. if use library, have wire-up of components , need provide implementation engine , package installer.

scriptcs.hosting

scriptcs.hosting convenience layer hosting scriptcs in application. it's used internally in scriptcs.exe , wire-up of components (via autofac) you. contains nuget implementation package installer , has dependency on scriptcs.engine.roslyn default. preferred way host scriptcs provides scriptservicesbuilder replace scriptcs' internal services. see scriptcs' program.cs example usage.

this sound confusing if have questions, please ask on jabbr, github or on google group.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -