public async Task pound_r_is_not_split_into_separate_command_from_csharp_code() { var receivedCommands = new List <IKernelCommand>(); using var kernel = new CSharpKernel(); kernel.AddMiddleware((command, context, next) => { receivedCommands.Add(command); return(Task.CompletedTask); }); kernel.UseNugetDirective(); var path = Path.GetTempFileName(); var poundR_and_usingStatement = $@"#r ""{path}""{Environment.NewLine}using Some.Namespace;"; var nextSubmission = "// the code"; kernel.DeferCommand(new SubmitCode(poundR_and_usingStatement)); await kernel.SubmitCodeAsync(nextSubmission); receivedCommands .Cast <SubmitCode>() .Select(c => c.Code.Trim()) .Should() .BeEquivalentSequenceTo( poundR_and_usingStatement, nextSubmission); }
public static CSharpKernel UseVSCodeHelpers(this CSharpKernel kernel) { var command = new SubmitCode($@" #r ""{typeof(VSCodeInteractiveHost).Assembly.Location.Replace("\\", "/")}"" using static {typeof(VSCodeInteractiveHost).FullName}; "); kernel.DeferCommand(command); return(kernel); }
public static CSharpKernel UseJupyterHelpers( this CSharpKernel kernel) { var command = new SubmitCode($@" #r ""{typeof(TopLevelMethods).Assembly.Location.Replace("\\", "/")}"" using static {typeof(TopLevelMethods).FullName}; "); kernel.DeferCommand(command); return(kernel); }
public static CSharpKernel UseMathAndLaTeX(this CSharpKernel kernel) { if (kernel is null) { throw new ArgumentNullException(nameof(kernel)); } kernel.DeferCommand( new SubmitCode($@" #r ""{typeof(LaTeXString).Assembly.Location.Replace("\\", "/")}"" using {typeof(LaTeXString).Namespace}; ")); return(kernel); }