Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add simple `FSharpKernel` wrapper around fsi.exe #357

Merged
merged 9 commits into from Aug 22, 2019

Conversation

@brettfo
Copy link
Member

commented Aug 5, 2019

This is more of a proof-of-concept until we decide how we want to properly refactor fsi.

Since we're forced to scrape stdin/stdout, all returned values are forced to text/plain (hence no formatter support because everything is System.String); this will change once we have a proper kernel.

Includes moving most of CSharpKernelTestBase.cs into a common KernelTestBase.cs.

public void Dispose()
{
_disposables?.Dispose();
return new CSharpKernel();

This comment has been minimized.

Copy link
@jonsequitur

jonsequitur Aug 5, 2019

Collaborator

I have some changes in flight here as well and I'm leaning toward always using the same default set of extensions here as we use in the app at runtime. There's really only one supported configuration at the moment so we should test that.

This comment has been minimized.

Copy link
@brettfo

brettfo Aug 6, 2019

Author Member

Currently I think the .UseDefaultRendering() extension should stay only in CSharpKernelTestBase.cs because the F# kernel doesn't support any of that yet since it's really just a thin wrapper/scraper around fsi.

The other alternative is to broaden the extension methods to switch on specific types like so:

public static KernelBase UseDefaultRendering(this KernelBase kernel)
{
    switch (kernel)
    {
        case CSharpKernel csharpKernel:
            csharpKernel.UseDefaultRendering();
            break;
        case FSharpKernel fsharpKernel:
            // noop
            break;
    }

    return kernel;
}

public static KernelBase UseDefaultRendering(this CSharpKernel kernel)
{
    // do C#-specific stuff
}

Thoughts?

This comment has been minimized.

Copy link
@jonsequitur

jonsequitur Aug 7, 2019

Collaborator

Rather than change the type that UseDefaultRendering accepts, maybe we should add an overload for FSharpKernel. The implication of the proposed method is that it should work for all kernel types, which isn't really possible since we can't know all of the possible implementations of KernelBase.

This comment has been minimized.

Copy link
@brettfo

brettfo Aug 8, 2019

Author Member

I added void SetDefaultRendering() to IKernel so C# can implement it and F#'s is currently a noop.

Also updated to reflect your recent changes to master.

This comment has been minimized.

Copy link
@jonsequitur

jonsequitur Aug 8, 2019

Collaborator

I don't think that belongs on IKernel. Rendering is a fairly separate concern.

@brettfo

This comment has been minimized.

Copy link
Member Author

commented Aug 5, 2019

image

@brettfo brettfo force-pushed the brettfo:fsharp-kernel branch from e6b01d2 to 2c3fd03 Aug 6, 2019

@akshita31 akshita31 self-requested a review Aug 7, 2019

@brettfo brettfo force-pushed the brettfo:fsharp-kernel branch from d482d63 to b57cd46 Aug 8, 2019

@@ -16,5 +16,7 @@ public interface IKernel : IDisposable
IObservable<IKernelEvent> KernelEvents { get; }

Task<IKernelCommandResult> SendAsync(IKernelCommand command, CancellationToken cancellationToken);

void SetDefaultRendering();

This comment has been minimized.

Copy link
@jonsequitur

jonsequitur Aug 8, 2019

Collaborator

There's no generalization of default rendering that makes sense across all possible kernels, and the concept may not be something we even want to commit to for the two existing kernels. Let's keep the implementations specific to the cases where we understand what this means and keep the interface simpler for now.

This comment has been minimized.

Copy link
@brettfo

brettfo Aug 8, 2019

Author Member

Then move this back to be specific to the C# kernel? That's where we originally started which seems at odds with how I interpreted this comment, specifically, I read this:

maybe we should add an overload for FSharpKernel.

As

move this method to KernelBase

But to properly support CompositeKernel, the method needed to be on IKernel, instead.

This comment has been minimized.

Copy link
@jonsequitur

jonsequitur Aug 8, 2019

Collaborator

Sorry. I meant that we should have two methods, one for CSharpKernel and one for FSharpKernel. Their implementations are different and I don't know if this method will make sense for all kernels.

This comment has been minimized.

Copy link
@brettfo

brettfo Aug 8, 2019

Author Member

Added commit 03e8866, let me know what you think.

@brettfo brettfo force-pushed the brettfo:fsharp-kernel branch from 03e8866 to e20450c Aug 16, 2019

@brettfo

This comment has been minimized.

Copy link
Member Author

commented Aug 17, 2019

Rebased to handle recent changes in master.

@brettfo

This comment has been minimized.

Copy link
Member Author

commented Aug 22, 2019

Ping @jonsequitur for review.

@colombod
Copy link
Member

left a comment

Looks good to me

@brettfo brettfo force-pushed the brettfo:fsharp-kernel branch from a884d11 to 98328fb Aug 22, 2019

@brettfo brettfo merged commit 88b5134 into dotnet:master Aug 22, 2019

7 checks passed

WIP Ready for review
Details
license/cla All CLA requirements met.
Details
try-ci Build #20190822.10 succeeded
Details
try-ci (IntegrationTest) IntegrationTest succeeded
Details
try-ci (Linux) Linux succeeded
Details
try-ci (UpToDate_Windows) UpToDate_Windows succeeded
Details
try-ci (Windows_NT) Windows_NT succeeded
Details

@brettfo brettfo deleted the brettfo:fsharp-kernel branch Aug 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.