Skip to content

Commit

Permalink
New magic command parser (dotnet#3563)
Browse files Browse the repository at this point in the history
* cleanup

* rename lower-level parsing classes for reuse

* it builds

* wip

* wip

* cleanup

* directive options and arguments

* diagnostics for unknown magics and options

* basic subcommand support

* renames and cleanup

* initial parsing of inline JSON

* more code reorganization, start on directive serializability

* finish removing named vs unnamed parameter distinction

* support for serializing directives to JSON

* cleanup

* inherited and implicit parameters, JSON improvements

* limit subcommand nesting to only one level

* SubmissionParserTests passing

* DirectiveTests passing

* InputsWithinMagicCommandsTests passing

* VariableSharingWithinMagicCommandsTests passing

* refactoring, WIP on #!set and #!share

* WIP on submission splitting refactor

* #!share using new parser

* Custom kernel specifiers, start on #!value

* variable sharing improvements

* fix #!value --from-file and --from-url

* rename lower-level parsing classes for reuse

* it builds

* wip

* wip

* cleanup

* directive options and arguments

* diagnostics for unknown magics and options

* basic subcommand support

* renames and cleanup

* initial parsing of inline JSON

* more code reorganization, start on directive serializability

* finish removing named vs unnamed parameter distinction

* support for serializing directives to JSON

* cleanup

* inherited and implicit parameters, JSON improvements

* limit subcommand nesting to only one level

* SubmissionParserTests passing

* DirectiveTests passing

* InputsWithinMagicCommandsTests passing

* VariableSharingWithinMagicCommandsTests passing

* refactoring, WIP on #!set and #!share

* WIP on submission splitting refactor

* #!share using new parser

* Custom kernel specifiers, start on #!value

* variable sharing improvements

* #!value --from-file and --from-url

* fix more KeyValueStoreKernel tests

* merge cleanup

* fix a few tests accounting for empty DiagnosticsProduced event

* more test fixes

* fix some warnings

* fix warnings, move PackageManagement and Journey to net8.0

* fix warnings and IVT

* wire up #r nuget to new parser

* wire up #i nuget to new parser

* package loading fixes

* explicitly set split command's SchedulingScope to parent's

* update #!import to use new parser

* get #!connect scenarios building using new API

* Update #!mermaid to new parser

* rename incorrectly named local function

* allow directive subcommands to contain "-" and "_"

* named pipe connections working, stio refactored but failing

* add support for arrays in inline JSON in directives

* fix stdio kernel connector

* fix SQLite directive parsing

* remove ChooseKernelDirective and derived types

* update #!who and #!whos to use the new parser

* SQL and KQL connector fixes

* remove System.CommandLine reference from several projects

* improve subcommand parameter parsing

* basic completion support for magic commands

* completion improvements

* improve magic command completions to accommodate more kernel test cases

* magic command completion fixes

* update contract tests

* a few more completion fixes

* update Polyglot Notebooks for contract changes

* fill missing magic command description

* make SubmitCode.parameters optional in TypeScript contract

* more contract test updates

* fix ambiguous call error

* more stdio and jupyter fixes

* make a few more tests pass

* fix ExtensionLab magic commands

* fix another test using #!connect stdio

* fix Journey magic commands

* support custom validations without (internal-only) custom parsing

* contract updates

* fix occasional accidental reparenting; some code cleanup

* allow events to be accessed after KernelInvocationContext is disposed

* pass defaultKernelName per parse

* combinatorial testing and bug fixes

This includes some refactoring to reuse the combinatorial test utilities from the HTTP parser

* update API baseline

* more completion fixes

* a little completion code cleanup

* fix magic command completions in Polyglot Notebooks
  • Loading branch information
jonsequitur authored Jul 17, 2024
1 parent 99446ae commit 5d87547
Show file tree
Hide file tree
Showing 356 changed files with 10,824 additions and 7,490 deletions.
10 changes: 4 additions & 6 deletions NotebookTestScript.dib
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ console.log(jsKernel.name);
# Execute the next cell. After execution, the output immediately below should be:

```
[".NET","csharp","fsharp","html","http","javascript","kql","mermaid","pwsh","sql","value","vscode","webview"]
[".NET","csharp","fsharp","html","http","javascript","kql","mermaid","pwsh","sql","value","webview"]
```

#!javascript
Expand Down Expand Up @@ -140,11 +140,9 @@ await kernel.root.send(command);

# Execute the next cell, the output should be displayed as HTML like so:

| Name | Salary |
:---|---: |
| Developer | 42 |
<details class="dni-treeview" open=""><summary><span class="dni-code-hint"><code>{ Name = Developer, Salary = 42 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Name</td><td><div class="dni-plaintext"><pre>Developer</pre></div></td></tr><tr><td>Salary</td><td><div class="dni-plaintext"><pre>42</pre></div></td></tr></tbody></table></div></details>

change the renderer using the `...` element, choose the json and the output should look like so:
Next, change the renderer using the `...` element, choose the json and the output should look like so:

``` json
{"Name":"Developer","Salary":42}
Expand All @@ -153,7 +151,7 @@ change the renderer using the `...` element, choose the json and the output shou
#!csharp

var value = new { Name = "Developer", Salary = 42 };
value.Display("application/json", "text/html");
value.Display("text/html", "application/json");

#!markdown

Expand Down
15 changes: 15 additions & 0 deletions dotnet-interactive.sln
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactiv
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.NamedPipeConnector.Tests", "src\Microsoft.DotNet.Interactive.NamedPipeConnector.Tests\Microsoft.DotNet.Interactive.NamedPipeConnector.Tests.csproj", "{B12834B8-373E-4932-852B-90E332A4BCED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.Interactive.Parsing.Tests", "src\Microsoft.DotNet.Interactive.Parsing.Tests\Microsoft.DotNet.Interactive.Parsing.Tests.csproj", "{55138BD7-111A-43A5-BFBB-326606C4C1B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -695,6 +697,18 @@ Global
{B12834B8-373E-4932-852B-90E332A4BCED}.Release|x64.Build.0 = Release|Any CPU
{B12834B8-373E-4932-852B-90E332A4BCED}.Release|x86.ActiveCfg = Release|Any CPU
{B12834B8-373E-4932-852B-90E332A4BCED}.Release|x86.Build.0 = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|x64.ActiveCfg = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|x64.Build.0 = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|x86.ActiveCfg = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Debug|x86.Build.0 = Debug|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|Any CPU.Build.0 = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|x64.ActiveCfg = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|x64.Build.0 = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|x86.ActiveCfg = Release|Any CPU
{55138BD7-111A-43A5-BFBB-326606C4C1B5}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -747,6 +761,7 @@ Global
{DA0B3BFC-ED19-4754-A9A0-0F831DBCC9C4} = {B95A8485-8C53-4F56-B0CE-19C0726B5805}
{BF68D266-500C-49AB-80EB-1B673E37E13A} = {B95A8485-8C53-4F56-B0CE-19C0726B5805}
{B12834B8-373E-4932-852B-90E332A4BCED} = {11BA3480-4584-435C-BA9A-8C554DB60E9F}
{55138BD7-111A-43A5-BFBB-326606C4C1B5} = {11BA3480-4584-435C-BA9A-8C554DB60E9F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6D05A9AF-CFFB-4187-8599-574387B76727}
Expand Down
1 change: 0 additions & 1 deletion dotnet-interactive.v3.ncrunchsolution
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<EnableRDI>True</EnableRDI>
<HotSpotsLineExclusionList />
<RdiConfigured>True</RdiConfigured>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.9.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 5d87547

Please sign in to comment.