提交 a38b04d1 编写于 作者: T Tomas Matousek

Rename ContinueAsync to RunFromAsync and make it public

上级 df14d0fd
...@@ -810,7 +810,7 @@ private async Task<ScriptState<object>> ExecuteOnUIThread(Script<object> script, ...@@ -810,7 +810,7 @@ private async Task<ScriptState<object>> ExecuteOnUIThread(Script<object> script,
{ {
var task = (stateOpt == null) ? var task = (stateOpt == null) ?
script.RunAsync(_globals, CancellationToken.None) : script.RunAsync(_globals, CancellationToken.None) :
script.ContinueAsync(stateOpt, CancellationToken.None); script.RunFromAsync(stateOpt, CancellationToken.None);
return await task.ConfigureAwait(false); return await task.ConfigureAwait(false);
} }
catch (FileLoadException e) when (e.InnerException is InteractiveAssemblyLoaderException) catch (FileLoadException e) when (e.InnerException is InteractiveAssemblyLoaderException)
......
...@@ -185,7 +185,7 @@ public async Task ContinueAsync_Error1() ...@@ -185,7 +185,7 @@ public async Task ContinueAsync_Error1()
{ {
var state = await CSharpScript.RunAsync("X + Y", globals: new Globals()); var state = await CSharpScript.RunAsync("X + Y", globals: new Globals());
await Assert.ThrowsAsync<ArgumentNullException>("previousState", () => state.Script.ContinueAsync(null)); await Assert.ThrowsAsync<ArgumentNullException>("previousState", () => state.Script.RunFromAsync(null));
} }
[Fact] [Fact]
...@@ -194,7 +194,7 @@ public async Task ContinueAsync_Error2() ...@@ -194,7 +194,7 @@ public async Task ContinueAsync_Error2()
var state1 = await CSharpScript.RunAsync("X + Y + 1", globals: new Globals()); var state1 = await CSharpScript.RunAsync("X + Y + 1", globals: new Globals());
var state2 = await CSharpScript.RunAsync("X + Y + 2", globals: new Globals()); var state2 = await CSharpScript.RunAsync("X + Y + 2", globals: new Globals());
await Assert.ThrowsAsync<ArgumentException>("previousState", () => state1.Script.ContinueAsync(state2)); await Assert.ThrowsAsync<ArgumentException>("previousState", () => state1.Script.RunFromAsync(state2));
} }
[Fact] [Fact]
......
...@@ -274,7 +274,7 @@ private bool TryBuildAndRun(Script<object> newScript, InteractiveScriptGlobals g ...@@ -274,7 +274,7 @@ private bool TryBuildAndRun(Script<object> newScript, InteractiveScriptGlobals g
{ {
var task = (state == null) ? var task = (state == null) ?
newScript.RunAsync(globals, cancellationToken) : newScript.RunAsync(globals, cancellationToken) :
newScript.ContinueAsync(state, cancellationToken); newScript.RunFromAsync(state, cancellationToken);
state = task.GetAwaiter().GetResult(); state = task.GetAwaiter().GetResult();
} }
......
...@@ -15,6 +15,8 @@ Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.MemberDisplayFormat.get -> ...@@ -15,6 +15,8 @@ Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.MemberDisplayFormat.get ->
Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.MemberDisplayFormat.set -> void Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.MemberDisplayFormat.set -> void
Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.NumberRadix.get -> int Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.NumberRadix.get -> int
Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.NumberRadix.set -> void Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.NumberRadix.set -> void
Microsoft.CodeAnalysis.Scripting.Script.RunFromAsync(Microsoft.CodeAnalysis.Scripting.ScriptState previousState, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Scripting.ScriptState>
Microsoft.CodeAnalysis.Scripting.Script<T>.RunFromAsync(Microsoft.CodeAnalysis.Scripting.ScriptState previousState, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task<Microsoft.CodeAnalysis.Scripting.ScriptState<T>>
abstract Microsoft.CodeAnalysis.Scripting.Hosting.ObjectFormatter.FormatObject(object obj, Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions options) -> string abstract Microsoft.CodeAnalysis.Scripting.Hosting.ObjectFormatter.FormatObject(object obj, Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions options) -> string
abstract Microsoft.CodeAnalysis.Scripting.Hosting.ObjectFormatter.FormatException(System.Exception e) -> string abstract Microsoft.CodeAnalysis.Scripting.Hosting.ObjectFormatter.FormatException(System.Exception e) -> string
virtual Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.IsValidRadix(int radix) -> bool virtual Microsoft.CodeAnalysis.Scripting.Hosting.PrintOptions.IsValidRadix(int radix) -> bool
\ No newline at end of file
...@@ -142,17 +142,17 @@ public Compilation GetCompilation() ...@@ -142,17 +142,17 @@ public Compilation GetCompilation()
internal abstract Task<ScriptState> CommonRunAsync(object globals, CancellationToken cancellationToken); internal abstract Task<ScriptState> CommonRunAsync(object globals, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Continue script execution from the specified state. /// Run the script from the specified state.
/// </summary> /// </summary>
/// <param name="previousState"> /// <param name="previousState">
/// Previous state of the script execution. /// Previous state of the script execution.
/// </param> /// </param>
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A <see cref="ScriptState"/> that represents the state after running the script, including all declared variables and return value.</returns> /// <returns>A <see cref="ScriptState"/> that represents the state after running the script, including all declared variables and return value.</returns>
internal Task<ScriptState> ContinueAsync(ScriptState previousState, CancellationToken cancellationToken = default(CancellationToken)) => public Task<ScriptState> RunFromAsync(ScriptState previousState, CancellationToken cancellationToken = default(CancellationToken)) =>
CommonContinueAsync(previousState, cancellationToken); CommonRunFromAsync(previousState, cancellationToken);
internal abstract Task<ScriptState> CommonContinueAsync(ScriptState previousState, CancellationToken cancellationToken); internal abstract Task<ScriptState> CommonRunFromAsync(ScriptState previousState, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Forces the script through the compilation step. /// Forces the script through the compilation step.
...@@ -285,8 +285,8 @@ internal override ImmutableArray<Diagnostic> CommonCompile(CancellationToken can ...@@ -285,8 +285,8 @@ internal override ImmutableArray<Diagnostic> CommonCompile(CancellationToken can
internal override Task<ScriptState> CommonRunAsync(object globals, CancellationToken cancellationToken) => internal override Task<ScriptState> CommonRunAsync(object globals, CancellationToken cancellationToken) =>
RunAsync(globals, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); RunAsync(globals, cancellationToken).CastAsync<ScriptState<T>, ScriptState>();
internal override Task<ScriptState> CommonContinueAsync(ScriptState previousState, CancellationToken cancellationToken) => internal override Task<ScriptState> CommonRunFromAsync(ScriptState previousState, CancellationToken cancellationToken) =>
ContinueAsync(previousState, cancellationToken).CastAsync<ScriptState<T>, ScriptState>(); RunFromAsync(previousState, cancellationToken).CastAsync<ScriptState<T>, ScriptState>();
/// <exception cref="CompilationErrorException">Compilation has errors.</exception> /// <exception cref="CompilationErrorException">Compilation has errors.</exception>
private Func<object[], Task<T>> GetExecutor(CancellationToken cancellationToken) private Func<object[], Task<T>> GetExecutor(CancellationToken cancellationToken)
...@@ -404,7 +404,7 @@ public ScriptRunner<T> CreateDelegate(CancellationToken cancellationToken = defa ...@@ -404,7 +404,7 @@ public ScriptRunner<T> CreateDelegate(CancellationToken cancellationToken = defa
} }
/// <summary> /// <summary>
/// Continue script execution from the specified state. /// Run the script from the specified state.
/// </summary> /// </summary>
/// <param name="previousState"> /// <param name="previousState">
/// Previous state of the script execution. /// Previous state of the script execution.
...@@ -413,7 +413,7 @@ public ScriptRunner<T> CreateDelegate(CancellationToken cancellationToken = defa ...@@ -413,7 +413,7 @@ public ScriptRunner<T> CreateDelegate(CancellationToken cancellationToken = defa
/// <returns>A <see cref="ScriptState"/> that represents the state after running the script, including all declared variables and return value.</returns> /// <returns>A <see cref="ScriptState"/> that represents the state after running the script, including all declared variables and return value.</returns>
/// <exception cref="ArgumentNullException"><paramref name="previousState"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="previousState"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="previousState"/> is not a previous execution state of this script.</exception> /// <exception cref="ArgumentException"><paramref name="previousState"/> is not a previous execution state of this script.</exception>
internal new Task<ScriptState<T>> ContinueAsync(ScriptState previousState, CancellationToken cancellationToken = default(CancellationToken)) public new Task<ScriptState<T>> RunFromAsync(ScriptState previousState, CancellationToken cancellationToken = default(CancellationToken))
{ {
// The following validation and executor construction may throw; // The following validation and executor construction may throw;
// do so synchronously so that the exception is not wrapped in the task. // do so synchronously so that the exception is not wrapped in the task.
......
...@@ -124,7 +124,7 @@ public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions op ...@@ -124,7 +124,7 @@ public Task<ScriptState<object>> ContinueWithAsync(string code, ScriptOptions op
public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) public Task<ScriptState<TResult>> ContinueWithAsync<TResult>(string code, ScriptOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return Script.ContinueWith<TResult>(code, options).ContinueAsync(this, cancellationToken); return Script.ContinueWith<TResult>(code, options).RunFromAsync(this, cancellationToken);
} }
// How do we resolve overloads? We should use the language semantics. // How do we resolve overloads? We should use the language semantics.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册