这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions DotNetTry.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Expand Down Expand Up @@ -34,10 +35,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MLS.WasmCodeRunner", "WasmC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MLS.WasmCodeRunner.Tests", "WasmCodeRunner.Tests\MLS.WasmCodeRunner.Tests.csproj", "{AAEF5063-5D4C-4CA7-8E22-0DAE1ADBBCD1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Try.Jupyter", "Microsoft.DotNet.Try.Jupyter\Microsoft.DotNet.Try.Jupyter.csproj", "{DDBAB171-7BA2-4B0F-8606-7CF21B969804}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Try.Jupyter.Tests", "Microsoft.DotNet.Try.Jupyter.Tests\Microsoft.DotNet.Try.Jupyter.Tests.csproj", "{614B2E7B-7B05-4023-9C6E-CE708EB1673F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Try.Markdown", "Microsoft.DotNet.Try.Markdown\Microsoft.DotNet.Try.Markdown.csproj", "{B70584C1-41A3-4DB3-9C49-799DFF57A3FC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Try.Markdown.Tests", "Microsoft.DotNet.Try.Markdown.Tests\Microsoft.DotNet.Try.Markdown.Tests.csproj", "{F2FEA069-3121-4AB3-8835-F4EF6FCBFA18}"
Expand All @@ -54,11 +51,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.ProjectTem
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpWorkspaceShim", "FSharpWorkspaceShim\FSharpWorkspaceShim.fsproj", "{9128FCED-2A19-4502-BCEE-BE1BAB6882EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotIntegrationTests", "NotIntegrationTests\NotIntegrationTests.csproj", "{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotIntegrationTests", "NotIntegrationTests\NotIntegrationTests.csproj", "{EA6DDD48-941D-43C6-BAC1-07CF24F4C792}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Rendering", "Microsoft.DotNet.Interactive.Rendering\Microsoft.DotNet.Interactive.Rendering.csproj", "{FBEA5F71-23F5-4412-A936-9B8E6E228968}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Rendering.Tests", "Microsoft.DotNet.Interactive.Rendering.Tests\Microsoft.DotNet.Interactive.Rendering.Tests.csproj", "{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Jupyter.Tests", "Microsoft.DotNet.Interactive.Jupyter.Tests\Microsoft.DotNet.Interactive.Jupyter.Tests.csproj", "{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Jupyter", "Microsoft.DotNet.Interactive.Jupyter\Microsoft.DotNet.Interactive.Jupyter.csproj", "{113A4166-5734-4F6E-B609-D6CF42679399}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -121,14 +123,6 @@ Global
{AAEF5063-5D4C-4CA7-8E22-0DAE1ADBBCD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAEF5063-5D4C-4CA7-8E22-0DAE1ADBBCD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAEF5063-5D4C-4CA7-8E22-0DAE1ADBBCD1}.Release|Any CPU.Build.0 = Release|Any CPU
{DDBAB171-7BA2-4B0F-8606-7CF21B969804}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDBAB171-7BA2-4B0F-8606-7CF21B969804}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDBAB171-7BA2-4B0F-8606-7CF21B969804}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDBAB171-7BA2-4B0F-8606-7CF21B969804}.Release|Any CPU.Build.0 = Release|Any CPU
{614B2E7B-7B05-4023-9C6E-CE708EB1673F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{614B2E7B-7B05-4023-9C6E-CE708EB1673F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{614B2E7B-7B05-4023-9C6E-CE708EB1673F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{614B2E7B-7B05-4023-9C6E-CE708EB1673F}.Release|Any CPU.Build.0 = Release|Any CPU
{B70584C1-41A3-4DB3-9C49-799DFF57A3FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B70584C1-41A3-4DB3-9C49-799DFF57A3FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B70584C1-41A3-4DB3-9C49-799DFF57A3FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -173,6 +167,14 @@ Global
{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218}.Release|Any CPU.Build.0 = Release|Any CPU
{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5}.Release|Any CPU.Build.0 = Release|Any CPU
{113A4166-5734-4F6E-B609-D6CF42679399}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{113A4166-5734-4F6E-B609-D6CF42679399}.Debug|Any CPU.Build.0 = Debug|Any CPU
{113A4166-5734-4F6E-B609-D6CF42679399}.Release|Any CPU.ActiveCfg = Release|Any CPU
{113A4166-5734-4F6E-B609-D6CF42679399}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -192,8 +194,6 @@ Global
{F228EC10-315A-41CF-A51E-FC8369552632} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{9DAE862E-C8AE-452B-B27E-C6DEB1403E81} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{AAEF5063-5D4C-4CA7-8E22-0DAE1ADBBCD1} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{DDBAB171-7BA2-4B0F-8606-7CF21B969804} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{614B2E7B-7B05-4023-9C6E-CE708EB1673F} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{B70584C1-41A3-4DB3-9C49-799DFF57A3FC} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{F2FEA069-3121-4AB3-8835-F4EF6FCBFA18} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{7EAD5482-90CC-4252-AF91-553A4B81D8E0} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
Expand All @@ -204,6 +204,8 @@ Global
{9128FCED-2A19-4502-BCEE-BE1BAB6882EB} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
{EA6DDD48-941D-43C6-BAC1-07CF24F4C792} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{B4B9DC70-6BA2-4BC1-A780-7FCEBDB1D218} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{91902AAC-F4E9-4648-AC6B-4E4A722D3CC5} = {8192FEAD-BCE6-4E62-97E5-2E9EA884BD71}
{113A4166-5734-4F6E-B609-D6CF42679399} = {6EE8F484-DFA2-4F0F-939F-400CE78DFAC2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D6CD99BA-B16B-4570-8910-225CBDFFA3AD}
Expand Down
2 changes: 1 addition & 1 deletion MLS.Agent/CommandLine/CommandLineParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Threading.Tasks;
using Clockwise;
using Microsoft.AspNetCore.Hosting;
using Microsoft.DotNet.Try.Jupyter;
using Microsoft.DotNet.Interactive.Jupyter;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MLS.Agent.Markdown;
Expand Down
4 changes: 2 additions & 2 deletions MLS.Agent/MLS.Agent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@
<Import Project="AssemblyInfo.props" Condition="Exists('AssemblyInfo.props')" />
</ImportGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Interactive.Jupyter\Microsoft.DotNet.Interactive.Jupyter.csproj" />
<ProjectReference Include="..\Microsoft.DotNet.Try.Markdown\Microsoft.DotNet.Try.Markdown.csproj" />
<ProjectReference Include="..\Microsoft.DotNet.Try.Project\Microsoft.DotNet.Try.Project.csproj" />
<ProjectReference Include="..\Microsoft.DotNet.Try.Protocol.ClientApi\Microsoft.DotNet.Try.Protocol.ClientApi.csproj" />
<ProjectReference Include="..\MLS.Agent.Tools\MLS.Agent.Tools.csproj" />
<ProjectReference Include="..\MLS.Blazor\MLS.Blazor.csproj" />
<ProjectReference Include="..\Microsoft.DotNet.Try.Jupyter\Microsoft.DotNet.Try.Jupyter.csproj" />
<ProjectReference Include="..\MLS.Repositories\MLS.Repositories.csproj" />
<ProjectReference Include="..\WorkspaceServer\WorkspaceServer.csproj" />
</ItemGroup>
Expand All @@ -125,7 +125,7 @@

<Target Name="GatherInputs" Condition="'$(NCrunch)' != '1' And '$(BuildingInsideVisualStudio)' != 'true'">
<ConvertToAbsolutePath Paths="$(MSBuildThisFileDirectory)">
<Output TaskParameter="AbsolutePaths" PropertyName="AbsoluteOutputPath"/>
<Output TaskParameter="AbsolutePaths" PropertyName="AbsoluteOutputPath" />
</ConvertToAbsolutePath>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion MLS.Agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using Microsoft.DotNet.Try.Jupyter;
using Microsoft.DotNet.Interactive.Jupyter;
using static Pocket.Logger<MLS.Agent.Program>;
using SerilogLoggerConfiguration = Serilog.LoggerConfiguration;
using MLS.Agent.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.DotNet.Try.Jupyter.Protocol;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using WorkspaceServer.Kernel;
using Xunit;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
public class CompleteRequestHandlerTests
{
Expand All @@ -29,13 +29,26 @@ public CompleteRequestHandlerTests()
}

[Fact]
public void cannot_handle_requests_that_are_not_executeRequest()
public void cannot_handle_requests_that_are_not_CompleteRequest()
{
var kernel = new CSharpRepl();
var handler = new CompleteRequestHandler(kernel);
var request = Message.Create(new DisplayData(), null);
Func<Task> messageHandling = () => handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));
messageHandling.Should().ThrowExactly<InvalidOperationException>();
}

[Fact]
public async Task send_completeReply_on_CompleteRequest()
{
var kernel = new CSharpRepl();
var handler = new CompleteRequestHandler(kernel);
var request = Message.Create(new CompleteRequest("System.Console.", 15 ), null);
await handler.Handle(new JupyterRequestContext(_serverChannel, _ioPubChannel, request, _kernelStatus));

_serverRecordingSocket.DecodedMessages
.Should().Contain(message =>
message.Contains(MessageTypeValues.CompleteReply));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.DotNet.Try.Jupyter.Protocol;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using WorkspaceServer.Kernel;
using Xunit;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
public class ExecuteRequestHandlerTests
{
Expand All @@ -29,7 +29,7 @@ public ExecuteRequestHandlerTests()
}

[Fact]
public void cannot_handle_requests_that_are_not_executeRequest()
public void cannot_handle_requests_that_are_not_ExecuteRequest()
{
var kernel = new CSharpRepl();
var handler = new ExecuteRequestHandler(kernel);
Expand All @@ -48,7 +48,7 @@ public async Task handles_executeRequest()
}

[Fact]
public async Task sends_ExecuteReply_message_on_codeSubmissionEvaluated()
public async Task sends_ExecuteReply_message_on_CodeSubmissionEvaluated()
{
var kernel = new CSharpRepl();

Expand All @@ -62,7 +62,7 @@ public async Task sends_ExecuteReply_message_on_codeSubmissionEvaluated()
}

[Fact]
public async Task sends_executeReply_with_error_message_on_codeSubmissionEvaluated()
public async Task sends_ExecuteReply_with_error_message_on_CodeSubmissionEvaluated()
{
var kernel = new CSharpRepl();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using FluentAssertions;
using Microsoft.DotNet.Try.Jupyter.Protocol;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using Newtonsoft.Json;
using Xunit;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
public class HistorySerializationTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
using System;
using System.Collections.Generic;
using Assent;
using Microsoft.DotNet.Try.Jupyter.Protocol;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using Xunit;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
public class JupyterMessageContractTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
class KernelStatus : IRequestHandlerStatus
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="System.Reactive" Version="4.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.DotNet.Try.Jupyter\Microsoft.DotNet.Try.Jupyter.csproj" />
<ProjectReference Include="..\Microsoft.DotNet.Interactive.Jupyter\Microsoft.DotNet.Interactive.Jupyter.csproj" />
<ProjectReference Include="..\WorkspaceServer\WorkspaceServer.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using NetMQ;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
internal class RecordingSocket : IOutgoingSocket
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using NetMQ;

namespace Microsoft.DotNet.Try.Jupyter.Tests
namespace Microsoft.DotNet.Interactive.Jupyter.Tests
{
internal class TextSocket : IOutgoingSocket
{
Expand Down
103 changes: 103 additions & 0 deletions Microsoft.DotNet.Interactive.Jupyter/CompleteRequestHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// 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.Concurrent;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Jupyter.Protocol;
using WorkspaceServer.Kernel;

namespace Microsoft.DotNet.Interactive.Jupyter
{
public class CompleteRequestHandler: RequestHandlerBase<CompleteRequest>
{
private static readonly Regex _lastToken = new Regex(@"(?<lastToken>\S+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline);


public CompleteRequestHandler(IKernel kernel) : base(kernel)
{

}

public async Task Handle(JupyterRequestContext context)
{
var completeRequest = GetJupyterRequest(context);

context.RequestHandlerStatus.SetAsBusy();

var command = new RequestCompletion(completeRequest.Code, completeRequest.CursorPosition);

var openRequest = new InflightRequest(context, completeRequest, 0, null);

InFlightRequests[command] = openRequest;

var kernelResult = await Kernel.SendAsync(command);
openRequest.AddDisposable(kernelResult.KernelEvents.Subscribe(OnKernelResultEvent));

}

void OnKernelResultEvent(IKernelEvent value)
{
switch (value)
{
case CompletionRequestCompleted completionRequestCompleted:
OnCompletionRequestCompleted(completionRequestCompleted, InFlightRequests);
break;
case CompletionRequestReceived _:
break;
default:
throw new NotSupportedException();
}
}

private static void OnCompletionRequestCompleted(CompletionRequestCompleted completionRequestCompleted, ConcurrentDictionary<IKernelCommand, InflightRequest> openRequests)
{
openRequests.TryGetValue(completionRequestCompleted.Command, out var openRequest);
if (openRequest == null)
{
return;
}

var pos = ComputeReplacementStartPosition(openRequest.Request.Code, openRequest.Request.CursorPosition);
var reply = new CompleteReply(pos, openRequest.Request.CursorPosition, matches: completionRequestCompleted.CompletionList.Select(e => e.InsertText).ToList());

var completeReply = Message.CreateResponse(reply, openRequest.Context.Request);
openRequest.Context.ServerChannel.Send(completeReply);
openRequest.Context.RequestHandlerStatus.SetAsIdle();
openRequest.Dispose();

}

private static int ComputeReplacementStartPosition(string code, int cursorPosition)
{
var pos = cursorPosition;

if (pos > 0)
{
var codeToCursor = code.Substring(0, pos);
var match = _lastToken.Match(codeToCursor);
if (match.Success)
{
var token = match.Groups["lastToken"];
if (token.Success)
{
var lastDotPosition = token.Value.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase);
if (lastDotPosition >= 0)
{
pos = token.Index + lastDotPosition + 1;
}
else
{
pos = token.Index;
}
}
}

}

return pos;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.IO;
using Newtonsoft.Json;

namespace Microsoft.DotNet.Try.Jupyter
namespace Microsoft.DotNet.Interactive.Jupyter
{
public class ConnectionInformation
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.

namespace Microsoft.DotNet.Try.Jupyter
namespace Microsoft.DotNet.Interactive.Jupyter
{
public static class Constants
{
Expand Down
Loading