244 references to CSharpScript
InteractiveHost.UnitTests (1)
InteractiveHostCoreInitTests.cs (1)
44
var scriptingAssemblyName = typeof(
CSharpScript
).Assembly.GetName().Name;
Microsoft.CodeAnalysis.CSharp.Scripting (1)
Hosting\CSharpReplServiceProvider.cs (1)
27
=>
CSharpScript
.Create<T>(code, options, globalsTypeOpt, assemblyLoader);
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (30)
InteractiveSessionReferencesTests.cs (30)
43
var s0 = await
CSharpScript
.RunAsync("", options);
58
var s0 = await
CSharpScript
.RunAsync("using System.Diagnostics;", ScriptOptions);
70
var s0 = await
CSharpScript
.RunAsync("using System.Diagnostics;", ScriptOptions);
89
CSharpScript
.RunAsync("using System;", ScriptOptions).
121
var result =
CSharpScript
.EvaluateAsync($@"
145
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync(source, options),
165
var script =
CSharpScript
.Create(@"
184
var s0 = await
CSharpScript
.RunAsync<Process>($@"
228
var process =
CSharpScript
.EvaluateAsync<Process>($@"
251
var script =
CSharpScript
.Create($@"
281
var script0 =
CSharpScript
.Create($@"
344
var result =
CSharpScript
.EvaluateAsync($@"
360
var result =
CSharpScript
.Create($@"
380
var result =
CSharpScript
.EvaluateAsync($@"
399
var result =
CSharpScript
.Create($@"
419
var script0 =
CSharpScript
.Create($@"
452
var s0 =
CSharpScript
.RunAsync("var x = new { a = 3 }; x", ScriptOptions);
480
var script =
CSharpScript
.Create("new S1()", options);
499
var s0 = await
CSharpScript
.RunAsync<int>("x", options, new C());
535
var s0 = await
CSharpScript
.Create("new C()", options: ScriptOptions.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync();
578
var script =
CSharpScript
.Create<int>(
630
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
688
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
754
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
822
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
890
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
958
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
1026
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
1094
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""", ScriptOptions);
1120
var s0 = await
CSharpScript
.RunAsync("C c;", ScriptOptions.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (207)
InteractiveSessionReferencesTests.cs (3)
39
var s0 =
CSharpScript
.Create($@"
97
var s0 =
CSharpScript
.Create($@"
136
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);
519
var state =
CSharpScript
.RunAsync("", ScriptOptions);
533
CSharpScript
.Create("using System;", ScriptOptions).
541
CSharpScript
.Create("int Environment = 1;", ScriptOptions).
553
CSharpScript
.Create("int System = 1;", ScriptOptions).
573
CSharpScript
.RunAsync("System", options: ScriptOptions, globals: new C1()).
583
CSharpScript
.RunAsync("using System;", options: ScriptOptions, globals: new C1()).
594
CSharpScript
.RunAsync("int System = 2;", options: ScriptOptions, globals: new C1()).
604
var s0 =
CSharpScript
.Create("int x = 1;", ScriptOptions);
623
var s0 = await
CSharpScript
.RunAsync("int x = 1;", ScriptOptions);
650
var state0 = await
CSharpScript
.RunAsync("", options: ScriptOptions, globals: new HostObjectWithOverrides());
665
var state0 = await
CSharpScript
.RunAsync("", options: ScriptOptions, globals: new object());
683
var state0 =
CSharpScript
.RunAsync("", ScriptOptions);
717
var script =
CSharpScript
.Create(@"
734
CSharpScript
.EvaluateAsync(@"
743
var s0 =
CSharpScript
.Create(@"
762
var state =
CSharpScript
.RunAsync(@"
795
var state =
CSharpScript
.RunAsync(@"
830
var result =
CSharpScript
.EvaluateAsync<int>(@"
852
Assert.Equal(18,
CSharpScript
.EvaluateAsync<int>("(4 + 5) * 2", ScriptOptions).Result);
853
Assert.Equal(1,
CSharpScript
.EvaluateAsync<long>("6 / (2 * 3)", ScriptOptions).Result);
859
var s =
CSharpScript
.RunAsync(@"
874
var f =
CSharpScript
.EvaluateAsync<Func<int, int>>(@"
890
var result =
CSharpScript
.EvaluateAsync<List<string>>(@"
907
var f =
CSharpScript
.RunAsync("using System;", ScriptOptions).
917
var s =
CSharpScript
.RunAsync(@"
933
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
957
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
984
var result =
CSharpScript
.RunAsync(@"
1004
var result =
CSharpScript
.EvaluateAsync<int>(@"
1015
var result =
CSharpScript
.EvaluateAsync<object[]>(@"
1038
var result1 = await
CSharpScript
.EvaluateAsync<int[]>("new int[] { 1,2,3,4 }", ScriptOptions);
1041
var result2 = await
CSharpScript
.EvaluateAsync<int[]>("new int[] { 1,2,3,4,5 }", ScriptOptions);
1044
var s1 = await
CSharpScript
.RunAsync<int[]>("new int[] { 1,2,3,4,5,6 }", ScriptOptions);
1058
var result =
CSharpScript
.EvaluateAsync("System.Threading.Tasks.Task.FromResult(1)", ScriptOptions).Result;
1068
Assert.Equal(2,
CSharpScript
.EvaluateAsync("await System.Threading.Tasks.Task.FromResult(2)", ScriptOptions).Result);
1077
Assert.Equal(3,
CSharpScript
.EvaluateAsync<int>("0 + await System.Threading.Tasks.Task.FromResult(3)", ScriptOptions).Result);
1083
var task =
CSharpScript
.EvaluateAsync<object>("await System.Threading.Tasks.Task.Run(() => { })", ScriptOptions);
1094
var s0 = await
CSharpScript
.RunAsync(@"
1121
CSharpScript
.RunAsync("int i = 0;", options).
1139
CSharpScript
.Create("int i = 0;", options).
1153
var state = await
CSharpScript
.RunAsync("var x = (false, 4);", ScriptOptions);
1162
var state = await
CSharpScript
.RunAsync("object x = 1;", options: options);
1176
var script =
CSharpScript
.Create(@"
1224
object result =
CSharpScript
.EvaluateAsync($@"
1243
var script =
CSharpScript
.Create(
1263
var script =
CSharpScript
.Create(
1296
var r2 =
CSharpScript
.Create($@"#r ""{fileMain.Path}""", ScriptOptions).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1327
var r2 =
CSharpScript
.Create($@"#r ""{fileMain.Path}""", ScriptOptions).ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1342
var script =
CSharpScript
.Create(@"new C()",
1355
object result =
CSharpScript
.EvaluateAsync(@"
1371
object result =
CSharpScript
.EvaluateAsync("new int[] { 1, 2, 3 }.First()", options).Result;
1382
var s1 =
CSharpScript
.RunAsync("new int[] { 1, 2, 3 }.First()", options);
1395
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1403
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1409
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1415
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1431
Assert.Equal(2,
CSharpScript
.EvaluateAsync<int>("1+1", ScriptOptions).Result);
1433
Assert.Null(
CSharpScript
.EvaluateAsync<string>("null", ScriptOptions).Result);
1437
CSharpScript
.RunAsync<C<int>>("null", ScriptOptions);
1449
var cint =
CSharpScript
.EvaluateAsync<C<int>>("null", options).Result;
1452
Assert.Null(
CSharpScript
.EvaluateAsync<int?>("null", options).Result);
1456
CSharpScript
.RunAsync<int>("null", ScriptOptions);
1469
CSharpScript
.RunAsync<string>("1+1", ScriptOptions);
1484
var value =
CSharpScript
.EvaluateAsync<IEnumerable<Exception>>(@"
1532
var s0 =
CSharpScript
.RunAsync<int>("x + Y + Z()", options: ScriptOptions, globals: c);
1548
var result =
CSharpScript
.EvaluateAsync<string>("G()", options: ScriptOptions, globals: m);
1557
var s0 = await
CSharpScript
.RunAsync<int>("Z()", options: ScriptOptions, globals: c, globalsType: typeof(I));
1574
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("Z()", options: ScriptOptions, globals: c),
1584
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("Z()", options: ScriptOptions, globals: c),
1593
var result =
CSharpScript
.EvaluateAsync<int>("Z()", options: ScriptOptions, globals: c, globalsType: typeof(I));
1600
var s0 =
CSharpScript
.RunAsync("static int goo = StaticField;", options: ScriptOptions, globals: new C());
1619
var s0 =
CSharpScript
.RunAsync("int goo(double a) { return 2; }", options: ScriptOptions, globals: new D());
1631
var r0 =
CSharpScript
.EvaluateAsync<int>("X + Y + Z", options: ScriptOptions, globals: obj);
1635
var r1 =
CSharpScript
.EvaluateAsync<int>("X", options: ScriptOptions, globals: obj);
1642
var scriptCompilation =
CSharpScript
.Create(
1699
var scriptCompilation =
CSharpScript
.Create(
1703
WithReferences(typeof(
CSharpScript
).GetTypeInfo().Assembly),
1764
#r ""{typeof(
CSharpScript
).GetTypeInfo().Assembly.ManifestModule.FullyQualifiedName}""
1767
var scriptCompilation =
CSharpScript
.Create(
1845
var result = await
CSharpScript
.EvaluateAsync<bool>(code, options: ScriptOptions, globalsType: typeof(E), globals: new E());
1865
var script =
CSharpScript
.Create<bool>(code, options: ScriptOptions, globalsType: typeof(F));
1887
var script =
CSharpScript
.Create<bool>(code, options: ScriptOptions, globalsType: typeof(F));
1909
var result = await
CSharpScript
.EvaluateAsync<bool>(code, options: ScriptOptions, globalsType: typeof(F), globals: new F());
1921
var s0 =
CSharpScript
.Create(@"
1944
var s0 =
CSharpScript
.Create(@"
1971
var s0 =
CSharpScript
.Create(@"
1999
var state0 = await
CSharpScript
.RunAsync(@"
2032
var s0 =
CSharpScript
.Create(@"
2066
var s0 =
CSharpScript
.Create(@"
2100
var s0 =
CSharpScript
.Create(@"
2129
CSharpScript
.RunAsync(
ScriptTests.cs (92)
35
var script =
CSharpScript
.Create("1 + 2", ScriptOptions);
42
Assert.Throws<ArgumentNullException>(() =>
CSharpScript
.Create((string)null));
48
var script =
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")), ScriptOptions);
55
Assert.Throws<ArgumentNullException>(() =>
CSharpScript
.Create((Stream)null, ScriptOptions));
61
var state = await
CSharpScript
.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests());
69
var state = await
CSharpScript
.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests());
82
var script =
CSharpScript
.Create("1 + 2", options: ScriptOptions.WithEmitDebugInformation(true));
106
var script =
CSharpScript
.Create("1 + 2", ScriptOptions);
117
var script =
CSharpScript
.Create<int>("X + Y", options: ScriptOptions, globalsType: typeof(Globals));
128
var state = await
CSharpScript
.RunAsync("1 + 2", ScriptOptions);
135
var script =
CSharpScript
.Create("1 + 2", ScriptOptions);
144
var script =
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")), ScriptOptions);
153
var value = await
CSharpScript
.EvaluateAsync("1 + 2", ScriptOptions);
160
var state = await
CSharpScript
.RunAsync("1 + 2", ScriptOptions);
168
CSharpScript
.Create("System.Console.WriteLine(0);", ScriptOptions),
176
var state = await
CSharpScript
.RunAsync(
185
await
CSharpScript
.RunAsync(@"
200
await
CSharpScript
.RunAsync(@"
219
var state =
CSharpScript
.RunAsync(@"if (true)
237
var state =
CSharpScript
.RunAsync(@"if (true)
245
var state =
CSharpScript
.RunAsync(@"System.Console.WriteLine(true) ", options: ScriptOptions, globals: new ScriptTests());
252
var state =
CSharpScript
.RunAsync(@"
266
var state =
CSharpScript
.RunAsync(@"if (e) a = b
286
var state = await
CSharpScript
.RunAsync("X + Y", options: ScriptOptions, globals: new Globals { X = 1, Y = 2 });
293
var script =
CSharpScript
.Create("X + Y", options: ScriptOptions, globalsType: typeof(Globals));
302
var script =
CSharpScript
.Create("X + Y", ScriptOptions);
311
var script =
CSharpScript
.Create("X + Y", options: ScriptOptions, globalsType: typeof(Globals));
320
var script =
CSharpScript
.Create("X + Y", options: ScriptOptions, globalsType: typeof(Globals));
329
var state = await
CSharpScript
.RunAsync("X + Y", options: ScriptOptions, globals: new Globals());
337
var state1 = await
CSharpScript
.RunAsync("X + Y + 1", options: ScriptOptions, globals: new Globals());
338
var state2 = await
CSharpScript
.RunAsync("X + Y + 2", options: ScriptOptions, globals: new Globals());
347
var state = await
CSharpScript
.RunAsync("int X = 100;", ScriptOptions).ContinueWith("X + X");
361
var state = await
CSharpScript
.RunAsync("", ScriptOptions);
388
CSharpScript
.Create(
415
var script =
CSharpScript
.Create("var x = 1;", ScriptOptions);
434
var state = await
CSharpScript
.RunAsync(@"
455
var state1 = await
CSharpScript
.RunAsync("int M(int x) { return x + x; }", ScriptOptions);
471
var state0 = await
CSharpScript
.RunAsync("static int Add(int x, int y) => x + y;", options: ScriptOptions.WithLanguageVersion(LanguageVersion.Preview));
480
var state0 = await
CSharpScript
.RunAsync("class Id<T> { static T Core(T t) => t; public static System.Func<T, T> Get => Core; }", ScriptOptions);
488
var state0 = await
CSharpScript
.RunAsync("class Id { static T Core<T>(T t) => t; public static System.Func<T, T> Get<T>() => Core; }", ScriptOptions);
497
var script =
CSharpScript
.Create<object>($"return {expected};", ScriptOptions);
506
CSharpScript
.Create("System.Console.WriteLine();", ScriptOptions), ""));
512
var script =
CSharpScript
.Create<int>("return await System.Threading.Tasks.Task.FromResult(42);", ScriptOptions);
520
var script =
CSharpScript
.Create(@"
533
var script =
CSharpScript
.Create(@"
543
script =
CSharpScript
.Create(@"
557
var script =
CSharpScript
.Create<int>(@"
567
script =
CSharpScript
.Create<int>(@"
581
var script =
CSharpScript
.Create(@"
591
script =
CSharpScript
.Create(@"
605
var script =
CSharpScript
.Create<IEnumerable<int>>(@"
613
script =
CSharpScript
.Create<IEnumerable<int>>(@"
625
var script =
CSharpScript
.Create<int?>(@"
633
script =
CSharpScript
.Create<int?>(@"
649
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
653
script =
CSharpScript
.Create(@"
672
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
676
script =
CSharpScript
.Create(@"
695
var script =
CSharpScript
.Create("#load \"a.csx\"", options);
699
script =
CSharpScript
.Create(@"
715
var script =
CSharpScript
.Create("#load \"b.csx\"", options);
723
script =
CSharpScript
.Create(@"
733
script =
CSharpScript
.Create(@"
750
var script =
CSharpScript
.Create("#load \"b.csx\"", options);
758
script =
CSharpScript
.Create(@"
768
script =
CSharpScript
.Create(@"
788
var script =
CSharpScript
.Create(@"
796
script =
CSharpScript
.Create(@"
810
var script =
CSharpScript
.Create("return;", ScriptOptions);
814
script =
CSharpScript
.Create(@"
834
var script =
CSharpScript
.Create<int>(@"
848
var script = await
CSharpScript
.RunAsync(code, opts);
862
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "debug.csx");
869
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
876
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
884
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: "debug.csx");
891
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts));
899
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "");
907
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts), line: 1, column: 1, filename: "");
914
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
921
return VerifyStackTraceAsync(() =>
CSharpScript
.Create("throw new System.Exception();", opts));
929
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts), line: 1, column: 1, filename: "");
936
return VerifyStackTraceAsync(() =>
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("throw new System.Exception();")), opts));
944
var script =
CSharpScript
.Create(@"#load ""a.csx""", options);
951
var script =
CSharpScript
.Create(@"string x = default;", ScriptOptions.WithLanguageVersion(LanguageVersion.CSharp7));
964
var script =
CSharpScript
.Create(@"#nullable enable
987
var script =
CSharpScript
.Create(code, ScriptOptions.WithLanguageVersion(LanguageVersion.CSharp8));
1003
await
CSharpScript
.RunAsync(@"var data = notExistentVariable switch { _ => null };", options: ScriptOptions, globals: new ScriptTests());
1025
await
CSharpScript
.RunAsync(@"var data = ""data"" switch { < 5 => null };", options: ScriptOptions, globals: new ScriptTests());
1050
await
CSharpScript
.RunAsync(@"var data = ""test"" switch { _ => armError };", options: ScriptOptions, globals: new ScriptTests());
1069
var script =
CSharpScript
.Create("class partial;", ScriptOptions.WithLanguageVersion(LanguageVersion.Preview))
1089
var script =
CSharpScript
.Create("class partial;", ScriptOptions.WithLanguageVersion(LanguageVersion.CSharp13))
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();