dotnet/roslyn
GitHub で見るAdd Script property to InteractiveScriptGlobals and CommandLineScriptGlobals that returns a ScriptContext object
Open
#5,979 opened on 2015年10月14日
Area-InteractiveInteractive-ScriptingLogichelp wanted
説明
public class CommandLineScriptGlobals
{
public ScriptContext Script { get; }
public CommandLineScriptGlobals(..., ScriptContext context)
}
public class InteractiveScriptGlobals
{
public ScriptContext Script { get; }
public InteractiveScriptGlobals(..., ScriptContext context)
}
public class ScriptContext
{
public string GetPath([CallerFilePath]string path = null) { get; }
public string GetDirectory([CallerFilePath]string path = null) { get; }
public ScriptContext(string path)
}
The Script property would thus be available to scripts:
foreach (var arg in Script.Args)
Console.Writeline(File.ReadAllText(Path.Combine(Script.GetDirectory(), arg)));
...
In future we can add more features to this context:
class ScriptContext
{
Task<object> EvalAsync(string code, object globals);
}
F# has a similar concept: "fsi" object:
