1 instantiation of ScriptState
Microsoft.CodeAnalysis.Scripting (1)
Script.cs (1)
557return 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;"); 72var s0 = await CSharpScript.RunAsync("using System.Diagnostics;"); 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.Default.AddReferences(portableLibRef), assemblyLoader: loader).RunAsync(); 632var s0 = await CSharpScript.RunAsync($@"#r ""{file1.Path}"""); 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}"""); 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}"""); 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}"""); 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}"""); 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}"""); 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}"""); 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}"""); 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.Default.WithReferences(libFile.Path));
Microsoft.CodeAnalysis.CSharp.Scripting.UnitTests (68)
InteractiveSessionTests.cs (38)
621var s0 = await CSharpScript.RunAsync("int x = 1;"); 625var s1 = await s0.ContinueWithAsync("x = 2; x = 10"); 630var s2 = await s1.ContinueWithAsync("int y = 2;"); 634var s3 = await s2.ContinueWithAsync("x + y"); 648var state0 = await CSharpScript.RunAsync("", globals: new HostObjectWithOverrides()); 650var state1 = await state0.ContinueWithAsync<bool>("Equals(null)"); 653var state2 = await state1.ContinueWithAsync<int>("GetHashCode()"); 656var state3 = await state2.ContinueWithAsync<string>("ToString()"); 663var state0 = await CSharpScript.RunAsync("", globals: new object()); 664var state1 = await state0.ContinueWithAsync<bool>(@" 671var state2 = await state1.ContinueWithAsync<string>("ToString()"); 674var state3 = await state2.ContinueWithAsync<bool>("Equals(null)"); 1042var s1 = await CSharpScript.RunAsync<int[]>("new int[] { 1,2,3,4,5,6 }"); 1045var s2 = await s1.ContinueWithAsync<int[]>("new int[] { 1,2,3,4,5,6,7 }"); 1048var s3 = await s2.ContinueWithAsync<int[]>("new int[] { 1,2,3,4,5,6,7,8 }"); 1092var s0 = await CSharpScript.RunAsync(@" 1104var s1 = await s0.ContinueWithAsync("F(async () => await Task.FromResult(4))"); 1107var s2 = await s1.ContinueWithAsync("G(5, async x => await Task.FromResult(x))"); 1118var state = 1136var state = 1151var state = await CSharpScript.RunAsync("var x = (false, 4);"); 1160var state = await CSharpScript.RunAsync("object x = 1;", options: options); 1555var s0 = await CSharpScript.RunAsync<int>("Z()", globals: c, globalsType: typeof(I)); 1563var s1 = await s0.ContinueWithAsync<string>("N"); 1929var state1 = await s1.RunAsync(catchException: e => true); 1933var state2 = await state1.ContinueWithAsync<int>("F()"); 1956var state2 = await s2.RunAsync(catchException: e => true); 1960var state3 = await state2.ContinueWithAsync<int>("F()"); 1984var state3 = await s3.RunAsync(catchException: e => true); 1988var state4 = await state3.ContinueWithAsync<int>("F()"); 1997var state0 = await CSharpScript.RunAsync(@" 2000var state1 = await state0.ContinueWithAsync(@" 2008var state2 = await state1.ContinueWithAsync<int>(@" 2016var state4 = await state2.ContinueWithAsync(@" 2047var state3 = await s3.RunAsync(globals, catchException: e => true, cancellationToken: cancellationSource.Token); 2051var state4 = await state3.ContinueWithAsync<int>("F()"); 2081var state3 = await s3.RunAsync(globals, catchException: e => true, cancellationToken: cancellationSource.Token); 2085var state4 = await state3.ContinueWithAsync<int>("F()");
ScriptTests.cs (30)
62var state = await CSharpScript.RunAsync("1 + 2", globals: new ScriptTests()); 70var state = await CSharpScript.RunAsync("1 + 2", globals: new ScriptTests()); 129var state = await CSharpScript.RunAsync("1 + 2"); 137var state = await script.RunAsync(); 146var state = await script.RunAsync(); 161var state = await CSharpScript.RunAsync("1 + 2"); 168var state = ScriptingTestHelpers.RunScriptWithOutput( 177var state = await CSharpScript.RunAsync( 287var state = await CSharpScript.RunAsync("X + Y", globals: new Globals { X = 1, Y = 2 }); 295var state = await script.RunAsync(new Globals { X = 1, Y = 2 }); 330var state = await CSharpScript.RunAsync("X + Y", globals: new Globals()); 338var state1 = await CSharpScript.RunAsync("X + Y + 1", globals: new Globals()); 339var state2 = await CSharpScript.RunAsync("X + Y + 2", globals: new Globals()); 348var state = await CSharpScript.RunAsync("int X = 100;").ContinueWith("X + X"); 362var state = await CSharpScript.RunAsync(""); 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; }"); 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.Default.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; }"); 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; }"); 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)
71internal readonly ScriptState<object>? ScriptState; 75ScriptState<object>? scriptState, 92internal EvaluationState WithScriptState(ScriptState<object> state) 381var newScriptState = await ExecuteOnUIThreadAsync(script, state.ScriptState, displayResult: true).ConfigureAwait(false); 595var newScriptState = await TryExecuteFileAsync(rspState, initializationScriptPath).ConfigureAwait(false); 693var newScriptState = await TryExecuteFileAsync(state, fullPath).ConfigureAwait(false); 710private async Task<ScriptState<object>?> TryExecuteFileAsync(EvaluationState state, string fullPath) 756private Task<ScriptState<object>> ExecuteOnUIThreadAsync(Script<object> script, ScriptState<object>? state, bool displayResult) 758return (Task<ScriptState<object>>)_invokeOnMainThread((Func<Task<ScriptState<object>>>)(async () => 766var newState = await task.ConfigureAwait(false);
Microsoft.CodeAnalysis.Scripting (15)
Hosting\CommandLine\CommandLineRunner.cs (2)
219ScriptState<object> state = null; 286private void BuildAndRun(Script<object> newScript, InteractiveScriptGlobals globals, ref ScriptState<object> state, ref ScriptOptions options, bool displayResult, CancellationToken cancellationToken)
Script.cs (8)
355=> RunAsync(globals, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 358=> RunFromAsync(previousState, catchException, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); 442public new Task<ScriptState<T>> RunAsync(object globals, CancellationToken cancellationToken) 460public new Task<ScriptState<T>> RunAsync(object globals = null, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 503public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, CancellationToken cancellationToken) 520public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, Func<Exception, bool> catchException = null, CancellationToken cancellationToken = default(CancellationToken)) 533return Task.FromResult((ScriptState<T>)previousState); 548private 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))