1 instantiation of ScriptState
Microsoft.CodeAnalysis.Scripting (1)
Script.cs (1)
583return new ScriptState<T>(executionState, this, result, exceptionOpt?.Value);
152 references to ScriptState
Microsoft.CodeAnalysis.CSharp.Scripting (2)
CSharpScript.cs (2)
98public static Task<ScriptState<T>> RunAsync<T>(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken)) 112public static Task<ScriptState<object>> RunAsync(string code, ScriptOptions options = null, object globals = null, Type globalsType = null, CancellationToken cancellationToken = default(CancellationToken))
Microsoft.CodeAnalysis.CSharp.Scripting.Desktop.UnitTests (41)
InteractiveSessionReferencesTests.cs (41)
43var s0 = await CSharpScript.RunAsync("", options); 58var s0 = await CSharpScript.RunAsync("using System.Diagnostics;", ScriptOptions); 70var s0 = await CSharpScript.RunAsync("using System.Diagnostics;", ScriptOptions); 172var state = await script.RunAsync().ContinueWith<IEnumerable<int>>("x", options.WithFilePath(null)); 184var s0 = await CSharpScript.RunAsync<Process>($@" 197var s1 = await s0.ContinueWithAsync<System.Xml.XmlDocument>(@" 205var s2 = await s1.ContinueWithAsync(@" 213var s3 = await s2.ContinueWithAsync<System.Windows.Forms.Form>(@" 499var s0 = await CSharpScript.RunAsync<int>("x", options, new C()); 513var s1 = await s0.ContinueWithAsync($@" 535var s0 = await CSharpScript.Create("new C()", options: ScriptOptions.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync(); 630var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 631var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 632var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 633var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); 634var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); 688var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 689var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 690var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 691var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); 692var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); 754var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 755var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 756var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 822var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 823var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 824var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 890var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 891var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 892var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 958var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 959var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 960var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1026var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1027var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1().libBase.X;"); 1028var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1094var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1095var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 1097var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1098var s3 = await s2.ContinueWithAsync($@"new Lib2().libBase.X"); 1120var s0 = await CSharpScript.RunAsync("C c;", ScriptOptions.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (68)
InteractiveSessionTests.cs (38)
622var s0 = await CSharpScript.RunAsync("int x = 1;", ScriptOptions); 626var s1 = await s0.ContinueWithAsync("x = 2; x = 10"); 631var s2 = await s1.ContinueWithAsync("int y = 2;"); 635var s3 = await s2.ContinueWithAsync("x + y"); 649var state0 = await CSharpScript.RunAsync("", options: ScriptOptions, globals: new HostObjectWithOverrides()); 651var state1 = await state0.ContinueWithAsync<bool>("Equals(null)"); 654var state2 = await state1.ContinueWithAsync<int>("GetHashCode()"); 657var state3 = await state2.ContinueWithAsync<string>("ToString()"); 664var state0 = await CSharpScript.RunAsync("", options: ScriptOptions, globals: new object()); 665var state1 = await state0.ContinueWithAsync<bool>(@" 672var state2 = await state1.ContinueWithAsync<string>("ToString()"); 675var state3 = await state2.ContinueWithAsync<bool>("Equals(null)"); 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); 1093var s0 = await CSharpScript.RunAsync(@" 1105var s1 = await s0.ContinueWithAsync("F(async () => await Task.FromResult(4))"); 1108var s2 = await s1.ContinueWithAsync("G(5, async x => await Task.FromResult(x))"); 1119var state = 1137var state = 1152var state = await CSharpScript.RunAsync("var x = (false, 4);", ScriptOptions); 1161var state = await CSharpScript.RunAsync("object x = 1;", options: options); 1556var s0 = await CSharpScript.RunAsync<int>("Z()", options: ScriptOptions, globals: c, globalsType: typeof(I)); 1564var s1 = await s0.ContinueWithAsync<string>("N"); 1930var state1 = await s1.RunAsync(catchException: e => true); 1934var state2 = await state1.ContinueWithAsync<int>("F()"); 1957var state2 = await s2.RunAsync(catchException: e => true); 1961var state3 = await state2.ContinueWithAsync<int>("F()"); 1985var state3 = await s3.RunAsync(catchException: e => true); 1989var state4 = await state3.ContinueWithAsync<int>("F()"); 1998var state0 = await CSharpScript.RunAsync(@" 2001var state1 = await state0.ContinueWithAsync(@" 2009var state2 = await state1.ContinueWithAsync<int>(@" 2017var state4 = await state2.ContinueWithAsync(@" 2048var state3 = await s3.RunAsync(globals, catchException: e => true, cancellationToken: cancellationSource.Token); 2052var state4 = await state3.ContinueWithAsync<int>("F()"); 2082var state3 = await s3.RunAsync(globals, catchException: e => true, cancellationToken: cancellationSource.Token); 2086var state4 = await state3.ContinueWithAsync<int>("F()");
ScriptTests.cs (30)
61var state = await CSharpScript.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests()); 69var state = await CSharpScript.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests()); 128var state = await CSharpScript.RunAsync("1 + 2", ScriptOptions); 136var state = await script.RunAsync(); 145var state = await script.RunAsync(); 160var state = await CSharpScript.RunAsync("1 + 2", ScriptOptions); 167var state = ScriptingTestHelpers.RunScriptWithOutput( 176var state = await CSharpScript.RunAsync( 286var state = await CSharpScript.RunAsync("X + Y", options: ScriptOptions, globals: new Globals { X = 1, Y = 2 }); 294var state = await script.RunAsync(new Globals { X = 1, Y = 2 }); 329var state = await CSharpScript.RunAsync("X + Y", options: ScriptOptions, globals: new Globals()); 337var state1 = await CSharpScript.RunAsync("X + Y + 1", options: ScriptOptions, globals: new Globals()); 338var state2 = await CSharpScript.RunAsync("X + Y + 2", options: ScriptOptions, globals: new Globals()); 347var state = await CSharpScript.RunAsync("int X = 100;", ScriptOptions).ContinueWith("X + X"); 361var state = await CSharpScript.RunAsync("", ScriptOptions); 397var state = await script.RunAsync(globals); 417var s1 = await script.RunAsync(); 426var s3 = await s1.ContinueWithAsync("x"); 434var state = await CSharpScript.RunAsync(@" 455var state1 = await CSharpScript.RunAsync("int M(int x) { return x + x; }", ScriptOptions); 459var state2 = await state1.ContinueWithAsync("int M(int x) { return x * x; } M(5)"); 464var state3 = await state1.ContinueWithAsync("M(5)"); 471var state0 = await CSharpScript.RunAsync("static int Add(int x, int y) => x + y;", options: ScriptOptions.WithLanguageVersion(LanguageVersion.Preview)); 472var state1 = await state0.ContinueWithAsync("System.Func<int, int, int> adder = Add;"); 473var state2 = await state1.ContinueWithAsync("adder(1, 1)"); 480var state0 = await CSharpScript.RunAsync("class Id<T> { static T Core(T t) => t; public static System.Func<T, T> Get => Core; }", ScriptOptions); 481var state1 = await state0.ContinueWithAsync("Id<int>.Get(1)"); 488var state0 = await CSharpScript.RunAsync("class Id { static T Core<T>(T t) => t; public static System.Func<T, T> Get<T>() => Core; }", ScriptOptions); 489var state1 = await state0.ContinueWithAsync("Id.Get<int>()(1)"); 848var script = await CSharpScript.RunAsync(code, opts);
Microsoft.CodeAnalysis.InteractiveHost (12)
Interactive\Core\InteractiveHost.Service.cs (12)
69internal readonly ScriptState<object>? ScriptState; 73ScriptState<object>? scriptState, 90internal EvaluationState WithScriptState(ScriptState<object> state) 375var newScriptState = await ExecuteOnUIThreadAsync(script, state.ScriptState, displayResult: true).ConfigureAwait(false); 589var newScriptState = await TryExecuteFileAsync(rspState, initializationScriptPath).ConfigureAwait(false); 687var newScriptState = await TryExecuteFileAsync(state, fullPath).ConfigureAwait(false); 704private async Task<ScriptState<object>?> TryExecuteFileAsync(EvaluationState state, string fullPath) 750private Task<ScriptState<object>> ExecuteOnUIThreadAsync(Script<object> script, ScriptState<object>? state, bool displayResult) 752return (Task<ScriptState<object>>)_invokeOnMainThread((Func<Task<ScriptState<object>>>)(async () => 760var newState = await task.ConfigureAwait(false);
Microsoft.CodeAnalysis.Scripting (15)
Hosting\CommandLine\CommandLineRunner.cs (2)
227ScriptState<object>? state = null; 294private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object>? state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken)
Script.cs (8)
381=> RunAsync(globals, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 384=> RunFromAsync(previousState, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 468public new Task<ScriptState<T>> RunAsync(object globals, CancellationToken cancellationToken) 486public new Task<ScriptState<T>> RunAsync(object globals = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 529public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, CancellationToken cancellationToken) 546public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 559return Task.FromResult((ScriptState<T>)previousState); 574private async Task<ScriptState<T>> RunSubmissionsAsync(
ScriptState.cs (4)
142public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions options, CancellationToken cancellationToken) 156public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions options = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 166public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options, CancellationToken cancellationToken) 180public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken))
Utilities\TaskExtensions.cs (1)
18internal static async Task<T> GetEvaluationResultAsync<T>(this Task<ScriptState<T>> task)
Microsoft.CodeAnalysis.Scripting.TestUtilities (12)
ScriptingTestHelpers.cs (4)
19public static ScriptState<T> RunScriptWithOutput<T>(Script<T> script, string expectedOutput) 21ScriptState<T> result = null; 45public static void ContinueRunScriptWithOutput<T>(Task<ScriptState<T>> scriptState, string code, string expectedOutput) 64internal static void AssertCompilationError<T>(Task<ScriptState<T>> state, string code, params DiagnosticDescription[] expectedDiagnostics)
ScriptTaskExtensions.cs (8)
15public static async Task<ScriptState<object>> ContinueWith(this Task<ScriptState> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 20public static async Task<ScriptState<object>> ContinueWith(this Task<ScriptState<object>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 25public static async Task<ScriptState<T>> ContinueWith<T>(this Task<ScriptState> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 30public static async Task<ScriptState<T>> ContinueWith<T>(this Task<ScriptState<object>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) 35public static async Task<ScriptState<object>> ContinueWith<S>(this Task<ScriptState<S>> task, string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
Microsoft.CodeAnalysis.VisualBasic.Scripting (2)
VisualBasicScript.vb (2)
45Optional cancellationToken As CancellationToken = Nothing) As Task(Of ScriptState(Of T)) 55Optional cancellationToken As CancellationToken = Nothing) As Task(Of ScriptState(Of Object))