Skip to content

Commit 600b134

Browse files
committed
remove DisplayAsync method
1 parent eee3cee commit 600b134

File tree

12 files changed

+30
-33
lines changed

12 files changed

+30
-33
lines changed

src/Microsoft.DotNet.Interactive.ExtensionLab/DataFrameKernelExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async Task CompileStuff(
5555

5656
if (showCode)
5757
{
58-
await context.DisplayAsync(code);
58+
context.Display(code);
5959
}
6060

6161
cSharpKernel.TryGetVariable(variableName, out DataFrame oldFrame);

src/Microsoft.DotNet.Interactive.ExtensionLab/SqlKernel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public virtual async Task HandleAsync(
3636

3737
var results = Execute(dbCommand);
3838

39-
await context.DisplayAsync(results);
39+
context.Display(results);
4040
}
4141

4242
protected abstract DbConnection OpenConnection();

src/Microsoft.DotNet.Interactive.Jupyter/KernelExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private static Command lsmagic(Kernel kernel)
205205
supportedDirectives.Commands.AddRange(
206206
kernel.Directives.Where(d => !d.IsHidden));
207207

208-
await context.DisplayAsync(supportedDirectives);
208+
context.Display(supportedDirectives);
209209

210210
await kernel.VisitSubkernelsAsync(async k =>
211211
{

src/Microsoft.DotNet.Interactive.Tests/DirectiveTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ public async Task OnComplete_can_be_used_to_act_on_completion_of_commands()
172172

173173
kernel.AddDirective(new Command("#!wrap")
174174
{
175-
Handler = CommandHandler.Create(async (KernelInvocationContext c) =>
176-
{
177-
await c.DisplayAsync("hello!");
175+
Handler = CommandHandler.Create((KernelInvocationContext c) =>
176+
{
177+
c.Display("hello!");
178178

179-
c.OnComplete(async context =>
179+
c.OnComplete(context =>
180180
{
181-
await context.DisplayAsync("goodbye!");
181+
context.Display("goodbye!");
182+
183+
return Task.CompletedTask;
182184
});
183185
})
184186
});

src/Microsoft.DotNet.Interactive/Extensions/AssemblyBasedExtensionLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private async Task LoadFromAssembly(
122122
{
123123
var extension = (IKernelExtension) Activator.CreateInstance(extensionType);
124124

125-
var displayed = await context.DisplayAsync(
125+
var displayed = context.Display(
126126
$"Loading kernel extension \"{extensionType.Name}\" from assembly {assemblyFile.FullName}");
127127

128128
try

src/Microsoft.DotNet.Interactive/HtmlKernel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public HtmlKernel() : base(DefaultKernelName)
1818
{
1919
}
2020

21-
public async Task HandleAsync(SubmitCode command, KernelInvocationContext context)
21+
public Task HandleAsync(SubmitCode command, KernelInvocationContext context)
2222
{
23-
await context.DisplayAsync(
23+
context.Display(
2424
new HtmlString(command.Code),
2525
HtmlFormatter.MimeType);
26+
return Task.CompletedTask;
2627
}
2728
}
2829
}

src/Microsoft.DotNet.Interactive/JavaScriptKernel.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ public class JavaScriptKernel :
1515
public JavaScriptKernel() : base(DefaultKernelName)
1616
{
1717
}
18-
public async Task HandleAsync(
18+
public Task HandleAsync(
1919
SubmitCode command,
2020
KernelInvocationContext context)
2121
{
2222
var scriptContent = new ScriptContent(command.Code);
2323

24-
await context.DisplayAsync(scriptContent);
24+
context.Display(scriptContent);
25+
26+
return Task.CompletedTask;
2527
}
2628
}
2729
}

src/Microsoft.DotNet.Interactive/Kernel.Static.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static DisplayedValue display(
2121
object value,
2222
string mimeType = null)
2323
{
24-
return Task.Run(() => KernelInvocationContext.Current.DisplayAsync(value, mimeType)).Result;
24+
return KernelInvocationContext.Current.Display(value, mimeType);
2525
}
2626

2727
public static IHtmlContent HTML(string content) => content.ToHtmlContent();

src/Microsoft.DotNet.Interactive/KernelInvocationContextExtensions.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System;
55
using System.Collections.Generic;
6-
using System.Threading.Tasks;
76
using Microsoft.DotNet.Interactive.Commands;
87
using Microsoft.DotNet.Interactive.Events;
98
using Microsoft.DotNet.Interactive.Formatting;
@@ -12,15 +11,6 @@ namespace Microsoft.DotNet.Interactive
1211
{
1312
public static class KernelInvocationContextExtensions
1413
{
15-
public static Task<DisplayedValue> DisplayAsync(
16-
this KernelInvocationContext context,
17-
object value,
18-
string mimeType = null)
19-
{
20-
DisplayedValue result = Display(context, value, mimeType);
21-
return Task.FromResult(result);
22-
}
23-
2414
public static DisplayedValue Display(
2515
this KernelInvocationContext context,
2616
object value,

src/Microsoft.DotNet.Interactive/KernelSupportsNugetExtensions.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,17 @@ private static Command i()
4242
};
4343
iDirective.Handler = CommandHandler.Create<string, KernelInvocationContext>((source, context) =>
4444
{
45-
var kernel = context.HandlingKernel as ISupportNuget;
46-
kernel.AddRestoreSource(source.Replace("nuget:", ""));
45+
if (context.HandlingKernel is ISupportNuget kernel)
46+
{
47+
kernel.AddRestoreSource(source.Replace("nuget:", ""));
4748

48-
IHtmlContent content = div(
49-
strong("Restore sources"),
50-
ul(kernel.RestoreSources
51-
.Select(s => li(span(s)))));
49+
IHtmlContent content = div(
50+
strong("Restore sources"),
51+
ul(kernel.RestoreSources
52+
.Select(s => li(span(s)))));
5253

53-
context.DisplayAsync(content);
54+
context.Display(content);
55+
}
5456
});
5557
return iDirective;
5658
}

0 commit comments

Comments
 (0)