1 instantiation of ScriptState
Microsoft.CodeAnalysis.Scripting (1)
Script.cs (1)
584return 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)
45var s0 = await CSharpScript.RunAsync("", options); 60var s0 = await CSharpScript.RunAsync("using System.Diagnostics;", ScriptOptions); 72var s0 = await CSharpScript.RunAsync("using System.Diagnostics;", ScriptOptions); 174var state = await script.RunAsync().ContinueWith<IEnumerable<int>>("x", options.WithFilePath(null)); 186var s0 = await CSharpScript.RunAsync<Process>($@" 199var s1 = await s0.ContinueWithAsync<System.Xml.XmlDocument>(@" 207var s2 = await s1.ContinueWithAsync(@" 215var s3 = await s2.ContinueWithAsync<System.Windows.Forms.Form>(@" 501var s0 = await CSharpScript.RunAsync<int>("x", options, new C()); 515var s1 = await s0.ContinueWithAsync($@" 537var s0 = await CSharpScript.Create("new C()", options: ScriptOptions.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync(); 632var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 633var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 634var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 635var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); 636var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); 690var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 691var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 692var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 693var s3 = await s2.ContinueWithAsync($@"var l2 = new Lib2();"); 694var s4 = await s3.ContinueWithAsync($@"l2.libBase.X"); 756var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 757var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1();"); 758var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 824var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 825var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 826var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 892var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 893var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 894var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 960var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 961var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 962var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1028var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1029var s1 = await s0.ContinueWithAsync($@"var l1 = new Lib1().libBase.X;"); 1030var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1096var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}""", ScriptOptions); 1097var s1 = await s0.ContinueWithAsync($@"new Lib1().libBase.X"); 1099var s2 = await s1.ContinueWithAsync($@"#r ""{file2.Path}"""); 1100var s3 = await s2.ContinueWithAsync($@"new Lib2().libBase.X"); 1122var 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)
65var state = await CSharpScript.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests()); 73var state = await CSharpScript.RunAsync("1 + 2", options: ScriptOptions, globals: new ScriptTests()); 132var state = await CSharpScript.RunAsync("1 + 2", ScriptOptions); 140var state = await script.RunAsync(); 149var state = await script.RunAsync(); 164var state = await CSharpScript.RunAsync("1 + 2", ScriptOptions); 171var state = ScriptingTestHelpers.RunScriptWithOutput( 180var state = await CSharpScript.RunAsync( 290var state = await CSharpScript.RunAsync("X + Y", options: ScriptOptions, globals: new Globals { X = 1, Y = 2 }); 298var state = await script.RunAsync(new Globals { X = 1, Y = 2 }); 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); 401var state = await script.RunAsync(globals); 421var s1 = await script.RunAsync(); 430var s3 = await s1.ContinueWithAsync("x"); 438var state = await CSharpScript.RunAsync(@" 459var state1 = await CSharpScript.RunAsync("int M(int x) { return x + x; }", ScriptOptions); 463var state2 = await state1.ContinueWithAsync("int M(int x) { return x * x; } M(5)"); 468var state3 = await state1.ContinueWithAsync("M(5)"); 475var state0 = await CSharpScript.RunAsync("static int Add(int x, int y) => x + y;", options: ScriptOptions.WithLanguageVersion(LanguageVersion.Preview)); 476var state1 = await state0.ContinueWithAsync("System.Func<int, int, int> adder = Add;"); 477var state2 = await state1.ContinueWithAsync("adder(1, 1)"); 484var state0 = await CSharpScript.RunAsync("class Id<T> { static T Core(T t) => t; public static System.Func<T, T> Get => Core; }", ScriptOptions); 485var state1 = await state0.ContinueWithAsync("Id<int>.Get(1)"); 492var state0 = await CSharpScript.RunAsync("class Id { static T Core<T>(T t) => t; public static System.Func<T, T> Get<T>() => Core; }", ScriptOptions); 493var state1 = await state0.ContinueWithAsync("Id.Get<int>()(1)"); 852var 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) 373var newScriptState = await ExecuteOnUIThreadAsync(script, state.ScriptState, displayResult: true).ConfigureAwait(false); 587var newScriptState = await TryExecuteFileAsync(rspState, initializationScriptPath).ConfigureAwait(false); 685var newScriptState = await TryExecuteFileAsync(state, fullPath).ConfigureAwait(false); 702private async Task<ScriptState<object>?> TryExecuteFileAsync(EvaluationState state, string fullPath) 748private Task<ScriptState<object>> ExecuteOnUIThreadAsync(Script<object> script, ScriptState<object>? state, bool displayResult) 750return (Task<ScriptState<object>>)_invokeOnMainThread((Func<Task<ScriptState<object>>>)(async () => 758var newState = await task.ConfigureAwait(false);
Microsoft.CodeAnalysis.Scripting (15)
Hosting\CommandLine\CommandLineRunner.cs (2)
229ScriptState<object>? state = null; 296private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object>? state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken)
Script.cs (8)
382=> RunAsync(globals, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 385=> RunFromAsync(previousState, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 469public new Task<ScriptState<T>> RunAsync(object globals, CancellationToken cancellationToken) 487public new Task<ScriptState<T>> RunAsync(object globals = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 530public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, CancellationToken cancellationToken) 547public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 560return Task.FromResult((ScriptState<T>)previousState); 575private 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)
19internal 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) 23ScriptState<T> result = null; 49public static void ContinueRunScriptWithOutput<T>(Task<ScriptState<T>> scriptState, string code, string expectedOutput) 70internal 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)
46Optional cancellationToken As CancellationToken = Nothing) As Task(Of ScriptState(Of T)) 56Optional cancellationToken As CancellationToken = Nothing) As Task(Of ScriptState(Of Object))