CSharpRepl icon indicating copy to clipboard operation
CSharpRepl copied to clipboard

Make a C# repl for your project in 2 minutes

Open mykeels opened this issue 9 months ago • 0 comments

Feature Description

Hi, thanks for making this tool @waf.

A while back, I experimented with using CSharpRepl as a dotnet tool in an existing project and gave up after struggling with running async methods, and registering services requiring IHttpContextAccessor. Perhaps this was because I was a missing a reference, but that's not why I'm opening this issue.

I'm opening this issue because I found it was much easier for my use-case, to use CSharpRepl.Services as a reusable package. I did this by stripping out:

  • Nuget references code
  • OpenAIAutocompleteService

because I didn't need these, then published the result as a reusable package. I could then use the resulting package in my project like:

await Repl.Run(
    new Configuration(
        references: AppDomain
            .CurrentDomain.GetAssemblies()
            .Select(a => $"{a.GetName().Name}.dll")
            .ToArray(),
        usings: ["System", "System.Collections.Generic", "System.Linq", "My.Project.NameSpace"],
        applicationName: "My.Project"
    )
);

This let me turn any .NET console application into a C# REPL, and I don't think such a reusable package is out there in the public nuget.org, at least I didn't find any when I searched for it.

So my suggestion? Can CSharpRepl.Services be distributed as a reusable package, so I don't have to maintain this myself? I think being able to make a fully functional C# repl for your project/business in 2 minutes has its benefits.


The reusable package would have to ship with code from the CSharpRepl project e.g.

  • NullLogger
  • TraceLogger
  • CSharpReplPromptCallbacks
  • PipedInputEvaluator
  • ReadEvalPrintLoop

And maybe there is a way to do it without stripping out the code I ended up removing.

Once again, thanks.

mykeels avatar Jan 28 '25 23:01 mykeels