> we don't want to create a new C# scripting dialect hence it isn't possible to "import" other files (that's not how C# works)
This statement is a bit confusing. From a user perspective, "dotnet run" does add a new scripting dialect. I would like to rewrite all my csx utilities to use this.
I've been using dotnet-script for several years for both unit testing code and for creating small utilities. Being able to load scripts (with "#load - see below) from other scripts is a core feature for keeping my code DRY. It would be a knock against "dotnet run" if a comparable syntax was not available. It's just a preprocessor - not a change to the C# syntax. Just like the other '#:' preprocessors being added.
I propose "#:load file.cs"
https://github.com/dotnet-script/dotnet-script#consuming-a-s...
> From a user perspective, "dotnet run" does add a new scripting dialect.
By dialect I mean that in CSX, the C# language has subtle differences in behavior compared to CS files (e.g., top-level methods are compiled differently). In 'dotnet run app.cs', the C# is exactly the same, hence it can be converted to a project (and we have a command for that - 'dotnet project convert').
> It's just a preprocessor - not a change to the C# syntax.
Should #:load work in normal C# files as well then? If yes, we would have two ways to include files - the normal way (include them in the project) or via #:load. If not, how would 'dotnet project convert' work? (It could paste the text but that's not very DRY if it's imported at multiple places.)
That's in short why #:load doesn't play very nicely with existing C# (it's a different paradigm of including other files). So the current proposal is to just make files in the same folder visible (just like they would be for a .csproj), because that's consistent with current C#, 'dotnet project convert' works, etc. But this proposal is not final yet, there are other options including what you suggest - see https://github.com/dotnet/sdk/issues/49193.