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;");
72
var s0 = await
CSharpScript
.RunAsync("using System.Diagnostics;");
91
CSharpScript
.RunAsync("using System;").
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");
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.Default.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync();
580
var script =
CSharpScript
.Create<int>(
632
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
690
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
756
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
824
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
892
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
960
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
1028
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
1096
var s0 = await
CSharpScript
.RunAsync($@"#r ""{file1.Path}""");
1122
var s0 = await
CSharpScript
.RunAsync("C c;", ScriptOptions.Default.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (205)
InteractiveSessionReferencesTests.cs (3)
40
var s0 =
CSharpScript
.Create($@"
98
var s0 =
CSharpScript
.Create($@"
137
var s0 =
CSharpScript
.Create($@"
InteractiveSessionTests.cs (112)
44
var script =
CSharpScript
.Create(@"
65
var script =
CSharpScript
.Create(@"
86
var script =
CSharpScript
.Create(@"
103
var script =
CSharpScript
.Create(@"
133
var script =
CSharpScript
.Create(@"
153
var script =
CSharpScript
.Create(@"
172
var script =
CSharpScript
.Create(@"
187
var script =
CSharpScript
.Create(@"
217
var script =
CSharpScript
.Create(@"
233
var script =
CSharpScript
.Create(@"
274
Type c =
CSharpScript
.EvaluateAsync<Type>(source).Result;
300
var script =
CSharpScript
.Create<int>(@"
327
var script =
CSharpScript
.Create(@"
363
var script =
CSharpScript
.Create(@"
388
var script =
CSharpScript
.Create(
403
var script =
CSharpScript
.Create("var x = 1;").ContinueWith("x");
411
CSharpScript
.Create("using InteractiveFixtures.C;", ScriptOptions.Default.AddReferences(HostAssembly)).
422
var s0 =
CSharpScript
.RunAsync("", ScriptOptions.Default.AddReferences(HostAssembly));
446
var script =
CSharpScript
.Create(@"
464
var state =
CSharpScript
.RunAsync("Environment.ProcessorCount", options);
475
var state1 =
CSharpScript
.RunAsync("internal class C1 { } protected int X; 1");
517
var state =
CSharpScript
.RunAsync("");
531
CSharpScript
.Create("using System;").
539
CSharpScript
.Create("int Environment = 1;").
551
CSharpScript
.Create("int System = 1;").
571
CSharpScript
.RunAsync("System", globals: new C1()).
581
CSharpScript
.RunAsync("using System;", globals: new C1()).
592
CSharpScript
.RunAsync("int System = 2;", globals: new C1()).
602
var s0 =
CSharpScript
.Create("int x = 1;");
621
var s0 = await
CSharpScript
.RunAsync("int x = 1;");
648
var state0 = await
CSharpScript
.RunAsync("", globals: new HostObjectWithOverrides());
663
var state0 = await
CSharpScript
.RunAsync("", globals: new object());
681
var state0 =
CSharpScript
.RunAsync("");
715
var script =
CSharpScript
.Create(@"
732
CSharpScript
.EvaluateAsync(@"
741
var s0 =
CSharpScript
.Create(@"
760
var state =
CSharpScript
.RunAsync(@"
793
var state =
CSharpScript
.RunAsync(@"
828
var result =
CSharpScript
.EvaluateAsync<int>(@"
850
Assert.Equal(18,
CSharpScript
.EvaluateAsync<int>("(4 + 5) * 2").Result);
851
Assert.Equal(1,
CSharpScript
.EvaluateAsync<long>("6 / (2 * 3)").Result);
857
var s =
CSharpScript
.RunAsync(@"
872
var f =
CSharpScript
.EvaluateAsync<Func<int, int>>(@"
888
var result =
CSharpScript
.EvaluateAsync<List<string>>(@"
905
var f =
CSharpScript
.RunAsync("using System;").
915
var s =
CSharpScript
.RunAsync(@"
931
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
955
var result =
CSharpScript
.EvaluateAsync<List<int>>(@"
982
var result =
CSharpScript
.RunAsync(@"
1002
var result =
CSharpScript
.EvaluateAsync<int>(@"
1013
var result =
CSharpScript
.EvaluateAsync<object[]>(@"
1036
var result1 = await
CSharpScript
.EvaluateAsync<int[]>("new int[] { 1,2,3,4 }");
1039
var result2 = await
CSharpScript
.EvaluateAsync<int[]>("new int[] { 1,2,3,4,5 }");
1042
var s1 = await
CSharpScript
.RunAsync<int[]>("new int[] { 1,2,3,4,5,6 }");
1056
var result =
CSharpScript
.EvaluateAsync("System.Threading.Tasks.Task.FromResult(1)").Result;
1066
Assert.Equal(2,
CSharpScript
.EvaluateAsync("await System.Threading.Tasks.Task.FromResult(2)").Result);
1075
Assert.Equal(3,
CSharpScript
.EvaluateAsync<int>("0 + await System.Threading.Tasks.Task.FromResult(3)").Result);
1081
var task =
CSharpScript
.EvaluateAsync<object>("await System.Threading.Tasks.Task.Run(() => { })");
1092
var s0 = await
CSharpScript
.RunAsync(@"
1119
CSharpScript
.RunAsync("int i = 0;", options).
1137
CSharpScript
.Create("int i = 0;", options).
1151
var state = await
CSharpScript
.RunAsync("var x = (false, 4);");
1160
var state = await
CSharpScript
.RunAsync("object x = 1;", options: options);
1174
var script =
CSharpScript
.Create(@"
1222
object result =
CSharpScript
.EvaluateAsync($@"
1241
var script =
CSharpScript
.Create(
1261
var script =
CSharpScript
.Create(
1294
var r2 =
CSharpScript
.Create($@"#r ""{fileMain.Path}""").ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1325
var r2 =
CSharpScript
.Create($@"#r ""{fileMain.Path}""").ContinueWith($@"M.X.F").RunAsync().Result.ReturnValue;
1340
var script =
CSharpScript
.Create(@"new C()",
1353
object result =
CSharpScript
.EvaluateAsync(@"
1369
object result =
CSharpScript
.EvaluateAsync("new int[] { 1, 2, 3 }.First()", options).Result;
1380
var s1 =
CSharpScript
.RunAsync("new int[] { 1, 2, 3 }.First()", options);
1393
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1401
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1407
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1413
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("1", options),
1429
Assert.Equal(2,
CSharpScript
.EvaluateAsync<int>("1+1").Result);
1431
Assert.Null(
CSharpScript
.EvaluateAsync<string>("null").Result);
1435
CSharpScript
.RunAsync<C<int>>("null");
1447
var cint =
CSharpScript
.EvaluateAsync<C<int>>("null", options).Result;
1450
Assert.Null(
CSharpScript
.EvaluateAsync<int?>("null", options).Result);
1454
CSharpScript
.RunAsync<int>("null");
1467
CSharpScript
.RunAsync<string>("1+1");
1482
var value =
CSharpScript
.EvaluateAsync<IEnumerable<Exception>>(@"
1530
var s0 =
CSharpScript
.RunAsync<int>("x + Y + Z()", globals: c);
1546
var result =
CSharpScript
.EvaluateAsync<string>("G()", globals: m);
1555
var s0 = await
CSharpScript
.RunAsync<int>("Z()", globals: c, globalsType: typeof(I));
1572
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("Z()", globals: c),
1582
ScriptingTestHelpers.AssertCompilationError(() =>
CSharpScript
.EvaluateAsync("Z()", globals: c),
1591
var result =
CSharpScript
.EvaluateAsync<int>("Z()", globals: c, globalsType: typeof(I));
1598
var s0 =
CSharpScript
.RunAsync("static int goo = StaticField;", globals: new C());
1617
var s0 =
CSharpScript
.RunAsync("int goo(double a) { return 2; }", globals: new D());
1629
var r0 =
CSharpScript
.EvaluateAsync<int>("X + Y + Z", globals: obj);
1633
var r1 =
CSharpScript
.EvaluateAsync<int>("X", globals: obj);
1640
var scriptCompilation =
CSharpScript
.Create(
1697
var scriptCompilation =
CSharpScript
.Create(
1701
WithReferences(typeof(
CSharpScript
).GetTypeInfo().Assembly),
1762
#r ""{typeof(
CSharpScript
).GetTypeInfo().Assembly.ManifestModule.FullyQualifiedName}""
1765
var scriptCompilation =
CSharpScript
.Create(
1843
var result = await
CSharpScript
.EvaluateAsync<bool>(code, globalsType: typeof(E), globals: new E());
1863
var script =
CSharpScript
.Create<bool>(code, globalsType: typeof(F));
1885
var script =
CSharpScript
.Create<bool>(code, globalsType: typeof(F));
1907
var result = await
CSharpScript
.EvaluateAsync<bool>(code, globalsType: typeof(F), globals: new F());
1919
var s0 =
CSharpScript
.Create(@"
1942
var s0 =
CSharpScript
.Create(@"
1969
var s0 =
CSharpScript
.Create(@"
1997
var state0 = await
CSharpScript
.RunAsync(@"
2030
var s0 =
CSharpScript
.Create(@"
2064
var s0 =
CSharpScript
.Create(@"
2098
var s0 =
CSharpScript
.Create(@"
2127
CSharpScript
.RunAsync(
ScriptTests.cs (90)
36
var script =
CSharpScript
.Create("1 + 2");
43
Assert.Throws<ArgumentNullException>(() =>
CSharpScript
.Create((string)null));
49
var script =
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")));
56
Assert.Throws<ArgumentNullException>(() =>
CSharpScript
.Create((Stream)null));
62
var state = await
CSharpScript
.RunAsync("1 + 2", globals: new ScriptTests());
70
var state = await
CSharpScript
.RunAsync("1 + 2", globals: new ScriptTests());
83
var script =
CSharpScript
.Create("1 + 2", options: ScriptOptions.Default.WithEmitDebugInformation(true));
107
var script =
CSharpScript
.Create("1 + 2");
118
var script =
CSharpScript
.Create<int>("X + Y", globalsType: typeof(Globals));
129
var state = await
CSharpScript
.RunAsync("1 + 2");
136
var script =
CSharpScript
.Create("1 + 2");
145
var script =
CSharpScript
.Create(new MemoryStream(Encoding.UTF8.GetBytes("1 + 2")));
154
var value = await
CSharpScript
.EvaluateAsync("1 + 2");
161
var state = await
CSharpScript
.RunAsync("1 + 2");
169
CSharpScript
.Create("System.Console.WriteLine(0);"),
177
var state = await
CSharpScript
.RunAsync(
186
await
CSharpScript
.RunAsync(@"
201
await
CSharpScript
.RunAsync(@"
220
var state =
CSharpScript
.RunAsync(@"if (true)
238
var state =
CSharpScript
.RunAsync(@"if (true)
246
var state =
CSharpScript
.RunAsync(@"System.Console.WriteLine(true) ", globals: new ScriptTests());
253
var state =
CSharpScript
.RunAsync(@"
267
var state =
CSharpScript
.RunAsync(@"if (e) a = b
287
var state = await
CSharpScript
.RunAsync("X + Y", globals: new Globals { X = 1, Y = 2 });
294
var script =
CSharpScript
.Create("X + Y", globalsType: typeof(Globals));
303
var script =
CSharpScript
.Create("X + Y");
312
var script =
CSharpScript
.Create("X + Y", globalsType: typeof(Globals));
321
var script =
CSharpScript
.Create("X + Y", globalsType: typeof(Globals));
330
var state = await
CSharpScript
.RunAsync("X + Y", globals: new Globals());
338
var state1 = await
CSharpScript
.RunAsync("X + Y + 1", globals: new Globals());
339
var state2 = await
CSharpScript
.RunAsync("X + Y + 2", globals: new Globals());
348
var state = await
CSharpScript
.RunAsync("int X = 100;").ContinueWith("X + X");
362
var state = await
CSharpScript
.RunAsync("");
389
CSharpScript
.Create(
415
var script =
CSharpScript
.Create("var x = 1;");
434
var state = await
CSharpScript
.RunAsync(@"
455
var state1 = await
CSharpScript
.RunAsync("int M(int x) { return x + x; }");
471
var state0 = await
CSharpScript
.RunAsync("static int Add(int x, int y) => x + y;", options: ScriptOptions.Default.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; }");
488
var state0 = await
CSharpScript
.RunAsync("class Id { static T Core<T>(T t) => t; public static System.Func<T, T> Get<T>() => Core; }");
497
var script =
CSharpScript
.Create<object>($"return {expected};");
506
CSharpScript
.Create("System.Console.WriteLine();"), ""));
512
var script =
CSharpScript
.Create<int>("return await System.Threading.Tasks.Task.FromResult(42);");
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;");
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.Default.WithLanguageVersion(LanguageVersion.CSharp7));
964
var script =
CSharpScript
.Create(@"#nullable enable
987
var script =
CSharpScript
.Create(code, ScriptOptions.Default.WithLanguageVersion(LanguageVersion.CSharp8));
1003
await
CSharpScript
.RunAsync(@"var data = notExistentVariable switch { _ => null };", globals: new ScriptTests());
1025
await
CSharpScript
.RunAsync(@"var data = ""data"" switch { < 5 => null };", globals: new ScriptTests());
1050
await
CSharpScript
.RunAsync(@"var data = ""test"" switch { _ => armError };", 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();