242 references to CSharpScript
InteractiveHost.UnitTests (1)
InteractiveHostCoreInitTests.cs (1)
43
var scriptingAssemblyName = typeof(
CSharpScript
).Assembly.GetName().Name;
Microsoft.CodeAnalysis.CSharp.Scripting (1)
Hosting\CSharpReplServiceProvider.cs (1)
28
=>
CSharpScript
.Create<T>(code, options, globalsTypeOpt, assemblyLoader);
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (30)
InteractiveSessionReferencesTests.cs (30)
45
var s0 = await
CSharpScript
.RunAsync("", options);
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).
123
var result =
CSharpScript
.EvaluateAsync($@"
147
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync(source, options),
167
var script =
CSharpScript
.Create(@"
186
var s0 = await
CSharpScript
.RunAsync<Process>($@"
230
var process =
CSharpScript
.EvaluateAsync<Process>($@"
253
var script =
CSharpScript
.Create($@"
283
var script0 =
CSharpScript
.Create($@"
346
var result =
CSharpScript
.EvaluateAsync($@"
362
var result =
CSharpScript
.Create($@"
382
var result =
CSharpScript
.EvaluateAsync($@"
401
var result =
CSharpScript
.Create($@"
421
var script0 =
CSharpScript
.Create($@"
454
var s0 =
CSharpScript
.RunAsync("var x = new { a = 3 }; x", ScriptOptions);
482
var script =
CSharpScript
.Create("new S1()", options);
501
var s0 = await
CSharpScript
.RunAsync<int>("x", options, new C());
537
var s0 = await
CSharpScript
.Create("new C()", options: ScriptOptions.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync();
580
var script =
CSharpScript
.Create<int>(
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 (205)
InteractiveSessionReferencesTests.cs (3)
41
var s0 =
CSharpScript
.Create($@"
99
var s0 =
CSharpScript
.Create($@"
138
var s0 =
CSharpScript
.Create($@"
InteractiveSessionTests.cs (112)
45
var script =
CSharpScript
.Create(@"
66
var script =
CSharpScript
.Create(@"
87
var script =
CSharpScript
.Create(@"
104
var script =
CSharpScript
.Create(@"
134
var script =
CSharpScript
.Create(@"
154
var script =
CSharpScript
.Create(@"
173
var script =
CSharpScript
.Create(@"
188
var script =
CSharpScript
.Create(@"
218
var script =
CSharpScript
.Create(@"
234
var script =
CSharpScript
.Create(@"
275
Type c =
CSharpScript
.EvaluateAsync<Type>(source, ScriptOptions).Result;
301
var script =
CSharpScript
.Create<int>(@"
328
var script =
CSharpScript
.Create(@"
364
var script =
CSharpScript
.Create(@"
389
var script =
CSharpScript
.Create(
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));
447
var script =
CSharpScript
.Create(@"
465
var state =
CSharpScript
.RunAsync("Environment.ProcessorCount", options);
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);
716
var script =
CSharpScript
.Create(@"
733
CSharpScript
.EvaluateAsync(@"
742
var s0 =
CSharpScript
.Create(@"
761
var state =
CSharpScript
.RunAsync(@"
794
var state =
CSharpScript
.RunAsync(@"
829
var result =
CSharpScript
.EvaluateAsync<int>(@"
851
Assert.Equal(18,
CSharpScript
.EvaluateAsync<int>("(4 + 5) * 2", ScriptOptions).Result);
852
Assert.Equal(1,
CSharpScript
.EvaluateAsync<long>("6 / (2 * 3)", ScriptOptions).Result);
858
var s =
CSharpScript
.RunAsync(@"
873
var f =
CSharpScript
.EvaluateAsync<Func<int, int>>(@"
889
var result =
CSharpScript
.EvaluateAsync<List<string>>(@"
906
var f =
CSharpScript
.RunAsync("using System;", ScriptOptions).
916
var s =
CSharpScript
.RunAsync(@"
932
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
956
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
983
var result =
CSharpScript
.RunAsync(@"
1003
var result =
CSharpScript
.EvaluateAsync<int>(@"
1014
var result =
CSharpScript
.EvaluateAsync<object[]>(@"
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);
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);
1093
var s0 = await
CSharpScript
.RunAsync(@"
1120
CSharpScript
.RunAsync("int i = 0;", options).
1138
CSharpScript
.Create("int i = 0;", options).
1152
var state = await
CSharpScript
.RunAsync("var x = (false, 4);", ScriptOptions);
1161
var state = await
CSharpScript
.RunAsync("object x = 1;", options: options);
1175
var script =
CSharpScript
.Create(@"
1223
object result =
CSharpScript
.EvaluateAsync($@"
1242
var script =
CSharpScript
.Create(
1262
var script =
CSharpScript
.Create(
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;
1341
var script =
CSharpScript
.Create(@"new C()",
1354
object result =
CSharpScript
.EvaluateAsync(@"
1370
object result =
CSharpScript
.EvaluateAsync("new int[] { 1, 2, 3 }.First()", options).Result;
1381
var s1 =
CSharpScript
.RunAsync("new int[] { 1, 2, 3 }.First()", options);
1394
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1402
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1408
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1414
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
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);
1448
var cint =
CSharpScript
.EvaluateAsync<C<int>>("null", options).Result;
1451
Assert.Null(
CSharpScript
.EvaluateAsync<int?>("null", options).Result);
1455
CSharpScript
.RunAsync<int>("null", ScriptOptions);
1468
CSharpScript
.RunAsync<string>("1+1", ScriptOptions);
1483
var value =
CSharpScript
.EvaluateAsync<IEnumerable<Exception>>(@"
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);
1641
var scriptCompilation =
CSharpScript
.Create(
1698
var scriptCompilation =
CSharpScript
.Create(
1702
WithReferences(typeof(
CSharpScript
).GetTypeInfo().Assembly),
1763
#r ""{typeof(
CSharpScript
).GetTypeInfo().Assembly.ManifestModule.FullyQualifiedName}""
1766
var scriptCompilation =
CSharpScript
.Create(
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());
1920
var s0 =
CSharpScript
.Create(@"
1943
var s0 =
CSharpScript
.Create(@"
1970
var s0 =
CSharpScript
.Create(@"
1998
var state0 = await
CSharpScript
.RunAsync(@"
2031
var s0 =
CSharpScript
.Create(@"
2065
var s0 =
CSharpScript
.Create(@"
2099
var s0 =
CSharpScript
.Create(@"
2128
CSharpScript
.RunAsync(
ScriptTests.cs (90)
39
var script =
CSharpScript
.Create("1 + 2", ScriptOptions);
46
Assert.Throws<ArgumentNullException>(() =>
CSharpScript
.Create((string)null));
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),
180
var state = await
CSharpScript
.RunAsync(
189
await
CSharpScript
.RunAsync(@"
204
await
CSharpScript
.RunAsync(@"
223
var state =
CSharpScript
.RunAsync(@"if (true)
241
var state =
CSharpScript
.RunAsync(@"if (true)
249
var state =
CSharpScript
.RunAsync(@"System.Console.WriteLine(true) ", options: ScriptOptions, globals: new ScriptTests());
256
var state =
CSharpScript
.RunAsync(@"
270
var state =
CSharpScript
.RunAsync(@"if (e) a = b
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);
392
CSharpScript
.Create(
419
var script =
CSharpScript
.Create("var x = 1;", ScriptOptions);
438
var state = await
CSharpScript
.RunAsync(@"
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);
524
var script =
CSharpScript
.Create(@"
537
var script =
CSharpScript
.Create(@"
547
script =
CSharpScript
.Create(@"
561
var script =
CSharpScript
.Create<int>(@"
571
script =
CSharpScript
.Create<int>(@"
585
var script =
CSharpScript
.Create(@"
595
script =
CSharpScript
.Create(@"
609
var script =
CSharpScript
.Create<IEnumerable<int>>(@"
617
script =
CSharpScript
.Create<IEnumerable<int>>(@"
629
var script =
CSharpScript
.Create<int?>(@"
637
script =
CSharpScript
.Create<int?>(@"
653
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
657
script =
CSharpScript
.Create(@"
676
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
680
script =
CSharpScript
.Create(@"
699
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
703
script =
CSharpScript
.Create(@"
719
var script =
CSharpScript
.Create("#load \"b.csx\"", options);
727
script =
CSharpScript
.Create(@"
737
script =
CSharpScript
.Create(@"
754
var script =
CSharpScript
.Create("#load \"b.csx\"", options);
762
script =
CSharpScript
.Create(@"
772
script =
CSharpScript
.Create(@"
792
var script =
CSharpScript
.Create(@"
800
script =
CSharpScript
.Create(@"
814
var script =
CSharpScript
.Create("return;", ScriptOptions);
818
script =
CSharpScript
.Create(@"
838
var script =
CSharpScript
.Create<int>(@"
852
var script = await
CSharpScript
.RunAsync(code, opts);
866
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "debug.csx");
873
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
880
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
888
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: "debug.csx");
895
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts));
903
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "");
911
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "");
918
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
925
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
933
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: "");
940
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts));
948
var script =
CSharpScript
.Create(@"#load ""a.csx""", options);
955
var script =
CSharpScript
.Create(@"string x = default;", ScriptOptions.WithLanguageVersion(LanguageVersion.CSharp7));
968
var script =
CSharpScript
.Create(@"#nullable enable
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.Scripting.UnitTests (5)
ScriptOptionsTests.cs (5)
163
var compilation =
CSharpScript
.Create(string.Empty, scriptOptions).GetCompilation();
219
var compilation = (CSharpCompilation)
CSharpScript
.Create(string.Empty, scriptOptions).GetCompilation();
246
var compilation =
CSharpScript
.Create(string.Empty, scriptOptions).GetCompilation();
274
var compilation =
CSharpScript
.Create(string.Empty, scriptOptions).GetCompilation();
311
var compilation =
CSharpScript
.Create(string.Empty, scriptOptions).GetCompilation();