diff --git a/MLS.Agent.Tests/XplotKernelExtensionTests.cs b/MLS.Agent.Tests/XplotKernelExtensionTests.cs index a013411ec..b41402dca 100644 --- a/MLS.Agent.Tests/XplotKernelExtensionTests.cs +++ b/MLS.Agent.Tests/XplotKernelExtensionTests.cs @@ -31,7 +31,7 @@ public async Task When_a_chart_is_returned_the_value_produced_has_html_with_the_ KernelEvents .ValuesOnly() - .OfType() + .OfType() .Should(). ContainSingle(valueProduced => valueProduced.FormattedValues.Any(formattedValue => diff --git a/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs b/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs index cfac60849..cc9c9de75 100644 --- a/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs +++ b/Microsoft.DotNet.Interactive.FSharp/FSharpKernel.fs @@ -29,7 +29,7 @@ type FSharpKernel() = | Ok(Some(value)) -> let value = value.ReflectionValue let formattedValues = FormattedValue.FromObject(value) - context.OnNext(ValueProduced(value, codeSubmission, true, formattedValues)) + context.OnNext(ReturnValueProduced(value, codeSubmission, formattedValues)) | Ok(None) -> () | Error(ex) -> context.OnError(ex) context.OnNext(CodeSubmissionEvaluated(codeSubmission)) diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/ExecuteRequestHandlerTests.cs b/Microsoft.DotNet.Interactive.Jupyter.Tests/ExecuteRequestHandlerTests.cs index afcf1ea0f..9458b829c 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/ExecuteRequestHandlerTests.cs +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/ExecuteRequestHandlerTests.cs @@ -82,7 +82,25 @@ public async Task sends_ExecuteReply_with_error_message_on_CodeSubmissionEvaluat } [Fact] - public async Task sends_ExecuteReply_message_on_ValueProduced() + public async Task sends_DisplayData_message_on_ValueProduced() + { + var kernel = new CSharpKernel(); + + var handler = new ExecuteRequestHandler(kernel); + var request = Message.Create(new ExecuteRequest("Console.WriteLine(2+2);"), null); + await handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus)); + + _serverRecordingSocket.DecodedMessages + .Should().Contain(message => + message.Contains(MessageTypeValues.ExecuteReply)); + + _ioRecordingSocket.DecodedMessages + .Should().Contain(message => + message.Contains(MessageTypeValues.DisplayData)); + } + + [Fact] + public async Task sends_ExecuteReply_message_on_ReturnValueProduced() { var kernel = new CSharpKernel(); diff --git a/Microsoft.DotNet.Interactive.Jupyter.Tests/MagicCommandTests.cs b/Microsoft.DotNet.Interactive.Jupyter.Tests/MagicCommandTests.cs index eb895a5eb..c04b06fbb 100644 --- a/Microsoft.DotNet.Interactive.Jupyter.Tests/MagicCommandTests.cs +++ b/Microsoft.DotNet.Interactive.Jupyter.Tests/MagicCommandTests.cs @@ -44,9 +44,9 @@ public async Task lsmagic_lists_registered_magic_commands() await kernel.SendAsync(new SubmitCode("%lsmagic")); events.Should() - .ContainSingle(e => e is ValueProduced) + .ContainSingle(e => e is Events.DisplayedValueProduced) .Which - .As() + .As() .Value .ToDisplayString("text/html") .Should() @@ -75,7 +75,7 @@ public async Task lsmagic_lists_registered_magic_commands_in_subkernels() await compositeKernel.SendAsync(new SubmitCode("%lsmagic")); - var valueProduceds = events.OfType().ToArray(); + var valueProduceds = events.OfType().ToArray(); valueProduceds[0].Value .ToDisplayString("text/html") @@ -112,7 +112,7 @@ await kernel.SendAsync(new SubmitCode( var formatted = events - .OfType() + .OfType() .SelectMany(v => v.FormattedValues) .ToArray(); @@ -140,7 +140,7 @@ await kernel.SendAsync(new SubmitCode( var formatted = events - .OfType() + .OfType() .SelectMany(v => v.FormattedValues) .ToArray(); diff --git a/Microsoft.DotNet.Interactive.Jupyter/ExecuteRequestHandler.cs b/Microsoft.DotNet.Interactive.Jupyter/ExecuteRequestHandler.cs index 953899e77..748810df8 100644 --- a/Microsoft.DotNet.Interactive.Jupyter/ExecuteRequestHandler.cs +++ b/Microsoft.DotNet.Interactive.Jupyter/ExecuteRequestHandler.cs @@ -56,8 +56,8 @@ protected override void OnKernelEvent(IKernelEvent @event) { switch (@event) { - case ValueProduced valueProduced: - OnValueProduced(valueProduced); + case ValueProducedEventBase valueProductionEvent: + OnValueProductionEvent(valueProductionEvent); break; case CodeSubmissionEvaluated codeSubmissionEvaluated: OnCodeSubmissionEvaluated(codeSubmissionEvaluated); @@ -114,72 +114,69 @@ private void OnCommandFailed(CommandFailed commandFailed) openRequest.Dispose(); } - private void OnValueProduced(ValueProduced valueProduced) + private void SendDisplayData(DisplayData displayData, InflightRequest openRequest) { - if (!InFlightRequests.TryGetValue(valueProduced.Command, out var openRequest)) + if (!openRequest.Request.Silent) + { + // send on io + var executeResultMessage = Message.Create( + displayData, + openRequest.Context.Request.Header); + openRequest.Context.IoPubChannel.Send(executeResultMessage); + } + } + + private void OnValueProductionEvent(ValueProducedEventBase eventBase) + { + if (!InFlightRequests.TryGetValue(eventBase.Command, out var openRequest)) { return; } - try + var transient = CreateTransient(eventBase.ValueId); + + var formattedValues = eventBase + .FormattedValues + .ToDictionary(k => k.MimeType, v => v.Value); + + var value = eventBase.Value; + + CreateDefaultFormattedValueIfEmpty(formattedValues, value); + + DisplayData executeResultData; + + switch (eventBase) { - var transient = CreateTransient(valueProduced.ValueId); - - var formattedValues = valueProduced - .FormattedValues - .ToDictionary(k => k.MimeType, v => v.Value); - - if (formattedValues.Count == 0) - { - formattedValues.Add( - HtmlFormatter.MimeType, - valueProduced.Value.ToDisplayString("text/html")); - } - - var executeResultData = - valueProduced.IsReturnValue - ? new ExecuteResult( - openRequest.ExecutionCount, - transient: transient, - data: formattedValues) - : valueProduced.IsUpdatedValue - ? new UpdateDisplayData( - transient: transient, - data: formattedValues) - : new DisplayData( - transient: transient, - data: formattedValues); - - if (!openRequest.Request.Silent) - { - // send on io - var executeResultMessage = Message.Create( - executeResultData, - openRequest.Context.Request.Header); - openRequest.Context.IoPubChannel.Send(executeResultMessage); - } + case Events.DisplayedValueProduced _: + executeResultData = new DisplayData( + transient: transient, + data: formattedValues); + break; + case ReturnValueProduced _: + executeResultData = new ExecuteResult( + openRequest.ExecutionCount, + transient: transient, + data: formattedValues); + break; + case DisplayedValueUpdated _: + executeResultData = new UpdateDisplayData( + transient: transient, + data: formattedValues); + break; + default: + throw new ArgumentException("Unsupported event type", nameof(eventBase)); } - catch (Exception e) + + SendDisplayData(executeResultData, openRequest); + } + + private static void CreateDefaultFormattedValueIfEmpty(Dictionary formattedValues, object value) + { + if (formattedValues.Count == 0) { - var errorContent = new Error( - eName: "Unhandled Exception", - eValue: $"{e.Message}"); - - if (!openRequest.Request.Silent) - { - // send on io - var error = Message.Create( - errorContent, - openRequest.Context.Request.Header); - openRequest.Context.IoPubChannel.Send(error); - - // send on stderr - var stdErr = new StdErrStream(errorContent.EValue); - var stream = Message.Create( - stdErr, - openRequest.Context.Request.Header); - openRequest.Context.IoPubChannel.Send(stream); - } + formattedValues.Add( + HtmlFormatter.MimeType, + value.ToDisplayString("text/html")); } } diff --git a/Microsoft.DotNet.Interactive.Jupyter/KernelExtensions.cs b/Microsoft.DotNet.Interactive.Jupyter/KernelExtensions.cs index ce79ba1dd..c1300c330 100644 --- a/Microsoft.DotNet.Interactive.Jupyter/KernelExtensions.cs +++ b/Microsoft.DotNet.Interactive.Jupyter/KernelExtensions.cs @@ -42,7 +42,7 @@ private static T UseHtml(this T kernel) .Trim(); - context.OnNext(new ValueProduced( + context.OnNext(new Events.DisplayedValueProduced( htmlContent, context.Command, formattedValues: new[] @@ -106,7 +106,7 @@ private static Command lsmagic() supportedDirectives.Commands.AddRange(context.CurrentKernel.Directives); - context.OnNext(new ValueProduced(supportedDirectives)); + context.OnNext(new Events.DisplayedValueProduced(supportedDirectives)); await context.CurrentKernel.VisitSubkernelsAsync(async k => { @@ -137,7 +137,7 @@ private static Command javascript() scriptContent)) .ToString(); - context.OnNext(new ValueProduced( + context.OnNext(new Events.DisplayedValueProduced( scriptContent, context.Command, formattedValues: new[] diff --git a/Microsoft.DotNet.Interactive/DisplayedValue.cs b/Microsoft.DotNet.Interactive/DisplayedValueProduced.cs similarity index 100% rename from Microsoft.DotNet.Interactive/DisplayedValue.cs rename to Microsoft.DotNet.Interactive/DisplayedValueProduced.cs diff --git a/Microsoft.DotNet.Interactive/Events/DisplayedValueProduced.cs b/Microsoft.DotNet.Interactive/Events/DisplayedValueProduced.cs new file mode 100644 index 000000000..5379ec4bd --- /dev/null +++ b/Microsoft.DotNet.Interactive/Events/DisplayedValueProduced.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using Microsoft.DotNet.Interactive.Commands; + +namespace Microsoft.DotNet.Interactive.Events +{ + public class DisplayedValueProduced : ValueProducedEventBase + { + public DisplayedValueProduced( + object value, + IKernelCommand command = null, + IReadOnlyCollection formattedValues = null, + string valueId = null) : base(value, command,formattedValues, valueId) + { + + } + } +} \ No newline at end of file diff --git a/Microsoft.DotNet.Interactive/Events/DisplayedValueUpdated.cs b/Microsoft.DotNet.Interactive/Events/DisplayedValueUpdated.cs new file mode 100644 index 000000000..e442e6054 --- /dev/null +++ b/Microsoft.DotNet.Interactive/Events/DisplayedValueUpdated.cs @@ -0,0 +1,25 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using Microsoft.DotNet.Interactive.Commands; + +namespace Microsoft.DotNet.Interactive.Events +{ + public class DisplayedValueUpdated : ValueProducedEventBase + { + public DisplayedValueUpdated( + object value, + string valueId, + IKernelCommand command = null, + IReadOnlyCollection formattedValues = null) : base(value,command,formattedValues,valueId) + { + if (string.IsNullOrWhiteSpace(valueId)) + { + throw new ArgumentException("Value cannot be null or whitespace.", nameof(valueId)); + } + + } + } +} \ No newline at end of file diff --git a/Microsoft.DotNet.Interactive/Events/ReturnValueProduced.cs b/Microsoft.DotNet.Interactive/Events/ReturnValueProduced.cs new file mode 100644 index 000000000..2cbe7143c --- /dev/null +++ b/Microsoft.DotNet.Interactive/Events/ReturnValueProduced.cs @@ -0,0 +1,21 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using Microsoft.DotNet.Interactive.Commands; + +namespace Microsoft.DotNet.Interactive.Events +{ + public class ReturnValueProduced : ValueProducedEventBase + { + public ReturnValueProduced( + object value, + IKernelCommand command = null, + IReadOnlyCollection formattedValues = null, + string valueId = null) : base(value,command, formattedValues, valueId) + { + + } + } +} \ No newline at end of file diff --git a/Microsoft.DotNet.Interactive/Events/ValueProduced.cs b/Microsoft.DotNet.Interactive/Events/ValueProducedEventBase.cs similarity index 52% rename from Microsoft.DotNet.Interactive/Events/ValueProduced.cs rename to Microsoft.DotNet.Interactive/Events/ValueProducedEventBase.cs index 3f38c3400..5408b847d 100644 --- a/Microsoft.DotNet.Interactive/Events/ValueProduced.cs +++ b/Microsoft.DotNet.Interactive/Events/ValueProducedEventBase.cs @@ -7,40 +7,23 @@ namespace Microsoft.DotNet.Interactive.Events { - public class ValueProduced : KernelEventBase + public abstract class ValueProducedEventBase : KernelEventBase { - public ValueProduced( + protected ValueProducedEventBase( object value, IKernelCommand command = null, - bool isReturnValue = false, IReadOnlyCollection formattedValues = null, - string valueId = null, - bool isUpdatedValue = false) : base(command) + string valueId = null) : base(command) { - if (isUpdatedValue && valueId == null) - { - throw new ArgumentException($"{nameof(isUpdatedValue)} cannot be true with a null {nameof(valueId)}", nameof(valueId)); - } - Value = value; - IsReturnValue = isReturnValue; FormattedValues = formattedValues ?? Array.Empty(); ValueId = valueId; - IsUpdatedValue = valueId switch - { - null => false, - _ => isUpdatedValue - }; } public object Value { get; } - public bool IsReturnValue { get; } - public IReadOnlyCollection FormattedValues { get; } public string ValueId { get; } - - public bool IsUpdatedValue { get; } } } \ No newline at end of file diff --git a/Microsoft.DotNet.Interactive/KernelBase.cs b/Microsoft.DotNet.Interactive/KernelBase.cs index 99f6943d2..147a75153 100644 --- a/Microsoft.DotNet.Interactive/KernelBase.cs +++ b/Microsoft.DotNet.Interactive/KernelBase.cs @@ -179,7 +179,7 @@ private async Task HandleDisplayValue( displayValue.Handler = invocationContext => { invocationContext.OnNext( - new ValueProduced( + new Events.DisplayedValueProduced( displayValue.FormattedValue, displayValue, formattedValues: new[] { displayValue.FormattedValue }, @@ -201,12 +201,12 @@ private async Task HandleUpdateDisplayValue( displayedValue.Handler = invocationContext => { invocationContext.OnNext( - new ValueProduced( + new DisplayedValueUpdated( displayedValue.FormattedValue, - displayedValue, - formattedValues: new[] { displayedValue.FormattedValue }, valueId: displayedValue.ValueId, - isUpdatedValue: true)); + command: displayedValue, + formattedValues: new[] { displayedValue.FormattedValue } + )); invocationContext.OnCompleted(); diff --git a/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs b/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs index 1892079c1..cdd3b01d5 100644 --- a/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs +++ b/WorkspaceServer.Tests/Kernel/CSharpKernelRenderingTests.cs @@ -7,6 +7,7 @@ using FluentAssertions.Extensions; using System.Linq; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.DotNet.Interactive; using Microsoft.DotNet.Interactive.Commands; using Microsoft.DotNet.Interactive.Events; @@ -38,7 +39,7 @@ public async Task Default_rendering_is_HTML( var valueProduced = await result .KernelEvents - .OfType() + .OfType() .Timeout(5.Seconds()) .FirstAsync(); @@ -65,7 +66,7 @@ public async Task String_is_rendered_as_plain_text( var valueProduced = await result .KernelEvents - .OfType() + .OfType() .Timeout(5.Seconds()) .FirstAsync(); @@ -89,7 +90,7 @@ public async Task Display_helper_can_be_called_without_specifying_class_name() var formatted = KernelEvents .ValuesOnly() - .OfType() + .OfType() .SelectMany(v => v.FormattedValues); formatted @@ -106,19 +107,24 @@ public async Task Displayed_value_can_be_updated() await kernel.SendAsync(new SubmitCode("var d = display(b(\"hello\")); d.Update(b(\"world\"));")); - var formatted = - KernelEvents - .OrderBy(e => e.Timestamp) - .ValuesOnly() - .OfType() - .SelectMany(v => v.FormattedValues); - formatted + KernelEvents + .OrderBy(e => e.Timestamp) + .ValuesOnly() + .OfType() + .SelectMany(v => v.FormattedValues) .Should() .ContainSingle(v => v.MimeType == "text/html" && - v.Value.ToString().Contains("hello")) - .And + v.Value.ToString().Contains("hello")); + + + KernelEvents + .OrderBy(e => e.Timestamp) + .ValuesOnly() + .OfType() + .SelectMany(v => v.FormattedValues) + .Should() .ContainSingle(v => v.MimeType == "text/html" && v.Value.ToString().Contains("world")); @@ -131,24 +137,15 @@ public async Task Value_display_and_update_are_in_right_order() await kernel.SendAsync(new SubmitCode("var d = display(b(\"hello\")); d.Update(b(\"world\"));")); - var formatted = + var valueEvents = KernelEvents .OrderBy(e => e.Timestamp) - .ValuesOnly() - .OfType() - .SelectMany(v => v.FormattedValues).ToList(); + .Where(e => e.Value is DisplayedValueProduced || e.Value is DisplayedValueUpdated) + .Select(e => e.Value) + .ToList(); - var firstValue = formatted.Select((v, i) => new {v, i}).First(e => e.v.MimeType == "text/html" && - e.v.Value.ToString() - .Contains("hello")).i; - - var updatedValue = formatted.Select((v, i) => new { v, i }).First(e => e.v.MimeType == "text/html" && - e.v.Value.ToString() - .Contains("world")).i; - - updatedValue - .Should() - .BeGreaterOrEqualTo(firstValue); + valueEvents.First().Should().BeOfType(); + valueEvents.Last().Should().BeOfType(); } [Fact] @@ -163,7 +160,7 @@ public async Task Javascript_helper_emits_string_as_content_within_a_script_elem var formatted = KernelEvents .ValuesOnly() - .OfType() + .OfType() .SelectMany(v => v.FormattedValues) .ToArray(); diff --git a/WorkspaceServer.Tests/Kernel/CSharpKernelTests.cs b/WorkspaceServer.Tests/Kernel/CSharpKernelTests.cs index 414970148..2117aeab3 100644 --- a/WorkspaceServer.Tests/Kernel/CSharpKernelTests.cs +++ b/WorkspaceServer.Tests/Kernel/CSharpKernelTests.cs @@ -36,7 +36,7 @@ public async Task it_returns_the_result_of_a_non_null_expression() await kernel.SendAsync(new SubmitCode("123")); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Last() .Value .Should() @@ -64,7 +64,7 @@ public async Task when_it_throws_exception_after_a_value_was_produced_then_only_ var lastValueProducedPosition = KernelEvents .Select((e, pos) => (e.Value, pos)) - .Last(t => t.Value is ValueProduced).pos; + .Last(t => t.Value is ReturnValueProduced).pos; lastValueProducedPosition .Should() @@ -118,7 +118,7 @@ public async Task it_cannot_execute_incomplete_submissions() await kernel.SendAsync(new SubmitCode("var a = 12")); KernelEvents.Should() - .NotContain(e => e.Value is ValueProduced); + .NotContain(e => e.Value is DisplayedValueProduced); KernelEvents .Should() @@ -145,7 +145,7 @@ public async Task expression_evaluated_to_null_has_result_with_null_value() await kernel.SendAsync(new SubmitCode("null")); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Last() .Value .Should() @@ -161,7 +161,7 @@ public async Task it_does_not_return_a_result_for_a_statement() KernelEvents .Should() - .NotContain(e => e.Value is ValueProduced); + .NotContain(e => e.Value is DisplayedValueProduced); } [Fact] @@ -174,7 +174,7 @@ public async Task it_aggregates_multiple_submissions() await kernel.SendAsync(new SubmitCode("x.Max()")); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Last() .Value .Should() @@ -194,12 +194,12 @@ public async Task it_produces_values_when_executing_Console_output() KernelEvents .ValuesOnly() - .OfType() + .OfType() .Should() .BeEquivalentTo( - new ValueProduced("value one", kernelCommand, false, new[] { new FormattedValue("text/plain", "value one"), }), - new ValueProduced("value two", kernelCommand, false, new[] { new FormattedValue("text/plain", "value two"), }), - new ValueProduced("value three", kernelCommand, false, new[] { new FormattedValue("text/plain", "value three"), })); + new DisplayedValueProduced("value one", kernelCommand, new[] { new FormattedValue("text/plain", "value one"), }), + new DisplayedValueProduced("value two", kernelCommand, new[] { new FormattedValue("text/plain", "value two"), }), + new DisplayedValueProduced("value three", kernelCommand, new[] { new FormattedValue("text/plain", "value three"), })); } [Fact] @@ -215,11 +215,15 @@ public async Task it_produces_a_final_value_if_the_code_expression_evaluates() await kernel.SendAsync(kernelCommand); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Should() - .HaveCount(4) - .And - .ContainSingle(e => e.IsReturnValue); + .HaveCount(3); + + KernelEvents + .ValuesOnly() + .OfType() + .Last() + .Value.Should().Be(5); } @@ -235,7 +239,7 @@ public async Task the_output_is_asynchronous() 5", "csharp"); await kernel.SendAsync(kernelCommand); var events = KernelEvents - .Where(e => e.Value is ValueProduced).ToArray(); + .Where(e => e.Value is DisplayedValueProduced).ToArray(); var diff = events[1].Timestamp - events[0].Timestamp; diff.Should().BeCloseTo(1.Seconds(), precision: 200); @@ -250,7 +254,7 @@ public async Task it_supports_csharp_8() await kernel.SendAsync(new SubmitCode("text[^5..^0]")); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Last() .Value .Should() @@ -277,10 +281,10 @@ await kernel.SendAsync( KernelEvents.ValuesOnly() .Should() - .ContainSingle(e => e is ValueProduced); + .ContainSingle(e => e is ReturnValueProduced); KernelEvents.ValuesOnly() - .OfType() + .OfType() .Single() .Value .Should() diff --git a/WorkspaceServer.Tests/Kernel/FSharpKernelTests.cs b/WorkspaceServer.Tests/Kernel/FSharpKernelTests.cs index b6a0f4e2f..e1e75fd91 100644 --- a/WorkspaceServer.Tests/Kernel/FSharpKernelTests.cs +++ b/WorkspaceServer.Tests/Kernel/FSharpKernelTests.cs @@ -57,7 +57,7 @@ await kernel.SendAsync(new SubmitCode(@" private void AssertLastValue(object value) { KernelEvents.ValuesOnly() - .OfType() + .OfType() .Last() .Value .Should() diff --git a/WorkspaceServer.Tests/Kernel/KernelClientTests.cs b/WorkspaceServer.Tests/Kernel/KernelClientTests.cs index a2b28fcbd..03423bd38 100644 --- a/WorkspaceServer.Tests/Kernel/KernelClientTests.cs +++ b/WorkspaceServer.Tests/Kernel/KernelClientTests.cs @@ -50,7 +50,7 @@ public async Task Kernel_can_be_interacted_using_kernel_client() var events = text.Split(Environment.NewLine) .Select(JsonConvert.DeserializeObject); - events.Should().Contain(e => e.EventType == "ValueProduced"); + events.Should().Contain(e => e.EventType == "ReturnValueProduced"); } } } \ No newline at end of file diff --git a/WorkspaceServer/Kernel/CSharpKernel.cs b/WorkspaceServer/Kernel/CSharpKernel.cs index dcb51c35c..573116334 100644 --- a/WorkspaceServer/Kernel/CSharpKernel.cs +++ b/WorkspaceServer/Kernel/CSharpKernel.cs @@ -173,10 +173,9 @@ private async Task HandleSubmitCode( { var formattedValues = FormattedValue.FromObject(_scriptState.ReturnValue); context.OnNext( - new ValueProduced( + new ReturnValueProduced( _scriptState.ReturnValue, submitCode, - true, formattedValues)); } @@ -198,10 +197,9 @@ private void PublishOutput( }; context.OnNext( - new ValueProduced( + new DisplayedValueProduced( output, command, - false, formattedValues)); }