From fd363ed02c6c6c5a66961f62465c602e1b228d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Matou=C5=A1ek?= Date: Wed, 28 Oct 2015 00:11:48 -0700 Subject: [PATCH] Updated Scripting API Samples (markdown) --- Scripting-API-Samples.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Scripting-API-Samples.md b/Scripting-API-Samples.md index 1057fb4..f566447 100644 --- a/Scripting-API-Samples.md +++ b/Scripting-API-Samples.md @@ -70,7 +70,7 @@ Console.WriteLine(await CSharpScript.EvaluateAsync("X+Y", globals: globals) ### Create & build a C# script and execute it multiple times ```csharp var script = CSharpScript.Create("X*Y", globalsType: typeof(Globals)); -script.Build(); +script.Compile(); for (int i = 0; i < 10; i++) { Console.WriteLine(await script.EvaluateAsync(new Globals { X = i, Y = i })); @@ -117,6 +117,7 @@ Console.WriteLine(state.ReturnValue); ### Create and analyze a C# script ```csharp using Microsoft.CodeAnalysis; + var script = CSharpScript.Create(Console.ReadLine()); Compilation compilation = script.GetCompilation(); //do stuff @@ -126,6 +127,7 @@ Compilation gives access to the full set of Roslyn APIs. ### Customize assembly loading ```csharp using Microsoft.CodeAnalysis.Scripting.Hosting; + using (var loader = new InteractiveAssemblyLoader()) { var script = CSharpScript.Create("1", assemblyLoader: loader);