SlideShare una empresa de Scribd logo
1 de 18
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.

Más contenido relacionado

La actualidad más candente

scriptcs - scripted C#, REPL and script extensibility
scriptcs - scripted C#, REPL and script extensibilityscriptcs - scripted C#, REPL and script extensibility
scriptcs - scripted C#, REPL and script extensibility
Filip W
 
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
Daniel Fisher
 

La actualidad más candente (20)

Importing Code and Existing Containers to OpenShift - Minneapolis Docker Meet...
Importing Code and Existing Containers to OpenShift - Minneapolis Docker Meet...Importing Code and Existing Containers to OpenShift - Minneapolis Docker Meet...
Importing Code and Existing Containers to OpenShift - Minneapolis Docker Meet...
 
Case Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API DocsCase Study: Integration Automation Create Delightful API Docs
Case Study: Integration Automation Create Delightful API Docs
 
scriptcs - scripted C#, REPL and script extensibility
scriptcs - scripted C#, REPL and script extensibilityscriptcs - scripted C#, REPL and script extensibility
scriptcs - scripted C#, REPL and script extensibility
 
server side Swift
server side Swift server side Swift
server side Swift
 
Frail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case StudyFrail & Cast Iron tools - a Postman Case Study
Frail & Cast Iron tools - a Postman Case Study
 
GitHub as a Landing Page
GitHub as a Landing Page GitHub as a Landing Page
GitHub as a Landing Page
 
OSCON 2012: ql.io and Node.js
OSCON 2012: ql.io and Node.jsOSCON 2012: ql.io and Node.js
OSCON 2012: ql.io and Node.js
 
Designing Auto Generated Codes
Designing Auto Generated CodesDesigning Auto Generated Codes
Designing Auto Generated Codes
 
Rescale New Feature: Bring Your Own VPC
Rescale New Feature: Bring Your Own VPCRescale New Feature: Bring Your Own VPC
Rescale New Feature: Bring Your Own VPC
 
X-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN StackX-celerate 2019: Iterating fast with the MERN Stack
X-celerate 2019: Iterating fast with the MERN Stack
 
Building Cloud-agnostic Serverless APIs
Building Cloud-agnostic Serverless APIsBuilding Cloud-agnostic Serverless APIs
Building Cloud-agnostic Serverless APIs
 
Deploying R for Production - SRUG
Deploying R for Production - SRUGDeploying R for Production - SRUG
Deploying R for Production - SRUG
 
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
2005 - .NET SummerCamp: Web developmentwith IIS & ASP.NET webservices
 
Serverless Containers
Serverless ContainersServerless Containers
Serverless Containers
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot Topics
 
What's coming in c# 9.0
What's coming in c# 9.0What's coming in c# 9.0
What's coming in c# 9.0
 
IBM Bootcamp - Text to Speech API Lab
IBM Bootcamp - Text to Speech API LabIBM Bootcamp - Text to Speech API Lab
IBM Bootcamp - Text to Speech API Lab
 
What's Coming in C# 9.0
What's Coming in C# 9.0What's Coming in C# 9.0
What's Coming in C# 9.0
 
Kubernetes Operators - the next frontier in application automation - Ádám Sándor
Kubernetes Operators - the next frontier in application automation - Ádám SándorKubernetes Operators - the next frontier in application automation - Ádám Sándor
Kubernetes Operators - the next frontier in application automation - Ádám Sándor
 
Nils Rhode - Does it always have to be k8s - TeC Day 2019
Nils Rhode - Does it always have to be k8s - TeC Day 2019Nils Rhode - Does it always have to be k8s - TeC Day 2019
Nils Rhode - Does it always have to be k8s - TeC Day 2019
 

Destacado

Schema presentation
Schema presentationSchema presentation
Schema presentation
l.t.j
 

Destacado (16)

UI Configuration in CoFX
UI Configuration in CoFXUI Configuration in CoFX
UI Configuration in CoFX
 
MS TechEd 2013: Continuous Integration with Team Foundation Services and Wind...
MS TechEd 2013: Continuous Integration with Team Foundation Services and Wind...MS TechEd 2013: Continuous Integration with Team Foundation Services and Wind...
MS TechEd 2013: Continuous Integration with Team Foundation Services and Wind...
 
Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#Workshop: Async and Parallel in C#
Workshop: Async and Parallel in C#
 
SQL Server Reporting Services Training
SQL Server Reporting Services TrainingSQL Server Reporting Services Training
SQL Server Reporting Services Training
 
Catching The Long Tail With SaaS + Windows Azure
Catching The Long Tail With SaaS + Windows AzureCatching The Long Tail With SaaS + Windows Azure
Catching The Long Tail With SaaS + Windows Azure
 
NRWConf 2013 - Effort Estimation in Agile Projects
NRWConf 2013 - Effort Estimation in Agile ProjectsNRWConf 2013 - Effort Estimation in Agile Projects
NRWConf 2013 - Effort Estimation in Agile Projects
 
Workshop: Modularization of .NET Applications
Workshop: Modularization of .NET ApplicationsWorkshop: Modularization of .NET Applications
Workshop: Modularization of .NET Applications
 
Whats New for WPF in .NET 4.5
Whats New for WPF in .NET 4.5Whats New for WPF in .NET 4.5
Whats New for WPF in .NET 4.5
 
