1 write to ScriptOptions
Microsoft.CodeAnalysis.Scripting.TestUtilities (1)
ScriptTestBase.cs (1)
37
ScriptOptions
= ScriptOptions.Default
240 references to ScriptOptions
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (30)
InteractiveSessionReferencesTests.cs (30)
43
var options =
ScriptOptions
.AddImports("System.Diagnostics");
60
var s0 = await CSharpScript.RunAsync("using System.Diagnostics;",
ScriptOptions
);
72
var s0 = await CSharpScript.RunAsync("using System.Diagnostics;",
ScriptOptions
);
91
CSharpScript.RunAsync("using System;",
ScriptOptions
).
121
var options =
ScriptOptions
.WithMetadataResolver(ScriptMetadataResolver.WithSearchPaths(RuntimeEnvironment.GetRuntimeDirectory()));
140
var options =
ScriptOptions
;
162
var options =
ScriptOptions
.
182
var options0 =
ScriptOptions
.AddReferences(
225
var options =
ScriptOptions
.
258
",
ScriptOptions
);
285
",
ScriptOptions
);
351
",
ScriptOptions
).Result;
364
",
ScriptOptions
).ContinueWith($@"
387
",
ScriptOptions
).Result;
403
",
ScriptOptions
).ContinueWith($@"
424
",
ScriptOptions
);
454
var s0 = CSharpScript.RunAsync("var x = new { a = 3 }; x",
ScriptOptions
);
479
var options =
ScriptOptions
.AddReferences(badTypeRef);
498
var options =
ScriptOptions
.
537
var s0 = await CSharpScript.Create("new C()", options:
ScriptOptions
.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync();
582
ScriptOptions
.WithReferences(libRef),
632
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
690
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
756
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
824
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
892
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
960
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
1028
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
1096
var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""",
ScriptOptions
);
1122
var s0 = await CSharpScript.RunAsync("C c;",
ScriptOptions
.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (199)
InteractiveSessionReferencesTests.cs (3)
44
",
ScriptOptions
);
103
",
ScriptOptions
);
141
",
ScriptOptions
);
InteractiveSessionTests.cs (111)
53
",
ScriptOptions
).ContinueWith(@"
74
",
ScriptOptions
).ContinueWith(@"
92
}",
ScriptOptions
).ContinueWith(@"
108
",
ScriptOptions
).ContinueWith(@"
136
",
ScriptOptions
).ContinueWith(@"
156
",
ScriptOptions
).ContinueWith(@"
175
",
ScriptOptions
).ContinueWith(@"
190
",
ScriptOptions
).ContinueWith(@"
211
var options =
ScriptOptions
.
242
",
ScriptOptions
);
275
Type c = CSharpScript.EvaluateAsync<Type>(source,
ScriptOptions
).Result;
307
",
ScriptOptions
);
351
",
ScriptOptions
);
370
",
ScriptOptions
).ContinueWith(@"
393
}",
ScriptOptions
);
404
var script = CSharpScript.Create("var x = 1;",
ScriptOptions
).ContinueWith("x");
412
CSharpScript.Create("using InteractiveFixtures.C;",
ScriptOptions
.AddReferences(HostAssembly)).
423
var s0 = CSharpScript.RunAsync("",
ScriptOptions
.AddReferences(HostAssembly));
450
",
ScriptOptions
).ContinueWith(@"
463
var options =
ScriptOptions
.AddImports("System");
476
var state1 = CSharpScript.RunAsync("internal class C1 { } protected int X; 1",
ScriptOptions
);
518
var state = CSharpScript.RunAsync("",
ScriptOptions
);
532
CSharpScript.Create("using System;",
ScriptOptions
).
540
CSharpScript.Create("int Environment = 1;",
ScriptOptions
).
552
CSharpScript.Create("int System = 1;",
ScriptOptions
).
572
CSharpScript.RunAsync("System", options:
ScriptOptions
, globals: new C1()).
582
CSharpScript.RunAsync("using System;", options:
ScriptOptions
, globals: new C1()).
593
CSharpScript.RunAsync("int System = 2;", options:
ScriptOptions
, globals: new C1()).
603
var s0 = CSharpScript.Create("int x = 1;",
ScriptOptions
);
622
var s0 = await CSharpScript.RunAsync("int x = 1;",
ScriptOptions
);
649
var state0 = await CSharpScript.RunAsync("", options:
ScriptOptions
, globals: new HostObjectWithOverrides());
664
var state0 = await CSharpScript.RunAsync("", options:
ScriptOptions
, globals: new object());
682
var state0 = CSharpScript.RunAsync("",
ScriptOptions
);
721
}",
ScriptOptions
).ContinueWith(@"
736
",
ScriptOptions
);
749
",
ScriptOptions
);
772
",
ScriptOptions
);
805
",
ScriptOptions
);
843
",
ScriptOptions
).Result;
851
Assert.Equal(18, CSharpScript.EvaluateAsync<int>("(4 + 5) * 2",
ScriptOptions
).Result);
852
Assert.Equal(1, CSharpScript.EvaluateAsync<long>("6 / (2 * 3)",
ScriptOptions
).Result);
861
",
ScriptOptions
);
882
",
ScriptOptions
).Result;
899
",
ScriptOptions
).Result;
906
var f = CSharpScript.RunAsync("using System;",
ScriptOptions
).
920
",
ScriptOptions
).ContinueWith(@"
946
",
ScriptOptions
).Result;
972
",
ScriptOptions
).Result;
985
static List<int> result = new List<int>();",
ScriptOptions
).
1000
var options =
ScriptOptions
.AddReferences(
1023
",
ScriptOptions
).Result;
1037
var result1 = await CSharpScript.EvaluateAsync<int[]>("new int[] { 1,2,3,4 }",
ScriptOptions
);
1040
var result2 = await CSharpScript.EvaluateAsync<int[]>("new int[] { 1,2,3,4,5 }",
ScriptOptions
);
1043
var s1 = await CSharpScript.RunAsync<int[]>("new int[] { 1,2,3,4,5,6 }",
ScriptOptions
);
1046
var s2 = await s1.ContinueWithAsync<int[]>("new int[] { 1,2,3,4,5,6,7 }",
ScriptOptions
);
1049
var s3 = await s2.ContinueWithAsync<int[]>("new int[] { 1,2,3,4,5,6,7,8 }",
ScriptOptions
);
1057
var result = CSharpScript.EvaluateAsync("System.Threading.Tasks.Task.FromResult(1)",
ScriptOptions
).Result;
1067
Assert.Equal(2, CSharpScript.EvaluateAsync("await System.Threading.Tasks.Task.FromResult(2)",
ScriptOptions
).Result);
1076
Assert.Equal(3, CSharpScript.EvaluateAsync<int>("0 + await System.Threading.Tasks.Task.FromResult(3)",
ScriptOptions
).Result);
1082
var task = CSharpScript.EvaluateAsync<object>("await System.Threading.Tasks.Task.Run(() => { })",
ScriptOptions
);
1103
}",
ScriptOptions
);
1115
var options =
ScriptOptions
.
1133
var options =
ScriptOptions
.
1152
var state = await CSharpScript.RunAsync("var x = (false, 4);",
ScriptOptions
);
1160
var options =
ScriptOptions
.WithLanguageVersion(MessageID.IDS_FeatureAndPattern.RequiredVersion());
1176
1 + 1",
ScriptOptions
.WithImports("System"));
1227
",
ScriptOptions
).Result;
1244
ScriptOptions
.WithFilePath(scriptPath));
1264
ScriptOptions
.WithFilePath(scriptPath));
1295
var r2 = CSharpScript.Create($@"#r ""{fileMain.Path}""",
ScriptOptions
).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1326
var r2 = CSharpScript.Create($@"#r ""{fileMain.Path}""",
ScriptOptions
).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1342
ScriptOptions
.WithReferences(libRef.WithAliases(new[] { "Hidden" })).WithImports("Hidden::N"));
1359
",
ScriptOptions
).Result;
1366
var options =
ScriptOptions
.
1377
var options =
ScriptOptions
.
1392
var options =
ScriptOptions
.AddImports("?1", "?2");
1400
options =
ScriptOptions
.AddImports("");
1406
options =
ScriptOptions
.AddImports(".abc");
1412
options =
ScriptOptions
.AddImports("a\0bc");
1430
Assert.Equal(2, CSharpScript.EvaluateAsync<int>("1+1",
ScriptOptions
).Result);
1432
Assert.Null(CSharpScript.EvaluateAsync<string>("null",
ScriptOptions
).Result);
1436
CSharpScript.RunAsync<C<int>>("null",
ScriptOptions
);
1446
var options =
ScriptOptions
.AddReferences(HostAssembly);
1455
CSharpScript.RunAsync<int>("null",
ScriptOptions
);
1468
CSharpScript.RunAsync<string>("1+1",
ScriptOptions
);
1487
",
ScriptOptions
).Result;
1531
var s0 = CSharpScript.RunAsync<int>("x + Y + Z()", options:
ScriptOptions
, globals: c);
1547
var result = CSharpScript.EvaluateAsync<string>("G()", options:
ScriptOptions
, globals: m);
1556
var s0 = await CSharpScript.RunAsync<int>("Z()", options:
ScriptOptions
, globals: c, globalsType: typeof(I));
1573
ScriptingTestHelpers.AssertCompilationError(() => CSharpScript.EvaluateAsync("Z()", options:
ScriptOptions
, globals: c),
1583
ScriptingTestHelpers.AssertCompilationError(() => CSharpScript.EvaluateAsync("Z()", options:
ScriptOptions
, globals: c),
1592
var result = CSharpScript.EvaluateAsync<int>("Z()", options:
ScriptOptions
, globals: c, globalsType: typeof(I));
1599
var s0 = CSharpScript.RunAsync("static int goo = StaticField;", options:
ScriptOptions
, globals: new C());
1618
var s0 = CSharpScript.RunAsync("int goo(double a) { return 2; }", options:
ScriptOptions
, globals: new D());
1630
var r0 = CSharpScript.EvaluateAsync<int>("X + Y + Z", options:
ScriptOptions
, globals: obj);
1634
var r1 = CSharpScript.EvaluateAsync<int>("X", options:
ScriptOptions
, globals: obj);
1643
ScriptOptions
.WithMetadataResolver(TestRuntimeMetadataReferenceResolver.Instance),
1700
options:
ScriptOptions
.
1768
ScriptOptions
.WithMetadataResolver(TestRuntimeMetadataReferenceResolver.Instance),
1844
var result = await CSharpScript.EvaluateAsync<bool>(code, options:
ScriptOptions
, globalsType: typeof(E), globals: new E());
1864
var script = CSharpScript.Create<bool>(code, options:
ScriptOptions
, globalsType: typeof(F));
1886
var script = CSharpScript.Create<bool>(code, options:
ScriptOptions
, globalsType: typeof(F));
1908
var result = await CSharpScript.EvaluateAsync<bool>(code, options:
ScriptOptions
, globalsType: typeof(F), globals: new F());
1924
",
ScriptOptions
);
1945
",
ScriptOptions
);
1972
",
ScriptOptions
);
2000
",
ScriptOptions
);
2033
", options:
ScriptOptions
, globalsType: globals.GetType());
2067
", options:
ScriptOptions
, globalsType: globals.GetType());
2101
", options:
ScriptOptions
, globalsType: globals.GetType());
2133
}", options:
ScriptOptions
, globals: new C()).
ScriptTests.cs (85)
39
var script = CSharpScript.Create("1 + 2",
ScriptOptions
);
52
var script = CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")),
ScriptOptions
);
59
Assert.Throws<ArgumentNullException>(() => CSharpScript.Create((Stream)null,
ScriptOptions
));
65
var state = await CSharpScript.RunAsync("1 + 2", options:
ScriptOptions
, globals: new ScriptTests());
73
var state = await CSharpScript.RunAsync("1 + 2", options:
ScriptOptions
, globals: new ScriptTests());
86
var script = CSharpScript.Create("1 + 2", options:
ScriptOptions
.WithEmitDebugInformation(true));
110
var script = CSharpScript.Create("1 + 2",
ScriptOptions
);
121
var script = CSharpScript.Create<int>("X + Y", options:
ScriptOptions
, globalsType: typeof(Globals));
132
var state = await CSharpScript.RunAsync("1 + 2",
ScriptOptions
);
139
var script = CSharpScript.Create("1 + 2",
ScriptOptions
);
148
var script = CSharpScript.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")),
ScriptOptions
);
157
var value = await CSharpScript.EvaluateAsync("1 + 2",
ScriptOptions
);
164
var state = await CSharpScript.RunAsync("1 + 2",
ScriptOptions
);
172
CSharpScript.Create("System.Console.WriteLine(0);",
ScriptOptions
),
182
F();",
ScriptOptions
);
198
,
ScriptOptions
.WithReferences(MscorlibRef, SystemRef, SystemCoreRef, CSharpRef));
213
,
ScriptOptions
.WithReferences(MscorlibRef, SystemRef, SystemCoreRef, CSharpRef));
224
System.Console.WriteLine(true)", options:
ScriptOptions
, globals: new ScriptTests());
242
System.Console.WriteLine(true);", options:
ScriptOptions
, globals: new ScriptTests());
249
var state = CSharpScript.RunAsync(@"System.Console.WriteLine(true) ", options:
ScriptOptions
, globals: new ScriptTests());
259
", options:
ScriptOptions
, globals: new ScriptTests());
271
throw e;", options:
ScriptOptions
, globals: new ScriptTests());
290
var state = await CSharpScript.RunAsync("X + Y", options:
ScriptOptions
, globals: new Globals { X = 1, Y = 2 });
297
var script = CSharpScript.Create("X + Y", options:
ScriptOptions
, globalsType: typeof(Globals));
306
var script = CSharpScript.Create("X + Y",
ScriptOptions
);
315
var script = CSharpScript.Create("X + Y", options:
ScriptOptions
, globalsType: typeof(Globals));
324
var script = CSharpScript.Create("X + Y", options:
ScriptOptions
, globalsType: typeof(Globals));
333
var state = await CSharpScript.RunAsync("X + Y", options:
ScriptOptions
, globals: new Globals());
341
var state1 = await CSharpScript.RunAsync("X + Y + 1", options:
ScriptOptions
, globals: new Globals());
342
var state2 = await CSharpScript.RunAsync("X + Y + 2", options:
ScriptOptions
, globals: new Globals());
351
var state = await CSharpScript.RunAsync("int X = 100;",
ScriptOptions
).ContinueWith("X + X");
365
var state = await CSharpScript.RunAsync("",
ScriptOptions
);
394
options:
ScriptOptions
,
419
var script = CSharpScript.Create("var x = 1;",
ScriptOptions
);
442
",
ScriptOptions
);
459
var state1 = await CSharpScript.RunAsync("int M(int x) { return x + x; }",
ScriptOptions
);
475
var state0 = await CSharpScript.RunAsync("static int Add(int x, int y) => x + y;", options:
ScriptOptions
.WithLanguageVersion(LanguageVersion.Preview));
484
var state0 = await CSharpScript.RunAsync("class Id<T> { static T Core(T t) => t; public static System.Func<T, T> Get => Core; }",
ScriptOptions
);
492
var state0 = await CSharpScript.RunAsync("class Id { static T Core<T>(T t) => t; public static System.Func<T, T> Get<T>() => Core; }",
ScriptOptions
);
501
var script = CSharpScript.Create<object>($"return {expected};",
ScriptOptions
);
510
CSharpScript.Create("System.Console.WriteLine();",
ScriptOptions
), ""));
516
var script = CSharpScript.Create<int>("return await System.Threading.Tasks.Task.FromResult(42);",
ScriptOptions
);
529
}",
ScriptOptions
);
543
System.Console.WriteLine();",
ScriptOptions
);
553
System.Console.WriteLine();",
ScriptOptions
);
567
System.Console.WriteLine();",
ScriptOptions
);
577
System.Console.WriteLine()",
ScriptOptions
);
591
1.1",
ScriptOptions
);
601
1.1",
ScriptOptions
);
613
}",
ScriptOptions
);
621
}",
ScriptOptions
);
633
}",
ScriptOptions
);
641
}",
ScriptOptions
);
651
var options =
ScriptOptions
.WithSourceResolver(resolver);
674
var options =
ScriptOptions
.WithSourceResolver(resolver);
697
var options =
ScriptOptions
.WithSourceResolver(resolver);
718
var options =
ScriptOptions
.WithSourceResolver(resolver);
726
options =
ScriptOptions
.WithSourceResolver(resolver);
736
options =
ScriptOptions
.WithSourceResolver(resolver);
753
var options =
ScriptOptions
.WithSourceResolver(resolver);
761
options =
ScriptOptions
.WithSourceResolver(resolver);
771
options =
ScriptOptions
.WithSourceResolver(resolver);
790
var options =
ScriptOptions
.WithSourceResolver(resolver);
814
var script = CSharpScript.Create("return;",
ScriptOptions
);
824
b",
ScriptOptions
);
837
var options =
ScriptOptions
.WithSourceResolver(resolver);
851
var opts =
ScriptOptions
.WithEmitDebugInformation(true).WithFilePath("debug.csx").WithFileEncoding(null);
865
var opts =
ScriptOptions
.WithEmitDebugInformation(true).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8);
872
var opts =
ScriptOptions
.WithEmitDebugInformation(false).WithFilePath(null).WithFileEncoding(null);
879
var opts =
ScriptOptions
.WithEmitDebugInformation(false).WithFilePath("debug.csx").WithFileEncoding(Encoding.UTF8);
887
var opts =
ScriptOptions
.WithEmitDebugInformation(true).WithFilePath("debug.csx");
894
var opts =
ScriptOptions
.WithEmitDebugInformation(false).WithFilePath("debug.csx");
902
var opts =
ScriptOptions
.WithEmitDebugInformation(true).WithFileEncoding(null);
910
var opts =
ScriptOptions
.WithEmitDebugInformation(true).WithFileEncoding(Encoding.UTF8);
917
var opts =
ScriptOptions
.WithEmitDebugInformation(false).WithFileEncoding(null);
924
var opts =
ScriptOptions
.WithEmitDebugInformation(false).WithFileEncoding(Encoding.UTF8);
932
var opts =
ScriptOptions
.WithEmitDebugInformation(true);
939
var opts =
ScriptOptions
.WithEmitDebugInformation(false);
947
var options =
ScriptOptions
.WithSourceResolver(resolver);
955
var script = CSharpScript.Create(@"string x = default;",
ScriptOptions
.WithLanguageVersion(LanguageVersion.CSharp7));
969
string x = null;",
ScriptOptions
.WithLanguageVersion(LanguageVersion.CSharp8));
991
var script = CSharpScript.Create(code,
ScriptOptions
.WithLanguageVersion(LanguageVersion.CSharp8));
1007
await CSharpScript.RunAsync(@"var data = notExistentVariable switch { _ => null };", options:
ScriptOptions
, globals: new ScriptTests());
1029
await CSharpScript.RunAsync(@"var data = ""data"" switch { < 5 => null };", options:
ScriptOptions
, globals: new ScriptTests());
1054
await CSharpScript.RunAsync(@"var data = ""test"" switch { _ => armError };", options:
ScriptOptions
, globals: new ScriptTests());
Microsoft.CodeAnalysis.VisualBasic.Scripting.UnitTests (11)
InteractiveSessionTests.vb (8)
22
RunAsync("Dim x As Integer = 1",
ScriptOptions
).
34
Assert.Equal(1, VisualBasicScript.EvaluateAsync(source,
ScriptOptions
).Result)
42
Assert.Equal(1, VisualBasicScript.EvaluateAsync(source,
ScriptOptions
).Result)
51
Assert.Null(VisualBasicScript.EvaluateAsync(source,
ScriptOptions
).Result)
67
Assert.Equal(6, VisualBasicScript.EvaluateAsync(source,
ScriptOptions
).Result)
75
",
ScriptOptions
).ContinueWith("
96
",
ScriptOptions
).ContinueWith("
123
",
ScriptOptions
)
ScriptTests.vb (3)
26
Private ReadOnly DefaultOptions As ScriptOptions =
ScriptOptions
.AddReferences(s_msvbReference)
30
Dim script = VisualBasicScript.Create("? 1 + 2",
ScriptOptions
)
62
Dim script = VisualBasicScript.Create("? 1 + 2",
ScriptOptions
)