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