Workshop: .NET Code Contracts
Workshop: .NET Code ContractsWorkshop: .NET Code Contracts
Workshop: .NET Code Contracts
 
High Quality C# - Codequality in Practice
High Quality C# - Codequality in PracticeHigh Quality C# - Codequality in Practice
High Quality C# - Codequality in Practice
 
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows AzureDeveloping Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
Developing Android and iOS Apps With C#, .NET, Xamarin, Mono, and Windows Azure
 
BASTA 2013: Custom OData Provider
BASTA 2013: Custom OData ProviderBASTA 2013: Custom OData Provider
BASTA 2013: Custom OData Provider
 
Portafolio andrés rodriguez
Portafolio andrés rodriguezPortafolio andrés rodriguez
Portafolio andrés rodriguez
 
Schema presentation
Schema presentationSchema presentation
Schema presentation
 
Business Model Generation Patterns
Business Model Generation PatternsBusiness Model Generation Patterns
Business Model Generation Patterns
 
AngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile ServicesAngularJS with TypeScript and Windows Azure Mobile Services
AngularJS with TypeScript and Windows Azure Mobile Services
 

Similar a C# Scripting with Microsoft's Project Roslyn

Spring.Net, Feb 2008, PostSharp: A Technical Introduction
Spring.Net, Feb 2008, PostSharp:  A Technical IntroductionSpring.Net, Feb 2008, PostSharp:  A Technical Introduction
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
gfraiteur
 
scriptcs - scripting, hosting and extending
scriptcs - scripting, hosting and extendingscriptcs - scripting, hosting and extending
scriptcs - scripting, hosting and extending
Filip W
 
What’s New for Devs
What’s New for DevsWhat’s New for Devs
What’s New for Devs
MicrosoftFeed
 
Heterogeneous Development With RTC - Sreerupa Sen
Heterogeneous Development With RTC -  Sreerupa SenHeterogeneous Development With RTC -  Sreerupa Sen
Heterogeneous Development With RTC - Sreerupa Sen
Roopa Nadkarni
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
George Kanellopoulos
 

Similar a C# Scripting with Microsoft's Project Roslyn (20)

The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
 
Visual studio 2019 launch
Visual studio 2019 launch Visual studio 2019 launch
Visual studio 2019 launch
 
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
Spring.Net, Feb 2008, PostSharp:  A Technical IntroductionSpring.Net, Feb 2008, PostSharp:  A Technical Introduction
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
 
scriptcs - scripting, hosting and extending
scriptcs - scripting, hosting and extendingscriptcs - scripting, hosting and extending
scriptcs - scripting, hosting and extending
 
Application Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldApplication Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless World
 
01 Introduction to programming
01 Introduction to programming01 Introduction to programming
01 Introduction to programming
 
What’s New for Devs
What’s New for DevsWhat’s New for Devs
What’s New for Devs
 
Heterogeneous Development With RTC - Sreerupa Sen
Heterogeneous Development With RTC -  Sreerupa SenHeterogeneous Development With RTC -  Sreerupa Sen
Heterogeneous Development With RTC - Sreerupa Sen
 
Moduarlity patterns with OSGi
Moduarlity patterns with OSGiModuarlity patterns with OSGi
Moduarlity patterns with OSGi
 
Rupie asp.net
Rupie asp.netRupie asp.net
Rupie asp.net
 
ASPNET for PHP Developers
ASPNET for PHP DevelopersASPNET for PHP Developers
ASPNET for PHP Developers
 
Windows Azure & How to Deploy Wordress
Windows Azure & How to Deploy WordressWindows Azure & How to Deploy Wordress
Windows Azure & How to Deploy Wordress
 
Introduction to Programming Lesson 01
Introduction to Programming Lesson 01Introduction to Programming Lesson 01
Introduction to Programming Lesson 01
 
Zero to Portlet in 20 minutes or less
Zero to Portlet in 20 minutes or lessZero to Portlet in 20 minutes or less
Zero to Portlet in 20 minutes or less
 
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
"Technical Challenges behind Visual IDE for React Components" Tetiana Mandziuk
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 
Build 2017 - B8083 - The future of Visual Studio
Build 2017 - B8083 - The future of Visual StudioBuild 2017 - B8083 - The future of Visual Studio
Build 2017 - B8083 - The future of Visual Studio
 
Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017Machine learning services with SQL Server 2017
Machine learning services with SQL Server 2017
 
I T Mentors V S2008 Onramp240 V1
I T Mentors  V S2008  Onramp240 V1I T Mentors  V S2008  Onramp240 V1
I T Mentors V S2008 Onramp240 V1
 
Polymer
PolymerPolymer
Polymer
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

C# Scripting with Microsoft's Project Roslyn

  • 2. 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.
  • 3. 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
  • 4. Why Scripting? Software Factory Projekt A Projekt B Custom Code Custom Code Base Class Library
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. Getting Started Add nuget package Roslyn.Compilers.CSharp
  • 10. 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
  • 11. Script Engine Setting up the basics Demo
  • 12. 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
  • 13. Script Session Setting up the basics Demo
  • 14. 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)
  • 15. Script Session Having fun with scripting… Demo
  • 16. 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.
  • 17. 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.
  • 18. 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.