Introduction to Scriptcs


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Introduction to Scriptcs

  1. 1.
  2. 2.
  3. 3. scriptcs.netWho is scriptcs? Community (!) Coordinators Glenn Block (@glennblock) Justin Rusbatch (@jrusbatch) Filip Wojcieszyn (@filip_woj) Core Commiters Damian Schenkelman (@dschenkelman) Kristian Hellang (@khellang)
  4. 4. scriptcs.netMetrics 525 watchers 110 forks 142 pull requests 29 unique contributors 14 community contributed script packs (extensions) Currently at v0.5
  5. 5. scriptcs.netKhalid AbuhakmehIan Battersby Nick Berardi Glenn Block Scott Blomquist Danielle Boldt Tim EricksonJonas Follesø Victor Grigoriu Andreas Håkansson Kristian Hellang lbargaoanu Denis Mentey JohnNelson Alexander Nyquist David Pendray Aaron Powell Adam Ralph Justin Rusbatch DamianSchenkleman Paul Shmakov Lodewijk Sioen Brandon Stirnaman Paul Stovell Patrik Svensson KevinTrethewey Michael Wade Filip Wojcieszyn Matt WrockContributors
  6. 6. scriptcs.netWhat is scriptcs? OSS project enabling rich C# scripting experience Script and execute -or- use REPL Robust extensibility model Low ceremony, lightweight Use your favorite text editor No compilation/projects/solutions Built on top of Nuget & Roslyn (no hard dependencies)
  7. 7.
  8. 8. scriptcs.netScriptcs overviewscriptcsScript EnginePackageManagementScript Packs
  9. 9. scriptcs.netKey scriptcs features Relaxed C# syntax & code semantics As defined in “Interactive C#/VB REPL and Script - CodeSemantics Spec“ white paper REPL Node.js-like extensibility model (script packs) Debug & step through in Visual Studio Sublime text plugin Scriptcs.Core available as a hostable service Nuget integration
  10. 10. scriptcs.netScriptcs modelRoslyn / Mono.Csharp*NugetOSS libraries MEF
  11. 11. scriptcs.netOSS libraries used by scriptcs Autofac (dependency injection) Common Logging, log4net (logging) LiteGuard (argument checks) Nuget Core (package installation as a service) PowerArgs (command line parsing) ServiceStack.Text (serialization) Moq, xunit, Should (testing)
  12. 12. scriptcs.netGetting started with scriptGetpackages*• Scriptcs -installWritecode• Any editorExecute • CLI or hosted
  13. 13. scriptcs.netDemo: Getting started with script
  14. 14. scriptcs.netDemo: #load & #r
  15. 15. scriptcs.netGetting started with REPLGetpackages*• Scriptcs -installRunscriptcsWritecodeEvaluate
  16. 16. scriptcs.netDemo: Getting started - REPL
  17. 17.
  18. 18. scriptcs.netScript code semantics No top level class No arbitrary namespaces No Main method Global functions allowed Script packs accessible through Require<T> #load directive to load script from script #r directive to reference an assembly from script
  19. 19.
  20. 20. scriptcs.netTypical C# experience Start Visual Studio (...wait...) Choose VS project template Create new solution Add references, install Nuget packages, importnamespaces Compile Run (repeat: compile+run) Difficult to distribute source code (bloated)
  21. 21.
  22. 22. scriptcs.netTypical scriptcs experience Install Nuget packages with “scriptcs –install” Write code in any text editor Run (repeat: edit & run) Easy to distribute code (just CSX + packages.config)
  23. 23. scriptcs.netSelf hosted server – traditional C#
  24. 24. scriptcs.netSelf hosted server – scriptcs / node.js
  25. 25. scriptcs.netDemo: Nancy
  26. 26. scriptcs.netRole of script packsImport referencesImport namespacesExpose functionality
  27. 27. scriptcs.netScript pack example: NUnit References nunit.core.dll, nunit.core.interfaces.dll, nunit.framework.dll Namespaces Nunit.Framework, System.Reflection Functionality public TestResult RunAllUnitTests(Assembly testAssembly =null) public TestResult RunAllUnitTests(Action<string> callback,Assembly testAssembly = null)
  28. 28. scriptcs.netscriptcs Nuget integration Developed to work around nuget.exe limitations scriptcs –install Gets all packages from packages.config with dependencies scriptcs –install <package name> Gets specific package with dependencies scriptcs –save Creates packages.config based on packages folder scriptcs –clean Gets rid of packages folder and unnecessary binaries
  29. 29. scriptcs.netDemo: RavenDB
  30. 30. scriptcs.netDemo: P/Invoke
  31. 31. scriptcs.netDemo: WPF
  32. 32. scriptcs.netGet scriptcs CLI distributed via Chocolatey cinst scriptcs Libs available on Nuget Nightly builds on MyGet Build from source
  33. 33. scriptcs.netWhat’s next? Pluggable CLI commands Pluggable REPL commands Export to Visual Studio solution Mono support Script packs as scripts ScriptCatalog – extend applications (MEF) with scriptcs Improved ScriptCs.Core API
  34. 34.