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

Feature Request: Load/Save As a csx File #248

Open
cmiles opened this issue Aug 18, 2024 · 4 comments
Open

Feature Request: Load/Save As a csx File #248

cmiles opened this issue Aug 18, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@cmiles
Copy link

cmiles commented Aug 18, 2024

I am fairly sure that it is not reasonable to support all of NetPad's features via csx files - and it is not reasonable to support all csx file features in NetPad - but regardless of that I think it would have huge value to be able to seamlessly load csx and save csx files to run on the commandline.

It is VERY worth noting that I am not a hardcore csx user (I find the sweet spot to be fairly simple csx files) and not a hardcore NetPad user - but for my fairly simple usage and expectations I think the main two issues are:

  • Converting package references to the #r style with #r "nuget: SlackNet, 0.13.2" style nuget references to/from the csx files
  • Detecting and erroring/warning/not allowing csx saves where it doesn't make sense -> the easiest example might be if 'Kind: Sql' then the csx option shouldn't be offered or should error

Of course if there are already features supporting this that I have missed please let me know...

@tareqimbasher
Copy link
Owner

That is an interesting feature, and it would be pretty cool. But it also introduces a few question on how to support things like:

  1. .Dump()
  2. When targeting a database connection, the csx file wouldn't have the scaffolded DbContext, although we could include it all in the csx file, and it would be very large for larger data models
  3. NetPad offers some built-in data types like Image that the csx file wouldn't know how to handle
  4. Referencing one script from another, or referencing code from "My Extensions" (this feature isn't implemented yet but is planned)

The solution for points 1 and 3 could be publishing the NetPad.Runtime assembly that contains this functionality with the generated csx file.

That being said, there are 2 features that are currently cooking:

  1. I will be providing a way for users to execute any NetPad script from the command line. This actually already done and is under testing and I'm hoping will be in the next release or soon thereafter.
  2. Another feature I'm working on is the ability for users to export/publish their script as a CS project, or as a built executable.

Do you feel that these features would satisfy your use case or are you more after a csx specifically?

@cmiles
Copy link
Author

cmiles commented Aug 19, 2024

I didn't realize that command line execution was an in-testing feature and for all practical purposes that covers my use cases. I hope that 'dotnet tool install' support will be available but regardless I'm excited about the feature and excited it is coming soon - Thank You!

I do think that one reason to still consider some level of csx support at some point is that there is value in having an open format that multiple programs can work with at least for 'simpler' code. NetPad cross-platform and command-line will be kind of unbeatable - but I would love to also be able to fall back to dotnet-script/Roslyn Pad (and maybe LinqPad, and others, in the future?) and/or also know that anyone who wants to edit the file has some choice in tooling.

@tareqimbasher
Copy link
Owner

Yes adding dotnet tool install support is the plan, it would certainly make it much more accessible and easy to use. Still working out some kinks in the cli tool itself currently, but it's close!

I hear you about csx support and an open format. I can see what I can do to support importing/exporting csx files (effectively converting from/to .netpad format), and support running them outright, ie. without conversion, basically similar to dotnet-script but with some Dump() capabilities. Agreeing on an open format with other apps will be much trickier 😄

Supporting opening LINQPad query files in NetPad was requested a few times and it's definitely something I'll be exploring. Shouldn't be too bad (I think).

@tareqimbasher
Copy link
Owner

Some progress on the new CLI tool, npad.

cli

@tareqimbasher tareqimbasher added the enhancement New feature or request label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants