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] Allow script globals object type to be passed via .rsp file #23421

Open
filipw opened this issue Nov 28, 2017 · 7 comments
Open

Comments

@filipw
Copy link
Contributor

filipw commented Nov 28, 2017

Version Used:
2.4.0

Expected Behavior:

When using an .rsp file with csi, I'd like to be able to set/pass globals object type into the script runner. I'd imagine something like:

/globalstype:Ozzy.OutBack.Kangaroo,MyAssembly

The type could be searched for in the current load context, or there could be an additional configuration parameter for providing the path to the globals assembly.

Actual Behavior:

It is not possible to pass own globals object type. csi hardcodes CommandLineScriptGlobals as globals type.
The functionality would offer excellent flexibility for script authors.

This could also help with tooling for custom script hosts. An .rsp file with host-specific configuration of usings, references and globals type could be parsed by the editor and relevant host-specific language services/intellisense could be offered - which will have a great, positive impact on the C# scripting ecosystem.

Spun off from #23402 (comment)
cc @tmat

@haacked
Copy link

haacked commented Aug 24, 2021

I know this is almost four years old, but I'd like add my support for this feature as well. We run C# scripts in Abbot and we want people to be able to have a nice experience editing Abbot scripts in their local editor. But we also provide a nice global type to the runner. So anyone editing these scripts locally gets a bad experience.

@jmarolf
Copy link
Contributor

jmarolf commented Aug 25, 2021

@jonsequitur have any of the libraries https://github.com/dotnet/interactive has built on top of scripting already solved this problem?

@jonsequitur
Copy link

We haven't spent a lot of time on script automation yet (though it's under discussion). We don't have any experiences based around .csx.

As for adding top-level variables that users can interact with in a script, it's pretty simple. This is what we do in .NET Interactive rather than using the globals type.

@haacked
Copy link

haacked commented Aug 25, 2021

As for adding top-level variables that users can interact with in a script, it's pretty simple. This is what we do in .NET Interactive rather than using the globals type.

How do you add top-level variables for a script?

@jonsequitur
Copy link

@haacked
Copy link

haacked commented Aug 25, 2021

@jonsequitur Ah, I see. That seems to be a runtime injection then, right? What I'm looking for is a way to let people edit Abbot scripts in VS Code with full Intellisense. Right now, it's difficult to tell VS Code about the top-level variables that we inject.

@jonsequitur
Copy link

It is runtime but it enables Intellisense if the script engine is running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants