Skip to content

Commit dc4f02e

Browse files
committed
Update all assemblies and code, added missing Immutable.dll
1 parent 7da3336 commit dc4f02e

17 files changed

+34
-59616
lines changed

CSharpScripts/Program.cs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public class GlobalParams
1212
public int Y;
1313
}
1414

15+
public class SumParams
16+
{
17+
public int a;
18+
public int b;
19+
}
20+
1521
static void Main(string[] args)
1622
{
1723
Console.WriteLine("EvalWithoutParameters");
@@ -32,41 +38,43 @@ static void Main(string[] args)
3238
Console.ReadLine();
3339
}
3440

35-
public static void EvalWithoutParameters()
41+
public static async void EvalWithoutParameters()
3642
{
37-
var result = CSharpScript.Eval(@"25 + 30", ScriptOptions.Default);
43+
var result = await CSharpScript.EvaluateAsync(@"25 + 30", ScriptOptions.Default);
3844
Console.WriteLine("Eval: " + result);
3945
}
4046

41-
public static void EvalExpression()
47+
public static async void EvalExpression()
4248
{
43-
var result = CSharpScript.Eval(@"X + Y", ScriptOptions.Default, new GlobalParams { X = 12, Y = 25 });
49+
var result = await CSharpScript.EvaluateAsync(@"X + Y", ScriptOptions.Default, new GlobalParams { X = 12, Y = 25 });
4450
Console.WriteLine("Eval: " + result);
4551
}
4652

47-
public static void ScriptCreateAndRun()
53+
public static async void ScriptCreateAndRun()
4854
{
49-
var script = CSharpScript.Create(@"var result = X + Y;", ScriptOptions.Default);
50-
var state = script.Run(new GlobalParams { X = 10, Y = 2 });
51-
var state2 = script.Run(new GlobalParams { X = 1, Y = 3 });
55+
var script = CSharpScript.Create(@"var result = X + Y;", ScriptOptions.Default, typeof(GlobalParams));
56+
var state = await script.RunAsync(new GlobalParams { X = 10, Y = 2 });
57+
var state2 = await script.RunAsync(new GlobalParams { X = 1, Y = 3 });
5258
Console.WriteLine("State variable: " + state.Variables["result"].Value);
5359
Console.WriteLine("State2 variable: " + state2.Variables["result"].Value);
5460
}
5561

56-
public static void ScriptWithNamespace()
62+
public static async void ScriptWithNamespace()
5763
{
5864
var scriptOptions = ScriptOptions.Default.AddNamespaces("System.IO");
5965
var script = CSharpScript.Create(@"var result = Path.Combine(""folder"", ""file"");", scriptOptions);
60-
var state = script.Run();
66+
var state = await script.RunAsync();
6167
Console.WriteLine("State variable: " + state.Variables["result"].Value);
6268
}
6369

64-
public static void ScriptAsDelegate()
70+
public static async void ScriptAsDelegate()
6571
{
66-
var script = CSharpScript.Create(@"int Sum(int a, int b) { return a + b;}", ScriptOptions.Default);
67-
var state = script.Run();
68-
var sumFunction = state.CreateDelegate<Func<int, int, int>>("Sum");
69-
Console.WriteLine("Sum function: " + sumFunction(2,22));
72+
var param = new SumParams { a = 2, b = 22 };
73+
var script = CSharpScript.Create<int>(@"int sum(int a, int b){return a + b;}", ScriptOptions.Default, typeof(SumParams))
74+
.ContinueWith("sum(a, b)");
75+
var function = script.CreateDelegate();
76+
var result = await function(param);
77+
Console.WriteLine("Sum function: " + result);
7078
}
7179
}
7280
}
4 KB
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
8+
</requestedPrivileges>
9+
</security>
10+
</trustInfo>
11+
</assembly>
Binary file not shown.

CSharpScripts/bin/Debug/Microsoft.CodeAnalysis.CSharp.xml

Lines changed: 0 additions & 32333 deletions
This file was deleted.
Binary file not shown.

CSharpScripts/bin/Debug/Microsoft.CodeAnalysis.Desktop.xml

Lines changed: 0 additions & 1499 deletions
This file was deleted.
Binary file not shown.

CSharpScripts/bin/Debug/Microsoft.CodeAnalysis.Scripting.CSharp.xml

Lines changed: 0 additions & 106 deletions
This file was deleted.

0 commit comments

Comments
 (0)