advertisement

C# Scripting with Microsoft's Project Roslyn

57 %
43 %
advertisement
Information about C# Scripting with Microsoft's Project Roslyn
Technology

Published on February 28, 2014

Author: rstropek

Source: slideshare.net

Description

At BASTA Spring 2014 conference I did a talk about C# Scripting with Microsoft's Project Roslyn. See my blog at http://www.software-architects.com for details.
advertisement

C# Scripting with Project Roslyn

BASTA! Spring 2014 Rainer Stropek software architects gmbh C# Scripting Web http://www.timecockpit.com Mail rainer@timecockpit.com Twitter @rstropek with Project Roslyn Saves the day.

Why Scripting?  Typical use cases Automate routine jobs (macros) Interfaces Installation, maintenance, updates Prototyping Software factories  Advantages Possibility to customize and extend at the customer site  business opportunity No complex prerequisites (e.g. Visual Studio), just a text editor REPL and dynamic scripting is efficient in certain situations

Why Scripting? Software Factory Projekt A Projekt B Custom Code Custom Code Base Class Library

Why Scripting? Software Factory Projekt A Projekt B Model, Extensions, Configuration, Scripts Custom Component Custom Component Model, Extensions, Configuration, Scripts Common Components Base Class Library Custom Component Custom Component

Why Scripting? Software Factory  Use classical .NET/C# for building the foundation  Use scripting as the „glue“ between the building blocks Class libraries and APIs Complex business logic Domain-specific libraries Combine existing components to working solutions using scripts Keep simple programs simple by executing text-based code assets

Scripting with .NET  Dynamic Language Runtime (DLR) E.g. IronPython (nuget)  JavaScript based on Google‘s V8 E.g. ClearScript (nuget), V8.NET, Javascript.NET, … Embedded browser (e.g. Chromium Embedded Framework (CEF), Awesomium, etc.)  C# or VB Scripting with Project Roslyn Roslyn home Roslyn scripting specs

Scripting with .NET   DLR with IronPython Part of .NET for quite a while Very good .NET integration Access to entire .NET framework Open source with active community Production-level quality Simple programming model Language is platform-independent Open source, future? JavaScript with V8 Compatibility to browsers and server (nodejs) Not core part of .NET Weaker .NET integration  C# and VB Scripting Not production yet The programming language you know and love Naturally very good .NET integration Powerful programming model (entire C# compiler pipeline) Dynamic programming (dynamic keyword) currently not supported

Getting Started Add nuget package Roslyn.Compilers.CSharp

Roslyn.Scripting.CSharp.ScriptEngine  Store a set of assembly references and imported namespaces ScriptEngine.AddReference ScriptEngine.ImportNamespace  You can create multiple engine instances in an AppDomain

Script Engine Setting up the basics Demo

Roslyn.Scripting.Session  Created based on an engine ScriptEngine.CreateSession References and Namespaces copied from engine when session is created  Add assembly references and imported namespaces to the ones defined on engine-level Session.AddReference Session.ImportNamespace  Represents a cumulative execution context E.g. define function in one code snippet, use it in the second snippet

Script Session Setting up the basics Demo

Roslyn.Scripting.Session  Executing scripts Session.Execute  returns object Session.Execute<T>  returns T Session.ExecuteFile  Host Object Script host’s object model (e.g. dedicated scripting API) Parameter to ScriptEngine.CreateSession Top-level identifiers are bound to the host object  Returning Delegates With Session.Execute<Func<…>>(…) you can return a delegate (lambda or function)

Script Session Having fun with scripting… Demo

BASTA! Spring 2014 Rainer Stropek software architects gmbh Q&A Mail rainer@timecockpit.com Web http://www.timecockpit.com Twitter @rstropek Thank your for coming! Saves the day.

is the leading time tracking solution for knowledge workers. Graphical time tracking calendar, automatic tracking of your work using signal trackers, high level of extensibility and customizability, full support to work offline, and SaaS deployment model make it the optimal choice especially in the IT consulting business. Try for free and without any risk. You can get your trial account at http://www.timecockpit.com. After the trial period you can use for only 0,20€ per user and month without a minimal subscription time and day without a minimal subscription time and without a minimal number of users.

ist die führende Projektzeiterfassung für Knowledge Worker. Grafischer Zeitbuchungskalender, automatische Tätigkeitsaufzeichnung über Signal Tracker, umfassende Erweiterbarkeit und Anpassbarkeit, volle Offlinefähigkeit und einfachste Verwendung durch SaaS machen es zur Optimalen Lösung auch speziell im IT-Umfeld. Probieren Sie kostenlos und ohne Risiko einfach aus. Einen Testzugang erhalten Sie unter http://www.timecockpit.com. Danach nutzen Sie um nur 0,20€ pro Benutzer und Tag ohne Mindestdauer und ohne Mindestbenutzeranzahl.

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

C# as a Scripting Language in Your .NET Applications Using ...

Introduction. Microsoft recently released Roslyn CTP, which previews the upcoming features of C# and VB.NET. Roslyn CTP is a pretty exciting release, and ...
Read more

Download Microsoft “Roslyn” CTP from Official ...

The Microsoft “Roslyn ... and the upcoming support for scripting and interactive use of C# ... Microsoft "Roslyn" Project Overview; Microsoft "Roslyn ...
Read more

BASTA Spring 2014: C# Scripting with Project Roslyn - Time ...

C# Scripting with Microsoft's Project Roslyn from Rainer Stropek. Sample Code You can ... About (2) CPP (3) C# (32) WPF (9) Android (1) ...
Read more

Project-less scripted C# with ScriptCS and Roslyn - Scott ...

Glenn Block is working on something interesting that combines C#, NuGet, Roslyn (the new "compiler as a service") and his love of text editors and scripts.
Read more

10 Questions, 10 Answers on Roslyn -- Visual Studio Magazine

10 Questions, 10 Answers on Roslyn. ... article "Using The Roslyn Scripting API in C#". ... Roslyn Project Overview "Exposing the C# and VB compiler's ...
Read more

CodePlex - .NET Compiler Platform ("Roslyn") - Home

NEWS: Roslyn has moved to GitHub The move has completed and our new address is https://github.com/dotnet/roslyn Move announcement The Roslyn Project has ...
Read more

ScriptCS: Turning C# into a Scripting Language

... InfoQ Homepage News ScriptCS: Turning C# into ... Block lists the advantages of scripting C# based ... this is NOT a Microsoft project and I ...
Read more

Download Whitepaper: Roslyn Project Overview from Official ...

Get an overview of how the Roslyn project exposes the Visual Basic and C# compilers’ code analysis.
Read more

GitHub - dotnet/roslyn: The .NET Compiler Platform ...

... ("Roslyn") provides open-source C# and Visual ... nuget install Microsoft.Net.Compilers # Install C# and VB compilers ... This project has adopted a ...
Read more

CS-Script - The C# Script Engine

... (CS-Script, C#, .NET1.1, .NET2.0) Home. ... Why use Roslyn when CSScript has been providing great scripting capability for my projects for over 7 years.
Read more